Mercurial > hg > forks > gldragon
changeset 10:c6c419861101
Use SDL_GetTicks() instead of std::clock().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 28 Oct 2019 12:59:18 +0200 |
parents | 87cb16492d91 |
children | 89dc8caeff41 |
files | glxdragon.cpp |
diffstat | 1 files changed, 6 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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 <string> #include <vector> #include <cstdio> -#include <ctime> #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(); } }