Results 1 to 7 of 7

Thread: Game rendering

  1. #1
    Guest

    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...

  2. #2
    Member Contributor
    Join Date
    Feb 2001
    Location
    Slovakia
    Posts
    53

    Re: Game rendering

    Solution: timer

  3. #3
    Guest

    Re: Game rendering

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

  4. #4
    Guest

    Re: Game rendering

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

  5. #5
    Senior Member Regular Contributor
    Join Date
    Jun 2000
    Location
    Brazil
    Posts
    102

    Re: Game rendering

    yeah! me too!

  6. #6
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Portsmouth, Hampshire, England
    Posts
    926

    Re: Game rendering

    Code :
    #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(&amp;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(&amp;last_time);
    	QueryPerformanceCounter(&amp;time);
    	QueryPerformanceFrequency(&amp;frequency);
    	//Set iniitial frame time to 0.
    	g_frame_time = 0.f;
     
    	while(1)
    	{
     
    		CalcFrameTime();		
     
     
    		Update(g_frame_time);
     
    		Render();
     
     
     
     
     
    	}
    }
    hope this helps.

    Nutty

  7. #7
    Member Contributor
    Join Date
    Feb 2001
    Posts
    89

    Re: Game rendering

    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
    -pATCheS

Similar Threads

  1. Replies: 5
    Last Post: 05-25-2018, 06:55 PM
  2. Making a realistic game engine rendering system
    By somodan in forum OpenGL: User Software
    Replies: 2
    Last Post: 09-23-2012, 07:40 AM
  3. OpenGL - game, NOT rendering objects, not in view.
    By BerlinBrown in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-16-2009, 06:52 PM
  4. Convert Java SW rendering to OpenGL HW rendering?
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-12-2004, 10:24 AM
  5. using basic opengl rendering results for software rendering
    By divide in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 01-04-2004, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean