Hello again, I was wondering how do you keep the frame rate of your OpenGL program the same on different computers. I''ve been doing the image translations via each call of "DrawGLScene()" under the "WinAPI WinMain(...)" function, but since not all computers are like mine... some cycle through faster or slower than mine. I was thinking of asking the user for a delay count and inserting the given number into the "Sleep()" function, but that does not seem like a very good idea. Should I take the refresh speed of the graphics card or something like that? Thankyou in advance.
My code for cycling is like this:
//UNDER WINAPI WINMAIN
...
while(!done)
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
if (msg.message==WM_QUIT)
{
done=TRUE;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else // If There Are No Messages
{
// Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene()
if ((active && !DrawGLScene()) || keys[VK_ESCAPE]) // Active? Was There A Quit Received?
{
done=TRUE;
}
else
{
SwapBuffers(hDC);
if(pic == 1 || pic == 2 || pic == 3 || pic == 4 || pic == 5 || pic == 6 || pic == 7 || pic == 8 || pic == 9)
{
pic_press=1;
}
if(screen != 0) //Start counting so we can "try" to position the cube correctly...
{
if(switch_side_c == 0)
{
move_side_c++;
}
if(adjust_near == 1)
{
move_near_c++;
}
}
DrawGLScene();
}
...
The object reacts to the cycling like this:
//Ignore the "GLCandace(...)" function
if(screen == 2)
{
//First Row
GLCandace(1,0,-3.5,3.1f,-12.0,0.00,0.0,0.0,0);
//The second cube is generated later to mask all other cubes
GLCandace(1,2,3.5,3.1f,-12.0,0.0,0.0,0.0,0);
//Second Row
GLCandace(2,3,-3.5,-0.1f,-12.0,0.0,0.0,0.0,0);
GLCandace(2,4,0.0,-0.1f,-12.0,0.0,0.0,0.0,0);
GLCandace(2,5,3.5,-0.1f,-12.0,0.0,0.0,0.0,0);
//Third Row
GLCandace(3,6,-3.5,-3.1f,-12.0,0.0,0.0,0.0,0);
GLCandace(3,7,0.0,-3.1f,-12.0,0.0,0.0,0.0,0);
GLCandace(3,8,3.5,-3.1f,-12.0,0.0,0.0,0.0,0);
//The second cube being generated
if(move_side_c < 45)
{
GLCandace(1,1,0.0,3.1f,-12.0,0.0,-0.03,0.0,1);
}
if(move_side_c > 45 && move_near_c !=30)
{
switch_side_c=1;
adjust_near=1;
GLCandace(1,1,finx,finy,finz,0.0,0.0,0.0,0);
}
if(move_near_c > 45 && move_near_c < 130)
{
movx=0;
movy=0;
GLCandace(1,1,finx,finy,finz,0.0,0.0,0.05,1);
}
if(move_near_c > 130)
{
glDisable(GL_BLEND);
GLCandace(0,1,0.0,0.0,8.3,0.0,0.0,0.0,0);
I''m sorry if this has already been delt with, I looked through the tutorials, but I have not found an answer.