I made a program (in C ++ using gl / glut) for training purposes, where you can mainly run around the screen (in the first person) and have several solids around the scene. I tried to run it on another computer, and the speed was completely different, so I was looking for an item, and now I'm doing something like this:
Standby function:
start = glutGet (GLUT_ELAPSED_TIME);
double dt = (start-end)*30/1000;
<all the movement*dt>
glutPostRedisplay ();
end = glutGet (GLUT_ELAPSED_TIME);
Display function:
<rendering for all objects>
glutSwapBuffers ();
My question is: is this the right way to do this? Is the scene displayed immediately after the idle function?
I tried placing end = glutGet (GLUT_ELAPSED_TIME) before glutSwapBuffers () and didn’t notice any changes, but when I put it after glutSwapBuffers () it slows down and even sometimes stops.
EDIT: , , , , , , idle() , display() , , , , - , ? ( ?)
, .
.