Game rendering

In games with every machine you play it the game goes same speed. how you do it?
Mean that like in CS on fast machines game runs about 100 FPS in lower end machines it runs 20 FPS but the game time goes sameway. It has something to do with rendering something=)
Please help me. I cannot sleep…

Solution: timer

I would really like to see one code example with working timer…
In glut with windows and linux compatible…

I would really like to see one code example with working timer…
In glut with windows and linux compatible…

yeah! me too!

#include <windows.h>

static LARGE_INTEGER time, last_time, diff, frequency;
float g_frame_time; //In seconds!
float g_frame_rate;

void Render(void)
{

//Render stuff here!

}

void CalcFrameTime(void)
{
GLfloat frame_time;

last_time = time;
QueryPerformanceCounter(&time);

diff.QuadPart = time.QuadPart - last_time.QuadPart;
frame_time = (GLfloat)diff.QuadPart / (GLfloat)frequency.QuadPart;

g_frame_time = frame_time;
g_frame_rate = 1.0f / frame_time;
}

void Update(float d_time)
{

//Move all game objects and cameras based on d_time here.

//For example. To move 1 metre a second. Move the camera with a vector of 1,0,0 multiplied
//by d_time.

}

void main(void)
{

QueryPerformanceCounter(&last_time);
QueryPerformanceCounter(&time);
QueryPerformanceFrequency(&frequency);
//Set iniitial frame time to 0.
g_frame_time = 0.f;

while(1)
{

  CalcFrameTime();		
  Update(g_frame_time);

  Render();

}
}

hope this helps.

Nutty

That’s Win32 code… it wouldn’t work under Linux and Windows… Still useful, and is certainly something that I needed for a simple and fast OpenGL app