View Full Version : More than one viewport
02-06-2001, 04:29 AM
Hi! I am trying to do an OpenGL program with multiple viewports. Let say I set up two viewports, one is left viewport and the other one is right viewport. If I wish to update left viewport then right viewport, how to do that? How do I switch from left viewport to right viewport? Is there any function to switch the viewport? Hopefully you can write me a simple OpenGL code in VC that can helps me to learn the way of doing multiple viewports. Thanks.
02-06-2001, 04:48 AM
You can either use multiple windows or a big window with two glViewport()'s. glViewport sets the rectangle to which opengl will draw afterwards.
02-06-2001, 04:56 AM
I am trying to use two viewports, so how do I draw objects to different viewports? The problem is I don't know how to control the viewport. For example I want to draw an object, how do I know that this object will be placed on which viewport? Thanks
02-06-2001, 06:14 AM
glViewport can just enable a certain rectangle in a opengl windows' client rectangle. The least set glViewport obiously rules.
If you have two (faked "windows", lets consider @ 0,0,100,100 and 100,0,200,100
just put the first rectangle with glViewport up, draw the stuff for the first window, the another call to glViewport and then render the second window. That is a faked two window system with one opengl context.
02-06-2001, 12:04 PM
I once did something similer to this (once sorry cant find that code "it was in my juvinile days")
I have a way of doing this im not sure if the best (i assume there must be a professional/correct/fast method of changing viewports perhaps by naming them or something)
but as Michael said the last glViewport() call obiously rules. so every time i have i wanted to refresh a view port i drew a new viewport over the old. this may make it more understandable.
glViewPort(parameters); //new veiwport over the old every time a scene is refreshed
and when u wish to draw geometry just cal the appropreate function
as u can c this is a "quick hack" and probably not the way it should be done but it worked for me.
if any 1 has comments about this method i would like to hear them im not to certain about what happens to the old vewports which i have drawn over are they still running and if so r they taking up system resources.
its an answer but its full of holes(sorry i couldn't do better than that)
02-06-2001, 12:41 PM
Hey man? What's up? Yeah. Strike.
02-07-2001, 03:28 AM
thanks guys! I think I know how to do! http://www.opengl.org/discussion_boards/ubb/smile.gif
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.