OpenGL scene jumps while window is moving

Hi All!

I am developing an OpenGL application in C#.NET (by using CsGL, http://csgl.sourceforge.net ) and experiencing a strange problem. I do not know what is causing it (Windows XP or nVidia video card). The problem is present if the following code is included in OpenGL class (derived from OpenGLControl):

private bool draw = true;
protected override void OnPaint(PaintEventArgs pevent)
{
if(draw)
{
glDraw();
draw = false;
}
SwapBuffer();
}

(If you have CsGL, you can just add this code to class MyView in quadric example which comes with CsGL)

This code simulate a situation where the OpenGL scene is static (nothing is moving inside the scene) and too complex to be repainted each time paint even is raised (e.g., when some other windows are moving on top of the scene). Therefore, scene is rendered only once, and after that, SwapBuffer method refreshes the scene. In order to keep this example simple, there is no code for resizing the scene, etc.

Now, here is the problem. If such OpenGL window is moved first completely to the left (so that it is almost out of the screen) and then start moving slowly back (to the right), OpenGL scene will jump left/right inside the window and vertical gray stripe (window background) will appear from time to time. In addition, during the movement, scene is repainted from the left visible edge of the window (i.e., not from the real left edge which is out of the screen during the movement).

This problem is present at two XP PCs with different nVidia video cards, but NOT on a very old PC with NT 4.0 and ATI Rage 128 PRO video card.

Any help would be greatly appreciated.

Regards,
Fry

[This message has been edited by pjfry (edited 09-10-2003).]

framebuffer portions that correspond to obscured portions of the OpenGL window have undefined content. That is, after you drag another window over it, you can’t just use swapbuffers() “to get it back”. (btw, IIRC swapbuffers also leave the swapped buffer undefined).

You should render your complex scene to a texture, and draw it onto a quad.

Thanks for reply, but I am not completely convinced…

That is, SwapBuffering always perfectly refreshes the scene – no artifacts whatsoever. The only problem is that the whole OpenGL view is moving left-right inside the window (as if something is wrong with the docking of the view inside the window). In addition, the same view does not move at all under NT – steady as a rock.

Obviously, I am a beginner. Anyway, if there is no solution with SwapBuffer, I will try with texture.

Cheers,
Fry

As mentioned above, you are making assumptions about swapbuffers that aren’t guaranteed to be true.

To get the behavior you desire, you can create an off-screen render target (PBuffer), and copy from it to the front buffer.

-Evan