Archived

This topic is now archived and is closed to further replies.

huili0154

FrameRate Control

Recommended Posts

huili0154    122
I am using D3D8.1 to draw 2d primitives, the frame rate varying from 42 to 60 fps(display refresh rate is 60Hz), I wish to make it constantly at 30 fps, How to realize it? I draw many line strips, how to make the line wider than one pixel? Hui (please also reply to huili0154@163.net)

Share this post


Link to post
Share on other sites
CrazedGenius    156
Why do you want to limit the framerate?

In D3D, there is no way to set line width. You can either draw lines as polygons or draw many lines slightly offset from each other.

Share this post


Link to post
Share on other sites
Michalson    1657
I assume this is something like your code:

while(NoQuitAction)
{
GetPlayerInput();
AdjustEnvironment();//Move character based on input, do ai
Render();
}

Two solutions:

Change AdjustEnvironment() so that it is frame indpendent
(Check
Achieving Frame Rate Independent Game Movement
).

Or put a frame limiter:

int lastRender=GetTickCount();
while(NoQuitAction)
{
while(GetTickCount()-lastRender<1000 div 33) {};
lastRender=GetTickCount();
GetPlayerInput();
AdjustEnvironment();
Render();
}



Edited by - Michalson on February 8, 2002 10:12:41 AM

Share this post


Link to post
Share on other sites
DrunkenHyena    805
G''day!

Please don''t use a frame limiter. Using a time scale (Frame Independant) is much better. For example, if someone runs your game on a system that''s slower than your test system (periodically gets LOWER than 30FPS) then you game will not run properly since your timing is locked to the frame rate.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
Cybertron    122
aw man! I just fixed the bloody ship movement and now I have to re-write it again!!!!!

Everything is measured in frames, which is 10 minutes in game time! and each starsysyem has a different pixel sacle too

maybe i will just use all floats, where 1 = 1000 KM and have a time scale as suggested

now I have to re-write the game and editor, and scale everything. sounds like fun

I like using lines, it looks sorta retro...

Share this post


Link to post
Share on other sites