Advertisement Jump to content
Sign in to follow this  

Need multiple viewport help here

This topic is 4682 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to do multiple viewport, and i followed the tutorial available here to do that.. but I failed to get the results i want. Here's how i do.... At the reshape function there, I set the glViewport here and set the projection style here too. Then because of the camera position will be changed all the time(as user controling the camera) so i place the gluLookAt at the display function. Then after this gluLookAt, I set my 2nd viewport right after it with the projection style and the gluLookAt for the second viewport... The results: No model that I loaded in display in the display window...just.....BLACK.... Can someone please....please help me see where is the problem. Thanks very much. Here's my code. GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window { if (height==0) // Prevent A Divide By Zero By { height=1; // Making Height Equal One } winWidth = width; winHeight = height; glViewport(0,0,width,height); // Reset The Current Viewport glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix // Calculate The Aspect Ratio Of The Window gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,500.0f); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix } int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glLoadIdentity(); // Reset The Current Modelview Matrix //NEW//////////////////NEW//////////////////NEW//////////////////NEW//////////////// //gluLookAt(0,4.0f,150.0f, 0,3,0.0f, 0,1,0); gluLookAt(objCamera.mPos.x, objCamera.mPos.y, objCamera.mPos.z, objCamera.mView.x, objCamera.mView.y, objCamera.mView.z, objCamera.mUp.x, objCamera.mUp.y, objCamera.mUp.z); // At here, set the second viewport at the right upper part glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(winWidth/2, winHeight/2, winWidth/2, winHeight/2); glOrtho(0, winWidth, 0, winHeight, -3, 3);; glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0, 50.0, 50.0, 0.0, 2.5, 50.0, 0.0, 1.0, 0.0); ........ ........ ......}

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!