glViewport & how to use it

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

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!”?

well I tried that, but I still got the same effect

Have you tried
glViewport(900,0,100,100);
?

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

Originally posted by Terminatore3:
well I tried that, but I still got the same effect
What 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…

Man, I’m an idiot, thnx sorry for your time.