Jump to content
  • Advertisement
Sign in to follow this  
pupillo

OpenGL glutSwapBuffers() and vsync

This topic is 3761 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, my appl moves some objects and should synchronize the frame drawing to the vertical sync of the monitor. I've the following pseudo code for the display registered function (written in MSVC 6.0 on Windows XP): void display(void) { ... draw my objects glFinish(); //NOTHING CHANGES IF I COMMENT THIS LINE glutSwapBuffers(); glutPostRedisplay(); } If I disable (by the desktop->property->advanced->openGL...) "wait for Vsync", I get a frame rate as high as 500 FPS (flickering of course). If I enable it, the frame rate correctly falls down to 60FPS (which corresponds to my monitor refresh rate) BUT the objects keep on flickering (Some moments I can see some objects cut in two staggered halfs by an imaginary descending horizontal line ). I think: if with "wait for Vsync" disabled I get 500FPS, then the time required for drawing is very smaller than the video frame time so it should work very well once synchronized with Vsync. Another thing: the usage of the CPU remains 100% even when "wait for vsync" is enabled, as if glutSwapBuffers did a continuous polling instead of sleeping waiting for being waked up. Nothing changes if I have a fullscreen mode or a small window. Thanks Tommaso

Share this post


Link to post
Share on other sites
Advertisement
Quote:

If I disable (by the desktop->property->advanced->openGL...) "wait for Vsync", I get a frame rate as high as 500 FPS (flickering of course).
If I enable it, the frame rate correctly falls down to 60FPS (which corresponds to my monitor refresh rate) BUT the objects keep on flickering (Some moments I can see some objects cut in two staggered halfs by an imaginary descending horizontal line ).


I guess there is some other problem then. Try your program on other computers.

Quote:

glFinish(); //NOTHING CHANGES IF I COMMENT THIS LINE


Why do you call glFinish?

Share this post


Link to post
Share on other sites
Quote:
glFinish does not return until the effects of all previously
called GL commands are complete. Such effects include all
changes to GL state, all changes to connection state, and
all changes to the frame buffer contents.


So, glFinish returns when the drawing is completed, which is probably immediately if you have a small amount of rendered objects. Therefore, glFinish has no effect there.

I can't help you with your problem, I'm not so familiar with GLUT. I'd suggest that you use SDL+OpenGL, GLUT gives too little control over the rendering in mine opinion. There are some good new SDL+OpenGL tutorials at the NeHe site.

Share this post


Link to post
Share on other sites
I tried glFinish as I read about that but I agree that it doesn't make sense. I will try on other PCs and have a look at SDL. Thanks.

Share this post


Link to post
Share on other sites
Partially solved,
I was using a notebook drving both its LCD and an external monitor. Once disabled the external one, the synchronization is ok. The CPU is still in use at 100% and I don't understand why.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!