PDA

View Full Version : Multiple Viewport problems



thesouthpaw
03-17-2012, 10:16 AM
I'm trying to get multiple viewports in a single window. In my Display function, I'm doing this:
wWindow = width of window
hWindow = height of window



for(int n=0; n<2; n++)
{
if (n==0)
{

glViewport (0, wWindow/2, hWindow/2, wWindow/2);
glScissor (0, wWindow/2, hWindow/2, wWindow/2);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective( 10.0, wWindow/hWindow, 0.1f, 500.0 );
RenderObjects();
}
if (n==1)
{
glViewport (0, 0, hWindow/2, wWindow/2);
glScissor (0, 0, hWindow/2, wWindow/2);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective( 100.0, wWindow/hWindow, 0.1f, 250.0 );
RenderObjects();
}
}


When I do this, there is only one viewport being created (in the bottom left). I'm not sure what's wrong. Any insight would be awesome, cheers!

tonyo_au
03-17-2012, 07:17 PM
glScissor is not really necessary and won't be doing anything if you have not enabled it; but I can't see an obvious error. Try using the same perspective matrix in both views in case the objects are just too small to see in the top view

thesouthpaw
03-19-2012, 09:41 AM
Thanks for the feedback.

Follow up: I fixed the problem by moving the code into the Idle function and removing the for loop. Not sure why it wasn't working in the Display