OpenGL - mixing perspective & orthographic projections
Hi all,
is it possible to mix perspective and orthographic projection in OpenGL?
What I have in mind is perspective projection for 3D game objects, and an overlaid orthographic projection for precise drawing of UI elements (e.g. scores, buttons, icons, text, HUD, etc.).
thanks.
is it possible to mix perspective and orthographic projection in OpenGL?
What I have in mind is perspective projection for 3D game objects, and an overlaid orthographic projection for precise drawing of UI elements (e.g. scores, buttons, icons, text, HUD, etc.).
thanks.
Yes, you can change the perspective and modelview matrices at any time and it only affects drawing done afterwards.
Excellent!
Is there any major performance hit for doing this, or can I pretty much do it at will?
thanks for the help.
Is there any major performance hit for doing this, or can I pretty much do it at will?
thanks for the help.
There shouldn't be any performance hit except in the sense that the more stuff you draw, the slower it'll be!
Don't forget that if you're using Z-buffering, you also need to clear the depth buffer between drawing your perspective stuff and drawing the orthographic overlay, otherwise your GUI elements will get sliced up by the 3D scene.
Don't forget that if you're using Z-buffering, you also need to clear the depth buffer between drawing your perspective stuff and drawing the orthographic overlay, otherwise your GUI elements will get sliced up by the 3D scene.
Quote:Originally posted by NCarter
Don't forget that if you're using Z-buffering, you also need to clear the depth buffer between drawing your perspective stuff and drawing the orthographic overlay, otherwise your GUI elements will get sliced up by the 3D scene.
Some of the old Pangea games suffered from this actually

Anyway, a better thing to do would be just turn off depth testing and do your drawing in the order you want it layered. Clearing the depth buffer has a non-trivial overhead involved. Infact to avoid the overhead of clearing the depth buffer some games do an interesting trick where they use half of the depth range each frame and flip the direction and range in the depth buffer used for the odd frames.
"He who breaks a thing to find out what it is, has left the path of wisdom."
- Gandalf the Gray-Hat
Bring Alistair Cooke's America to DVD!
Yep, turning depth testing off is how I got my frames counter up and running. I found the code in a demo named particle.c in the GLUT Examples from the OS X dev CD.
Iceman
Iceman
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| OpenGL Perspective Screen to Obj Coordinates Mapping Question | WhatMeWorry | 5 | 7,672 |
Feb 17, 2011 05:40 PM Last Post: Holmes |
|
| problem mixing 3d with 2d render | wolfra | 0 | 1,551 |
Feb 24, 2010 02:14 AM Last Post: wolfra |
|
| Turning off mixing iPod music | dsk00 | 0 | 2,261 |
Jun 4, 2009 10:25 PM Last Post: dsk00 |
|
| Mixing obj-c and c++ | DesertPenguin | 2 | 3,061 |
Aug 29, 2006 07:47 AM Last Post: TomorrowPlusX |
|
| getting the perspective i want | dave05 | 15 | 5,289 |
May 9, 2006 10:51 AM Last Post: unknown |
|

