News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

OpenGL - Frame Rate

Started by Rbraz, April 11, 2006, 06:44:23 PM

Previous topic - Next topic

Rbraz

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!

BogdanOntanu

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?
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

KSS

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.

hitchhikr

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.

Rbraz

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)


Rbraz

I found a better way to limit FPS, using "QueryPerformanceFrequency / QueryPerformanceCounter", works fine!  :toothy

Mark Jones

Hitchhikr, there appears to be a slight compatibility issue between the demos and the United Devices Agent - 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.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

hitchhikr

What other opengl applications ?

Mark Jones

OpenGL preview window of Rhinoceros
OpenGL driver for gMAX
And various games.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

hitchhikr

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.