Hi,
I’m experimenting with multiple viewports, and got them to work, but not quite the way I was hoping for. First, here’s my display function (pretty simple):
void display()
{
glEnable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glViewport(0,0, (cxClient/2)-2, cyClient);
glScissor(0,0, (cxClient/2)-2, cyClient);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)(cxClient/2)/(GLfloat)cyClient, 1.0f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glScalef(1.0, 2.0, 1.0); // modeling transformation
testtriangle();
// Force the draw
glFlush();glViewport((cxClient/2)+2, 0, (cxClient/2)-2, cyClient);
glScissor((cxClient/2)+2, 0, (cxClient/2)-2, cyClient);
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)(cxClient/2)/(GLfloat)cyClient, 1.0f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glScalef(1.0, 2.0, 1.0); // modeling transformation
testtriangle();// Force the draw and swap
glFlush();
SwapBuffers(g_HDC);
}
Like I said I got the two viewports running, but I wanted ~ 2 pixel border the native window background color around each viewport. I defined the background color in the WNDCLASSEX structure, and it displays fine when I don’t call this display function. I thought the offset with both the viewport and Scissor test would restrict the OGL drawing into their respective regions, but I still lose the windows background color. Does anyone have any ideas? (I really don’t want to manually draw the color in if I don’t have to).
Here’s the screenshots of with and without the display function:
[This message has been edited by NTense (edited 02-04-2004).]