summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKamil Kaminski <nfm@phenon.localdomain>2010-09-30 00:55:28 -0500
committerKamil Kaminski <nfm@phenon.localdomain>2010-09-30 00:55:28 -0500
commit9bab4b58c1250be1594fa8bf971fae39fb258142 (patch)
tree3d6b177a0d0cb73fb4016e4bbe3d42279b31b2c7
parent845fadd25bc43789ced2be4c97a549e926619b8d (diff)
downloadGLPyramid-9bab4b58c1250be1594fa8bf971fae39fb258142.tar.gz
GLPyramid-9bab4b58c1250be1594fa8bf971fae39fb258142.tar.bz2
GLPyramid-9bab4b58c1250be1594fa8bf971fae39fb258142.zip
pyramid: half-assed fps counter, for fun
-rw-r--r--sdl/pyramid.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sdl/pyramid.c b/sdl/pyramid.c
index 153f13f..35cd1c6 100644
--- a/sdl/pyramid.c
+++ b/sdl/pyramid.c
@@ -1,6 +1,5 @@
/* pyramid.c
*
- * TODO: use native tga loader, fix window resize, multiple keys
*/
#include <SDL/SDL.h>
@@ -258,7 +257,7 @@ int main(int argc, char **argv)
exit(-1);
}
atexit(SDL_Quit);
- SDL_WM_SetCaption("Textured Pyramid", "Textured Pyramid");
+ SDL_WM_SetCaption("Textured Pyramid", NULL);
if ((screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL | SDL_GL_DOUBLEBUFFER
| SDL_RESIZABLE)) == NULL)
@@ -288,10 +287,23 @@ int main(int argc, char **argv)
SetupRC();
+ /* fps counter */
+ Uint32 startclock = 0;
+ Uint32 deltaclock = 0;
+ Uint32 current_fps = 0;
for (;;)
{
+ startclock = SDL_GetTicks();
processEvents();
render();
+
+ deltaclock = SDL_GetTicks() - startclock;
+ if (deltaclock != 0 )
+ current_fps = 1000 / deltaclock;
+
+ static char buffer[30] = { 0 };
+ sprintf(buffer, "Textured Pyramid: %04d fps", current_fps);
+ SDL_WM_SetCaption(buffer, NULL);
}
return 0;