Skip to content

Commit

Permalink
Calculate the time this frame took.
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonard2 committed Jan 5, 2019
1 parent b65963e commit 479ce6c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions graphics/openGL/ScreenGL_SDL.cpp
Expand Up @@ -201,6 +201,7 @@ char mapSDLKeyToASCII( int inSDLKey );
static unsigned char keyMap[256];
static char keyMapOn = true;

long timeSinceLastFrameMS = 0;

// prototypes
/*
Expand Down Expand Up @@ -1671,16 +1672,23 @@ void ScreenGL::start() {
// can be negative (add to next sleep)
int oversleepMSec = 0;

timeSec_t frameStartSec;
unsigned long frameStartMSec;
unsigned long oldFrameStart;

Time::getCurrentTime( &frameStartSec, &frameStartMSec );


// main loop
while( true ) {

timeSec_t frameStartSec;
unsigned long frameStartMSec;


oldFrameStart = frameStartMSec;

Time::getCurrentTime( &frameStartSec, &frameStartMSec );

timeSinceLastFrameMS = frameStartMSec - oldFrameStart;
if( timeSinceLastFrameMS < 0 )
timeSinceLastFrameMS = 0;

// pre-display first, this might involve a sleep for frame timing
// purposes
Expand Down

0 comments on commit 479ce6c

Please sign in to comment.