float FpsLimiter::End() { calculateFps(); float frameTicks = SDL_GetTicks() - startTicks; if(1000.0f / maxFps > frameTicks) SDL_Delay(1000.0f / maxFps - frameTicks); return fps; }
float FpsLimiter::end(){ calculateFps(); float frameTicks = SDL_GetTicks() - _startTicks; if (1000.0f / _maxFps > frameTicks){ SDL_Delay(1000.0f / _maxFps - frameTicks); } return _fps; }
void Stage::update(double currentTime) { m_timer = currentTime; calculateFps(currentTime); //check if glfw window has been closed if (!glfwGetWindowParam(GLFW_OPENED)) { m_running = false; } //callback and give delta (time between frames) in seconds updateCallback(float(currentTime - m_lastTime)); m_lastTime = currentTime; m_frame++; }
void Screen::swap(void) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(-1, -1); glTexCoord2f(1, 0); glVertex2f(1, -1); glTexCoord2f(1, 1); glVertex2f(1, 1); glTexCoord2f(0, 1); glVertex2f(-1, 1); glEnd(); SwapBuffers(GetDC(hwnd)); MSG msg; while (PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } calculateFps(); }
void Video::swapBuffers() { SDL_GL_SwapWindow(window); calculateFps(); }