void RenderLoop::run() { isRunning = true; int lastFPS = -1; u32 then = device->getTimer()->getTime(); while (device->run() && isRunning) { if (device->isWindowActive()) { const u32 now = device->getTimer()->getTime(); frameDeltaTime = (f32) (now - then) / 1000.f; // Time in seconds then = now; driver->beginScene(true, true, SColor(255, 33, 33, 33)); beforeRender(); render(); afterRender(); driver->endScene(); } else { device->yield(); } } }
void Charts::LineDecoration::render(TR3DUtils::RenderContext & context, const RenderArgs & args) const { if(TR_VERIFY(axis)) { beforeRender(context, args); const glm::float_t screenValue = axis->dataToScreen(this->value); if(axis->inScreenRange(screenValue)) { const glm::vec2 axisDirection = axis->getAxisDirection(); const glm::vec2 gridDirection = axis->getGridDirection(); const glm::float_t gridStart = axis->getGridStart(); const glm::float_t gridLength = axis->getGridLength(); const glm::vec2 start = (axisDirection * screenValue) + gridDirection * gridStart; const glm::vec2 end = (axisDirection * screenValue) + gridDirection * (gridStart + gridLength); const std::shared_ptr<TR3DUtils::LineRenderer> lineRenderer = context.getLineRenderer(); glLineWidth(this->lineStyle.thickness * args.contentScaleFactor); lineRenderer->bind(TR3DUtils::LineRenderer::Mode(lineStyle.mode)); lineRenderer->bindModelViewProjection(args.projection); lineRenderer->bindColor(Utils::colorToVec4(getColor()) * Utils::opacityToAlpha(getOpacity())); lineRenderer->drawLine(glm::vec3(start, 0.f), glm::vec3(end, 0.f)); } afterRender(context, args); } }