PDA

View Full Version : why SwapBuffers doesn't work?



RainMan
05-12-2003, 03:14 PM
Can anyone help me?

The animations are flickering although I use SwapBuffers.
ex: SwapBuffers(pDC->GetSafeHdc());
I don't get the correct HDC or what?

shinpaughp
05-12-2003, 03:20 PM
Are you using double buffer? Are you calling SwapBuffers more than once per frame?

RainMan
05-12-2003, 03:25 PM
I "enabled" PFD_DOUBLEBUFFER and I use SwapBuffers every time after I create the current scene.

shinpaughp
05-12-2003, 05:26 PM
Have you checked your code to make sure that SwapBuffers is only being called once. I accidentally had 2 calls one time time and others have also, which results in flickering. Also, check to see if you have vsync turned off. If so, turn vsync on and see how it looks. Maybe it is just tearing. Other than that, you would have to show some code, or give much more detail. Is the entire screen flickering? Parts of the screen? Just certain objects?

RainMan
05-12-2003, 05:48 PM
I call SwapBuffers only once per scene and the flickering affects all the rendered objects. About vsync don't know much, is part of glut? (I only use the VC's gl.h && MFC)
Actually SwapBuffers does nothing in my case (if I take it out the result is exactly the same - flickering).

shinpaughp
05-12-2003, 06:01 PM
Is the flickering the exact same with or without the SwapBuffers? Without swapping the buffers, there shouldn't be any animation at all, because you would be rendering to the back buffer and the front buffer would just be blank. Did you check to verify that the PIXELFORMATDESCRIPTOR you requested is the same as what was set with SetPixelFormat? What values did you et PIXELFORMATDESCRIPTOR to?

marcus256
05-13-2003, 02:09 AM
Could it be that you:

glDrawBuffer( GL_FRONT )

???

Deiussum
05-13-2003, 04:24 AM
It sounds like you are using MFC. Have you overloaded OnEraseBkgnd and made it return TRUE? If that's not done, Windows will erase the window itself to whatever color was used for the background brush. Returning TRUE tells MFC that you handle that yourself.

Still doesn't explain why you get the same results with or w/o SwapBuffers. But it still might be something to check.

balcn
05-15-2003, 02:20 AM
Probably the Window background color
must be different from the OpenGL clear color. Set both to the same color and try

balachandran

RainMan
05-16-2003, 12:57 PM
Thank you all for the advices ! http://www.opengl.org/discussion_boards/ubb/wink.gif

From what I've seen in my code:
- I have glDrawBuffer(GL_FRONT_AND_BACK);
- I am setting correctly the PIXELFORMATDESCRIPTOR;

I still haven't tried to overload the gl function, but in the days to come shall do it.
It is strange that the behaviour is the same with SwapBuffers or w/o, but at home I see no difference. Actually all my problems appear at work, where the scene flickers like hell. I heard something about some graphic cards making themselves some sort if prebuffering so it can be explained why it's all ok at home.

zeckensack
05-20-2003, 11:44 AM
Originally posted by RainMan:
- I have glDrawBuffer(GL_FRONT_AND_BACK);


That's your problem http://192.48.159.181/discussion_boards/ubb/smile.gif

Try glDrawBuffers(GL_BACK);
Or you can erase the line altogether, because GL_BACK is the default.

With GL_FRONT_AND_BACK you're in effect disabling double buffering (well, not quite, but you lose the benefit double buffering: it avoids the flicker).

I already tried posting that a few days ago with some more information, but this board wasn't working right, it seemed.


[This message has been edited by zeckensack (edited 05-20-2003).]