More than one viewport

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.

Kelly

You can either use multiple windows or a big window with two glViewport()'s. glViewport sets the rectangle to which opengl will draw afterwards.

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

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.

whusss upppp

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.

LeftViewPort()
{
glViewPort(parameters); //new veiwport over the old every time a scene is refreshed
3d geometry
}

RightViewPort()
{
glViewPort(parameters)
3d geometry
}

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)

Zee

Hey man? What’s up? Yeah. Strike.

thanks guys! I think I know how to do!