Archived

This topic is now archived and is closed to further replies.

AHa

OpenGL OpenGL: How to detach frame rate form refresh rate

Recommended Posts

this is os specific
in windows u can disable it in the display properties tab, also theres an extension win_swap_interval (see my site for a demo)

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
If you are referring to the fact that when you use fullscreen exclusive mode that the speed of you rendering matches the speed of your refresh rate. The reason is simple. It is because of the surface option to wait for the verticle refresh before flipping the back buffer to the primary buffer. If you were to ignore this, your program would traverse though your code at full speed without stopping, but you would get a nasty flashing glitches in your graphics (fine for testing). To wait for your verticle refresh is to bring your main graphics rendering loop to a screeching halt until your refesh has flipped the surface. It is okay however, since when the flipping is done, your code blasts through the loop until it gets back to the flip surface routine again. The only way to have code run constantly without stopping for the flip is to run a separate thread.

Share this post


Link to post
Share on other sites
Actually I''ve noticed a number of things when running Win2k vs. WinMe.

In Win2k, when i run my demo in full screen mode, the FPS value cannot pass the refresh rate. However, running it in windowed mode, it does.

This problem does not occur under WinMe.
Also, i noticed the FPS is lower in fullscreen compared to windowed when running under Win2K. Again this problem does not occur in WinMe.

-Xtreme.

Share this post


Link to post
Share on other sites
Sorry but I have had this problem for a long time and i think it is related to the same issue. I notice in my games, there are set frame rates i can get. eg normally i get a frame rate of ~72, but there is a certain point beyond which adding 1 more poly causes frame rate to drops to 35, then again 24 and... I heard that this has to do with refresh rate or something. Could anyone explain to me why and what this is? is there a way to force a more gradual drop in framerate? Oh and i have noticed that this kindda doesn''t happen in Quake 3.

Thanks

Share this post


Link to post
Share on other sites
quote:
Original post by Xtreme
In Win2k, when i run my demo in full screen mode, the FPS value cannot pass the refresh rate. However, running it in windowed mode, it does.



Strange, I can run games in full screen with vsync disabled and get a higher fps than my refresh rate. Running Win2k pro w/ a 32meg geforce sdr, leaked 10.80 drivers.

Share this post


Link to post
Share on other sites
As was said in the previous post, I get higher numbers than my refresh rate in fullscreen in Win2K as well. Oh, and while I''m on this topic, I read a review about WinME vs. Win2K''s game performance, and Win2K was faster for almost every game except UT .

