Advertisement

Viewports

Started by April 11, 2003 11:39 PM
3 comments, last by noRulez43 21 years, 10 months ago
If you have more than one viewport set up on the screen...can you have different viewing methods on both of them? I have a 3d scene but I would like to add a 2d area just for a menu sort of thing with buttons and stuff. My idea was to set up different viewports, but I can''t figure out how to have different settings on them. They seem to be the same. When I change one, the other changes. ugh. Thanks in advance.
first render your scene, then use glOrtho/gluOrtho2D, to change to orthographic projection and render the menu...
Advertisement
any idea what''s wrong with this? The polygon I try to draw at the end isn''t showing up:


  	glViewport( 0, 100, 500, 400 );	    glMatrixMode( GL_PROJECTION );   	glPushMatrix();	glEnable(GL_TEXTURE_2D);    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);	glEnable(GL_LIGHTING);	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); /*clear the window */	glMatrixMode(GL_MODELVIEW);    glLoadIdentity();    //gluLookAt(4,2,4,0,0,0,0,1,0);    gluLookAt(0,0,10,0,0,0,0,1,0);	//calculate rho, theta, and phi	cir_x = cir_r * sin(cir_t) * cos(cir_p);	cir_y = cir_r * sin(cir_t) * sin(cir_p);	cir_z = cir_r * cos(cir_t);	//-----------------------------	//(re)set light position	light_position[0] = cir_x;  //set x coord	light_position[1] = cir_y;  //set y coord	light_position[2] = cir_z;  //set z coord	//----------------------		glLightfv(GL_LIGHT0, GL_POSITION, light_position);        drawCube(depth);  //draw cube		glDisable(GL_LIGHTING);  //disable lighting to draw the buttons			glViewport( 0, 0, 500, 100 );	gluOrtho2D(0.0, (GLdouble)500, 0.0, (GLdouble)100);	glMatrixMode(GL_MODELVIEW);    glLoadIdentity();		glColor3f(1,0,0);	glBegin(GL_POLYGON);		glVertex2i(200, 30);		glVertex2i(400, 70);	glEnd();    glutSwapBuffers(); /* clear buffers */[/source  
Nevermind, I figured it out
Thanks James. I thought I''d never get it working.
No problem at all! Glad you got it working!

This topic is closed to new replies.

Advertisement