PDA

View Full Version : viewports and glClear()



06-12-2003, 04:34 PM
I have two functions that are supposed to create two viewports on a single window. For some reason it only draws one of them. Can anyone help me? Here is some of the code:

void RenderScene(void)
{
glViewport(0,0,100,100);
glOrtho(-1000,1000,-1000,1000,1000,-1000);

glBegin(GL_LINES);
glColor3f(0,0,1);
glVertex3f(1000,10,0);
glVertex3f(-10,10,0);
glEnd();
}

void RenderScene2(void)
{
glViewport(100,100,100,100);
glOrtho(-1000,1000,-1000,1000,1000,-1000);

glBegin(GL_LINES);
glColor3f(1,0,0);
glVertex3f(1000,20,0);
glVertex3f(-10,20,0);
glEnd();
}


and in my winProc WM_PAINT case:

RenderScene2();
SwapBuffers(hDC);
ValidateRect(hWnd,NULL);

RenderScene();
SwapBuffers(hDC);
ValidateRect(hWnd,NULL);

The window this draws to is a 600x800 full screen window with windows in 600x800 resolution. This code only draws the RenderScene2() code.

Also can someone tell me if glClearColor() clears the entire window or just the current viewport? How do I clear just the current viewport when it does not take up the entire screen? Thanks.

errno
06-12-2003, 10:38 PM
in your rendering functions, you call glOrtho without calling glLoadIdentity.
the result is the concatenation of the 2 projection and i don't know what could it do.

Bob
06-13-2003, 01:29 AM
Also can someone tell me if glClearColor() clears the entire window or just the current viewport? How do I clear just the current viewport when it does not take up the entire screen?

glClear will clear the entire window. If you want to clear only a part of the window, use glScissor.

noobscratcher
12-24-2011, 05:07 AM
sorry for bringing this back up again but how would you clear only the 2ndviewport which has animation on vertexes instead of the 1st viewport with the background art on vertexes?