Added delay to make sure the app does not hog all CPU.
This commit is contained in:
parent
fdb4ad30f7
commit
d1dde08d35
Binary file not shown.
@ -420,6 +420,17 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
simIter++;
|
simIter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clamp the framerate so that we do not hog all the CPU.
|
||||||
|
const float FRAME_RATE = 40;
|
||||||
|
if (dt < FRAME_RATE)
|
||||||
|
{
|
||||||
|
int ms = (int)((FRAME_RATE - dt)*1000.0f);
|
||||||
|
if (ms > 10) ms = 10;
|
||||||
|
if (ms >= 0)
|
||||||
|
SDL_Delay(ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update and render
|
// Update and render
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
glClearColor(0.3f, 0.3f, 0.32f, 1.0f);
|
glClearColor(0.3f, 0.3f, 0.32f, 1.0f);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user