Hi, I would like to create a program that uses two viewports. Is there a good tutorial on it? Any tips? Thanks,
Multiple viewports in the same window?
If so, just do this for every viewport:-
- Call glViewport with its dimensions.
- Call glScissor with the same list of dimensions. Don’t forget to glEnable(GL_SCISSOR_TEST)
- Set up a projection matrix with the correct aspect ratio of the viewport
- Draw your stuff.
It really is that simple.
Just look up glViewport and glScissor on http://msdn.microsoft.com/
…and 5) don’t forget that OpenGL state is shared between the viewports.
If you intend to clear the entire window (both viewports) with one glClear call, set glViewport to the entire window and glDisable scissor test.
[This message has been edited by marcus256 (edited 07-04-2002).]
If you intend to clear the entire window (both viewports) with one glClear call, set glViewport to the entire window and glDisable scissor test
You don’t have to set the viewport to the entire screen before clearing. glClear is only limited by the scissor region, and is not affected by the viewport region. So you can leave the viewport as it is and only disable the scissor test. Saves a gl-call and a state change
For a tutorial/demo on multiple OpenGL viewports see,
“Multiple Views” and “Antimating Multiple Views” at www.mfcogl.com.
They are in MFC, but the OpenGL stuff is valid for any OS and/or compiler.
I believe he’s talking about multiple viewports in the same window - multiple views in MFC simply means multiple windows, which isn’t the same thing.
The tutorial/demos are on multiple OpenGL viewports in the same window not multiple views in MFC.
Apologies for my incorrect assumption.