Fps question about openGL

Started by
7 comments, last by ironhell3 22 years, 2 months ago
Hi, i have this problem: i made lets say a spinning cube.The problem is that in slow machines (2 fps) it spins only 4 times per second, while in a fast machine (50fps) it spins 100 times a second...How can you say that it spins only with a fixed speed, lets say 10 times a second no mater in what system runs?? Thanks for your time!
Advertisement
The problem is simple and has been covered many times before.

You use a per-frame basis for your animation, eg you increase your rotation angle every time OpenGL draws a new picture.

You have to use a per-clock basis.

That is, at each new frame, you DON''T do have to do that :

my_angle += 1.0f;

But you have to do that :

my_angle += rotation_angle_per_second * elapsed_seconds_since_last_frame;

where rotation_angle_per_second is constant, and where elapsed_seconds_since_last_frame has to be computed every frame.
Thanks a lot! this really helped me a lot!
One last question: how can i add an icon to my .exe?
The icon shouldn''t be read externally but from <> the executable...Probably this is a silly question but i don''t have any idea if this cone be done.
Thanks again for your time!


It's easy to add an icon to your .exe :-) Just add an icon resource to your project. For instance in VC++ (i don't know what you are using) just click Resource form the Insert menu. Then select icon. You can import an existing icon or paint a new one. The first icon in your resource file will show up in Explorer as the program's icon. To add the icon to your window when the application is running, make sure to include something like this when defining your window class:

wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(ID_MYICON));

Hope this helps!


Edited by - DDSquad on February 8, 2002 12:43:34 PM
-------------------------------------------------------BZZZZTT - CRASH - BANG"What was that?!""Captain, it appears that we have encountered a strange sub-space anomaly. I'm getting a high reading of tracheons beams. The anomaly seems to be some kind of rift in the space-time continuum. -- Never mind, Bones was just using the microwave again."
Thanks a lot!!!!

Okay, I don''t have access to VC++ right now so I can''t test this out. Let me ask the fps question yet again, in more detail.

Say I want my player to move 2 units per second. I would have to create a variable named "time" that stores the time it took for the last frame to render, in seconds.

So, for example when I''m running at 60 fps, time would be 0.1666 seconds. So the distance I need to move the player would be (playerspeed * time) = 0.3332 units. Right ?

Remember, I haven''t tested this yet, but I''m not entirely comfortable with one thing : how can this method be exact ? These calculations take place before any of the rendering is done, so you can''t know how much time it''s actually going to take to render the frame. The speed is based on the previous frame before the one you''re rendering - so if this frame runs much slower for some reason, the player speed would be too fast on this frame. Or am I mistaken ?

_________
"Maybe this world is another planet''''s hell." -- Aldous Huxley
_________"Maybe this world is another planet''s hell." -- Aldous Huxley
well no method is 100% accurate personally ive gone away from a variable timestep to a fixed timestep eg where u run your physics/collions/ai at a fixed rate of say 50/60/100hz

http://uk.geocities.com/sloppyturds/gotterdammerung.html
trying to run everything at a fixed rate is not good.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
You can find a great FPS demo at http://www.gametutorials.com

-The Headstones are talking... Can you hear them?
-The Headstones are talking... Can you hear them?

This topic is closed to new replies.

Advertisement