PDA

View Full Version : Order of OpenGL Commands



Furrage
01-28-2002, 05:30 AM
I want to switch between three viewports in my app. However, the way I'm planning on doing it seems very slow and complicated (I haven't tried it yet). I'm hoping someone can give me a rough idea of how to optimise the code.

glClear(...)
glViewport(<Viewport1> )
glMatrixMode(<Projection> )
LoadIdentity()
gluPerspective(...)
glMatrixMode(<Model> )
glEnable(<Lighting>|<DepthTest> )
Drawto(BackBuffer)
SetUpLights(...)
DrawImage(<Image1> )

glViewport(<Viewport2> )
glMatrixMode(<Projection> )
LoadIdentity()
gluOrtho(...)
glMatrixMode(<Model> )
glDisable(<Lighting>|<DepthTest> )
Drawto(BackBuffer)
DrawImage(<Image2> )

glViewport(<Viewport3> )
glMatrixMode(<Projection> )
LoadIdentity()
gluOrtho2D(...)
glMatrixMode(<Model> )
Drawto(BackBuffer)
DrawImage(<Image3> )

glFlush()
swapbuffers()

Is there anything that I can change, or set up once so that I don't have to keep calling it over and over again. Example: Can I set up the lighting for <image1> then just enable and disable it when needed instead of setting it up each frame? Do I need to specify DrawTo(BackBuffer) each viewport, etc. Finally, would it be faster to do scissors testing than to use viewports?