FrameRate Control

Started by
3 comments, last by huili0154 22 years, 2 months ago
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)
Advertisement
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.
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
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
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
Stay Casual,KenDrunken Hyena
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...

This topic is closed to new replies.

Advertisement