"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
Resist Windows XP''s Invasive Production Activation Technology!
http://www.gdarchive.net/druidgames/

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 )

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Announcements

  • Forum Statistics

    • Total Topics
      628354
    • Total Posts
      2982230
  • Similar Content

    • By test opty
      Hi all,
       
      I'm starting OpenGL using a tut on the Web. But at this point I would like to know the primitives needed for creating a window using OpenGL. So on Windows and using MS VS 2017, what is the simplest code required to render a window with the title of "First Rectangle", please?
       
       
    • By DejayHextrix
      Hi, New here. 
      I need some help. My fiance and I like to play this mobile game online that goes by real time. Her and I are always working but when we have free time we like to play this game. We don't always got time throughout the day to Queue Buildings, troops, Upgrades....etc.... 
      I was told to look into DLL Injection and OpenGL/DirectX Hooking. Is this true? Is this what I need to learn? 
      How do I read the Android files, or modify the files, or get the in-game tags/variables for the game I want? 
      Any assistance on this would be most appreciated. I been everywhere and seems no one knows or is to lazy to help me out. It would be nice to have assistance for once. I don't know what I need to learn. 
      So links of topics I need to learn within the comment section would be SOOOOO.....Helpful. Anything to just get me started. 
      Thanks, 
      Dejay Hextrix 
    • By mellinoe
      Hi all,
      First time poster here, although I've been reading posts here for quite a while. This place has been invaluable for learning graphics programming -- thanks for a great resource!
      Right now, I'm working on a graphics abstraction layer for .NET which supports D3D11, Vulkan, and OpenGL at the moment. I have implemented most of my planned features already, and things are working well. Some remaining features that I am planning are Compute Shaders, and some flavor of read-write shader resources. At the moment, my shaders can just get simple read-only access to a uniform (or constant) buffer, a texture, or a sampler. Unfortunately, I'm having a tough time grasping the distinctions between all of the different kinds of read-write resources that are available. In D3D alone, there seem to be 5 or 6 different kinds of resources with similar but different characteristics. On top of that, I get the impression that some of them are more or less "obsoleted" by the newer kinds, and don't have much of a place in modern code. There seem to be a few pivots:
      The data source/destination (buffer or texture) Read-write or read-only Structured or unstructured (?) Ordered vs unordered (?) These are just my observations based on a lot of MSDN and OpenGL doc reading. For my library, I'm not interested in exposing every possibility to the user -- just trying to find a good "middle-ground" that can be represented cleanly across API's which is good enough for common scenarios.
      Can anyone give a sort of "overview" of the different options, and perhaps compare/contrast the concepts between Direct3D, OpenGL, and Vulkan? I'd also be very interested in hearing how other folks have abstracted these concepts in their libraries.
    • By aejt
      I recently started getting into graphics programming (2nd try, first try was many years ago) and I'm working on a 3d rendering engine which I hope to be able to make a 3D game with sooner or later. I have plenty of C++ experience, but not a lot when it comes to graphics, and while it's definitely going much better this time, I'm having trouble figuring out how assets are usually handled by engines.
      I'm not having trouble with handling the GPU resources, but more so with how the resources should be defined and used in the system (materials, models, etc).
      This is my plan now, I've implemented most of it except for the XML parts and factories and those are the ones I'm not sure of at all:
      I have these classes:
      For GPU resources:
      Geometry: holds and manages everything needed to render a geometry: VAO, VBO, EBO. Texture: holds and manages a texture which is loaded into the GPU. Shader: holds and manages a shader which is loaded into the GPU. For assets relying on GPU resources:
      Material: holds a shader resource, multiple texture resources, as well as uniform settings. Mesh: holds a geometry and a material. Model: holds multiple meshes, possibly in a tree structure to more easily support skinning later on? For handling GPU resources:
      ResourceCache<T>: T can be any resource loaded into the GPU. It owns these resources and only hands out handles to them on request (currently string identifiers are used when requesting handles, but all resources are stored in a vector and each handle only contains resource's index in that vector) Resource<T>: The handles given out from ResourceCache. The handles are reference counted and to get the underlying resource you simply deference like with pointers (*handle).  
      And my plan is to define everything into these XML documents to abstract away files:
      Resources.xml for ref-counted GPU resources (geometry, shaders, textures) Resources are assigned names/ids and resource files, and possibly some attributes (what vertex attributes does this geometry have? what vertex attributes does this shader expect? what uniforms does this shader use? and so on) Are reference counted using ResourceCache<T> Assets.xml for assets using the GPU resources (materials, meshes, models) Assets are not reference counted, but they hold handles to ref-counted resources. References the resources defined in Resources.xml by names/ids. The XMLs are loaded into some structure in memory which is then used for loading the resources/assets using factory classes:
      Factory classes for resources:
      For example, a texture factory could contain the texture definitions from the XML containing data about textures in the game, as well as a cache containing all loaded textures. This means it has mappings from each name/id to a file and when asked to load a texture with a name/id, it can look up its path and use a "BinaryLoader" to either load the file and create the resource directly, or asynchronously load the file's data into a queue which then can be read from later to create the resources synchronously in the GL context. These factories only return handles.
      Factory classes for assets:
      Much like for resources, these classes contain the definitions for the assets they can load. For example, with the definition the MaterialFactory will know which shader, textures and possibly uniform a certain material has, and with the help of TextureFactory and ShaderFactory, it can retrieve handles to the resources it needs (Shader + Textures), setup itself from XML data (uniform values), and return a created instance of requested material. These factories return actual instances, not handles (but the instances contain handles).
       
       
      Is this a good or commonly used approach? Is this going to bite me in the ass later on? Are there other more preferable approaches? Is this outside of the scope of a 3d renderer and should be on the engine side? I'd love to receive and kind of advice or suggestions!
      Thanks!
    • By nedondev
      I 'm learning how to create game by using opengl with c/c++ coding, so here is my fist game. In video description also have game contain in Dropbox. May be I will make it better in future.
      Thanks.
  • Popular Now