From 0751446e1d069263d25abcff49a32a380231709a Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 23 Feb 2015 10:49:56 -0500 Subject: Rewrote bloom so it's not super slow, also removed the frame from the screen mesh --- src/main.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 62c8b16..bc7832d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,22 +42,24 @@ int main() curGameState = new MapView(m, 100, 100); Texture* buffer = createTexture(GAME_WIDTH, GAME_HEIGHT); + //Texture* buffer = loadTextureFromBMP("../res/title.png"); double lastTime = glfwGetTime(); - double accum = 0.0; + int nbFrames = 0; while (!(quit || glfwWindowShouldClose(window))) { - // Tick! - accum += (glfwGetTime() - lastTime); - if (accum < 0) accum = 0; - while (accum > SECONDS_PER_FRAME) + double currentTime = glfwGetTime(); + nbFrames++; + if (currentTime - lastTime >= 1.0) { - curGameState->tick(); - accum -= SECONDS_PER_FRAME; + // printf and reset timer + printf("%f ms/frame\n", 1000.0/double(nbFrames)); + nbFrames = 0; + lastTime += 1.0; } - lastTime = glfwGetTime(); + curGameState->tick(); // Do rendering curGameState->render(buffer); -- cgit 1.4.1