OpenGL: How to detach frame rate form refresh rate
Put simply, the Unreal engine has problems. The software renderer effects the hardware renderer which causes some of the slowdowns in D3D and OGL. 3DRealms removed the software renderer from Duke Forever, and sped up the hardware renderer by doing so. Sure hope DNF does get released eventually, I soooo want that game! Even more so than the new Doom at the moment.
My reply to all these topics questions and so on:
First i have worked with DirectDraw.. There it''s very simple to detach the framerate from the refresh rate.. You only set in the flip functio some code like this DDFLIP_NOVSYNC
and it works fine.. I get framerates above 1000 fps ) but you have some tearing effects...
So in opengl i think there is an option to do this also. First I somtime plays quake it''s OpenGL and it has a function in it to do this.
So I want to know that code )
First i have worked with DirectDraw.. There it''s very simple to detach the framerate from the refresh rate.. You only set in the flip functio some code like this DDFLIP_NOVSYNC
and it works fine.. I get framerates above 1000 fps ) but you have some tearing effects...
So in opengl i think there is an option to do this also. First I somtime plays quake it''s OpenGL and it has a function in it to do this.
So I want to know that code )
I''m not really saying anything new here...
wglSwapInterval is your answer. wglSwapInterval(0) disables retrace synchronization and wglSwapInterval(1) enables it. Whatever you decide to use, wglSwapInterval _should_ override any driver settings, but don''t necessarily expect it to.
OpenGL was intended to be hardware-independent so things like retrace synchroniziation are handled by the OS, so don''t expect to have OpenGL do it. OpenGL is just for drawing stuff, not managing frame buffers or anything like that.
Personally, I''d rather use a hardware-indepentent API like OpenGL and not have to worry about setting up structures and querying stuff to the point that I have 20 pages of code before I can even draw something like with Direct3D. I may be wrong on this, but if anyone says that DirectX 8 eliminates that, I should point out that Microsoft just wrapped the old stuff in the same way that the OpenGL utility library does, and that''s something that''s existed in OpenGL long before Direct3D ever existed.
wglSwapInterval is your answer. wglSwapInterval(0) disables retrace synchronization and wglSwapInterval(1) enables it. Whatever you decide to use, wglSwapInterval _should_ override any driver settings, but don''t necessarily expect it to.
OpenGL was intended to be hardware-independent so things like retrace synchroniziation are handled by the OS, so don''t expect to have OpenGL do it. OpenGL is just for drawing stuff, not managing frame buffers or anything like that.
Personally, I''d rather use a hardware-indepentent API like OpenGL and not have to worry about setting up structures and querying stuff to the point that I have 20 pages of code before I can even draw something like with Direct3D. I may be wrong on this, but if anyone says that DirectX 8 eliminates that, I should point out that Microsoft just wrapped the old stuff in the same way that the OpenGL utility library does, and that''s something that''s existed in OpenGL long before Direct3D ever existed.
MSDN is not very uptodate with opengl. have a look at www.opengl.org or my site under gl extensions
http://members.xoom.com/myBollux
http://members.xoom.com/myBollux
I don''t want to sound dumb, but hey this place is for help right?
Is retrace synchronization is the same as vertical sync?
-Will
Is retrace synchronization is the same as vertical sync?
-Will
Yes, the politically correct term is "verticle retrace" but there are numerous other terms, e.g. "refresh rate". It seems like we have been repeating ourselves a lot, so here is how it works. The Cathode Ray Tube (Monitor) has to draw one line at a time usually in a top-to-bottom motion. It is going fast enough that the human eye detects it as one steady image. But if you notice, the lower the refresh rate, the more flashy and blurry your image gets (tough on the eyes). It is recommened to run in refresh rates of 75hz or higher.
The reason you get "tearing" is because, if you decide NOT to wait for the refresh to finish drawing and start at the top, the image you place in your primary buffer instantly goes to the screen, even if the monitor isn''t done drawing the first frame, so you get part of one image at the top of the screen and part of another image at the bottom (ugly).
When you tell your code to wait for "verticle syncing", you are waiting for the frame in your primary buffer to be completely drawn to the screen and the CRT to move back up to the top of the screen to start drawing the next frame. It is at this point, the backbuffer is flipped to the primary buffer, the CRT begins drawing. and you code is free to put more data in the back buffer. Your CPU is much faster than your monitor, so it gets done doing everything, long before the monitor has finished drawing the last bit of data you flipped to the primary buffer. So when you code gets back to the flip function. It waits again until it has permission to flip the buffers. Repeated a million times or so.
The reason you get "tearing" is because, if you decide NOT to wait for the refresh to finish drawing and start at the top, the image you place in your primary buffer instantly goes to the screen, even if the monitor isn''t done drawing the first frame, so you get part of one image at the top of the screen and part of another image at the bottom (ugly).
When you tell your code to wait for "verticle syncing", you are waiting for the frame in your primary buffer to be completely drawn to the screen and the CRT to move back up to the top of the screen to start drawing the next frame. It is at this point, the backbuffer is flipped to the primary buffer, the CRT begins drawing. and you code is free to put more data in the back buffer. Your CPU is much faster than your monitor, so it gets done doing everything, long before the monitor has finished drawing the last bit of data you flipped to the primary buffer. So when you code gets back to the flip function. It waits again until it has permission to flip the buffers. Repeated a million times or so.
Refresh rate is NOT the same as Vertical retrace. The refresh rate is, basically, what it says - the rate at which the vertical retrace occurs. This of course is assuming you are talking about the vertical refresh rate. The vertical retrace is the actual event where the electron gun is repositioning itself back at the top of the frame.
Vertical sync is a term used to denote that you are in synchronisation with the vertical retrace, that is you wait for the vertical retrace before doing the flip.
Vertical sync is a term used to denote that you are in synchronisation with the vertical retrace, that is you wait for the vertical retrace before doing the flip.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement