diff options
Diffstat (limited to 'sdl')
-rw-r--r-- | sdl/pyramid.c | 16 |
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; |