Multiple Overlapping Viewports?

At E3 this weekend I saw a very cool effect in (grumble) Microsoft’s Mechwarrior. The effect was a zoomed in window in the center of the screen. This can be accomplished (I think) in OpenGL by using two calls to glViewport like such

glViewport(0,0,width,height); // Main Window

glViewport(350,250,450,350); // inner zoom window

However when I attempt to do something like this, fragments from the main window randomly overwrites the inner window… any ideas on what I can do to fix this? perhaps strategically placed glFlush calls? or PostRedisplay calls? Any help?


I think you are having some problems with the depthbuffer. When you create a new viewport, you will still have the information from the previous viewport (colors and depth). Try to clear the viewport first with. Maybe no need to clear the colorbuffer, but you must clear the depthbuffer.

Just thoughts. Not even sure this is the way it works with viewports…

Actually, that worked, thanks! All I had to do was clear the depth buffer.