PDA

View Full Version : glViewport & how to use it



t3jem
06-14-2005, 08:16 AM
Hi,

I am have a map for my program that pops up when ever I press 'm', but I would create a new subwindow for it and it ate too much memory so I thought glViewport would be a better way to go. My problem is that I can't figure out how to get it to work. Here is my code.


void map()
{
glViewport(900,0,1000,100);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-10, 10, -10, 10, -10,10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

<draw map>
}

void update()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, 1000/700, 0.1, 50);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(view.x,view.y, view.z, view.lx, view.ly, view.lz, 0, 0, 1);
}
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glViewport(0,0,width,hight);
glLoadIdentity();

update();

<draw scene>

if(button[M])
map();

glutPostRedisplay();
glutSwapBuffers();
glFlush();
}What am I doing wrong? All replies are greatly appretiated

CWiC
06-15-2005, 12:07 AM
Maybe you need to clear depth (and color) buffer before use of viewport (use scissors for applying clear operations to viewport only) or what you mean "how to get it to work!"?

t3jem
06-15-2005, 08:45 AM
well I tried that, but I still got the same effect

Trahern
06-15-2005, 10:35 AM
Have you tried
glViewport(900,0,100,100);
?

glViewport( x,y, !width!, height )

CWiC
06-16-2005, 12:27 AM
Originally posted by Terminatore3:
well I tried that, but I still got the same effectWhat kind of effect you contemplate? Need to say that glViewport is work fine for me, so please don't expect that OpenGl is broken in this part...

t3jem
06-16-2005, 09:09 AM
Man, I'm an idiot, thnx sorry for your time.