# HG changeset patch # User Matti Hamalainen # Date 1572260358 -7200 # Node ID c6c419861101b16540e82dc6dc09b3b691e2c533 # Parent 87cb16492d91c518c34d749e2a9cba082d4ba1a6 Use SDL_GetTicks() instead of std::clock(). diff -r 87cb16492d91 -r c6c419861101 glxdragon.cpp --- a/glxdragon.cpp Mon Oct 28 00:15:37 2019 +0200 +++ b/glxdragon.cpp Mon Oct 28 12:59:18 2019 +0200 @@ -38,7 +38,6 @@ #include #include #include -#include #define SET_FRAMES (180 * 2) @@ -293,9 +292,8 @@ { struct Mesh dragonMesh; std::string dragonVS, dragonFS; - std::clock_t startTime; bool exitFlag = false, optShowHelp = false; - int nframes = 0; + int startTime, nframes = 0; // Check commandline argument for enabling shaders @@ -373,7 +371,7 @@ // Main loop starts - startTime = std::clock(); + startTime = SDL_GetTicks(); while (!exitFlag) { @@ -413,14 +411,15 @@ nframes = 0; // Get the time it took to render a full turn - double time = (double(std::clock() - startTime) * 1000.0f) / CLOCKS_PER_SEC; + double time = SDL_GetTicks() - startTime; + + // Restart the timer + startTime = SDL_GetTicks(); // Print the current frames per second printf("%.1lf ms for %d frames = %.1lf FPS\n", time, SET_FRAMES, (SET_FRAMES * 1000.0f) / time); - // Restart the timer - startTime = std::clock(); } }