Hello to all, I new here :wink
To hitchhikr,
I'm coding a little opengl demo and experienced some probs with frame rate, at my home computer (P4 2.8 GeForce 6600GT) I got 60 fps even (my vertical monitor refresh rate). And some people with Ati Radeon card is having problems, the fps goes up and down (20 to +100 fps, same for vsynch enabled or disabled, drivers updated...).
The question is: Do you know some way to solve this, how can I maintain a stable fps rate ?
p.s.: hitchhikr, your demos rocks!
Calculate how much time has elapsed from your last frame render, and if enough time has elapsed then render another frame, otherwise do nothing, do some AI or better offsr the remaining time to the OS via a Sleep(5) or something similar.
This way you can limit the frame rate to a maximum.
However IF your frame rate fluctuates that much ... then you might have some algorithmic problems...
Does it fluctuate when the objects in scene are the same and with the camera fixed?
Quote from: BogdanOntanu on April 11, 2006, 10:41:25 PM
... remaining time to the OS via a Sleep(5)...
Remaining time to OS:
Sleep(0)From SDK:
A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution.
The sleep command won't do any good.
i'm also using a radeon without such problem, the only explanation i can think of is that there's some programs running in the background like winamp or anything else eating too much system resources.
The use of the high perf counter should ensure that the interval between frames is constant.
Thanks for your replies!
Well, the best what i can do for now, not sure if its correctly:
*** (Pseudocode) ***
const MAX_FRAMES 60.0f
float const_speed = 0.5f //Velocity for movement
Init_OGL()
do
{
iFPS = FPS_Counter()
PosX = PosX - ( (const_speed * MAX_FRAMES) / iFPS )
glTranslatef(Posx,0,-10)
DrawCube()
UpdateBuffer()
}
While(!Escape_Key)
I found a better way to limit FPS, using "QueryPerformanceFrequency / QueryPerformanceCounter", works fine! :toothy
Hitchhikr, there appears to be a slight compatibility issue between the demos and the United Devices Agent (http://www.grid.org/download/) - when both are running simultaneously, every second exactly the demos drop a frame or two. I think the UD agent might use OGL also. But all other OpenGL apps seem to work fine with UD.
What other opengl applications ?
OpenGL preview window of Rhinoceros (http://www.rhino3d.com/features.htm)
OpenGL driver for gMAX (http://usa.autodesk.com/adsk/servlet/index?id=5562445&siteID=123112)
And various games (http://www.binarybroz.com/games.html).
It happens everytime UD is writing the result of it's computation to the harddrive, no reasons to get excited. Realtime animation and hd access = nono.