I’m having some problems with my Viewports.
I have a window with 2 viewports in it. The main viewport draws the scene, then the 2nd viewport draws the world orientation.
My problem is that after a rotation/translate, I immediately call my draw routine to redraw the views. When I do this, the main scene is now drawn in the world orientation viewport, and the main viewport is blank.
Here’s the pseudo:
//Setup small overlapping viewport in lower corner. (glOrtho)
glPopMatrix(); //Reset to large viewport
Am I missing something? Let me know if this needs clarification.
I don’t see any viewport or scissor calls. That’s what you want to look at. These have nothing to do with the matrix, so basically you’re showing us the wrong code.
You probably have a viewport call (and maybe scissor call too) in your draw orientation function somewhere and so you’re exiting that function with the orientation viewport.
You should probably take the viewport code from your onSize callback and place it in front of your draw, or in your DrawScene callback.
I pulled the OnSize viewport code to the start of the OnDraw as well now, here’s what I have:
glViewport(0, 0, width, height);
gluPerspective(45, width/height, 0.1f, 100f)
glViewport(0, 0, width/4, height/4);
glOrtho(0, width/4, height, height/4, -200, 200);
glPopMatrix(); //reset viewports.
everywhere I’ve looked, this seems to be correct settings, but now I don’t get the Orientation window drawn at all…
am I not storing a matrix somewhere? am I overwriting something before I draw it properly?
Did you look fro glScissor calls in the routine?
I enabled GL_SCISSOR_TEST
Created a glScissor() with the same dimensions as my orientation viewport, drew
the viewport, then disabled GL_SCISSOR_TEST before I swapped the buffers.
Still nothing displaying in the corner. The main scene doesnt get blocked in that area either.
It’s working now. For some reason, the Ortho Projection for the Orientation didn’t have the Origin at the centre of the viewport. It was in the bottom left corner. Don’t know why.
Thanks for all the help
Because parameters “left” specifies the left border and “bottom” the bottom.