Threads?

Mike Parker aldacron71 at yahoo.com
Thu Nov 16 02:30:41 PST 2006


Bill Baxter wrote:

>>>
> 
> You probably need to be more specific about what you plan to use for 
> drawing the output, because different libraries have different ways to 
> achieve what you want.  For instance GLFW has a function 
> "glfwSwapInterval()" to which you can pass the desired frame rate of 
> your rendering.  Internally it presumably has some sort of timer and 
> sleep call for suspending itself between renders.  I think SDL also has 
> something like that.
> 
> --bb

I don't want to hijack the thread, but that's not what glfwSwapInterval 
is for, Bill. What it does is to either turn vsync off (an arg of 0) or 
on (an arg of 1 or higher), vsync being the vertical retrace (i.e. the 
updating of the screen, scan line by scan line, from top to bottom). 
Passing an arg of 1 will wait for one whole vertical retrace to complete 
before updating the screen again. The speed of the retrace is determined 
by the current display mode's refresh rate (60hz, 80hz, or whatever). 
Calling glfwSwapInterval with a value of 1 will effectively cap the 
frame rate to the refresh rate (i.e. a 60hz refresh rate will cap at 60 
fps), but it is not the same as running a rendering loop at 60hz per 
second. If you want to specify a frame rate lower than the refresh rate, 
the rendering loop will need to be managed manually to achieve it.

On Windows, glfwSwapInterval is a wrapper for a WGL extension. On other 
platforms, it may not work at all.



More information about the Digitalmars-d-learn mailing list