graphics

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 395d2d8f40a05bc10ba31ca3fc1518549f7b472e
parent 57c977f49525dc562a66ab5adba1107c7fe5b5c0
Author: Brian Swetland <swetland@frotz.net>
Date:   Sat,  6 Jul 2013 00:59:20 -0700

common: count fps

Diffstat:
Mcommon/app.h | 1+
Mcommon/glapp.cc | 19++++++++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/common/app.h b/common/app.h @@ -179,6 +179,7 @@ protected: /* keys down */ unsigned keystate[16]; + int fps; private: int _vsync; diff --git a/common/glapp.cc b/common/glapp.cc @@ -16,6 +16,8 @@ #include <stdio.h> #include <stdlib.h> +#include <time.h> + #ifdef _WIN32 #define GLUE_DEFINE_EXTENSIONS 1 #endif @@ -107,7 +109,10 @@ int App::start(void) { win = SDL_CreateWindow("Application", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - width, height, SDL_WINDOW_OPENGL /* | SDL_WINDOW_RESIZABLE */); + width, height, SDL_WINDOW_OPENGL + // | SDL_WINDOW_RESIZABLE + // | SDL_WINDOW_FULLSCREEN + ); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); @@ -131,6 +136,11 @@ int App::start(void) { if (init()) return -1; + time_t t0, t1; + unsigned count; + t0 = t1 = time(NULL); + count = 0; + for (;;) { handleEvents(); @@ -146,6 +156,13 @@ int App::start(void) { } else { glFlush(); } + count++; + t1 = time(NULL); + if (t0 != t1) { + fps = count; + count = 0; + t0 = t1; + } } return -1; }