PDA

View Full Version : Different Projections in same window



SurGL
03-15-2001, 01:46 AM
Hello,
Can we apply different projections in same window.
For eg. I have to draw an object with orthogonal projection and rest of the scene with perspective projection. Is it possible.
How do I do it
Thanks
sur

Bob
03-15-2001, 02:01 AM
Of course it's possible. Just rebuild the projectionmatrix before drawing the different objects. Set an orthographic matrix before drawing the ortho-objects, and a perspective matrix before drawing the perspective-objects.



glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(...);
DrawFirstObjects();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(...); // or gluPerspective(...);
DrawSecondObjects();

Tim Stirling
03-16-2001, 10:32 AM
If you want the ortho. and perp. stuff to be in a seperate quadrant to make an editor or such like also change the viewport (glViewport) and use a stencil test to the same area to stop commands like glClear effect the whole screen and not just the viewport. I have some code if you want.(email me if you want)