PDA

View Full Version : Display 2D image overtop of 3D scene



CaptainOatz
11-21-2007, 12:15 PM
Hi,

I've just started working with OpenGL, and I'm using Java to write a simple 3D first-person game. What I'm trying to do right now is draw a 2D image over the 3D scene, so it's always displayed on the screen no matter where the camera is pointing. Essentially, I want something like a 2D life-meter bar or current score to be overlaid like you see in games like GTA or Duke Nukem, except I don't need to draw text... I just want to load a small .png file and stick it on the corner of the screen. Does anyone have a piece of code or example of how to do this? (BTW, the OpenGL code in Java is almost identical to C++, so an example in C++ would be fine)

TIA

ZbuffeR
11-21-2007, 12:18 PM
An outline :

setup projection matrix for 3D scene
draw 3D scene
setup projection matrix for 2D scene (glOrtho for example)
draw 2D scene (just a small quad textured with the .png)
swapbuffers

CaptainOatz
11-21-2007, 12:22 PM
I've been trying to do that, but haven't been successful... but at least I know I'm on the right track.

Thanks

ZbuffeR
11-21-2007, 12:24 PM
Implementation details :

http://www.gamedev.net/community/forums/topic.asp?topic_id=104791

CaptainOatz
11-21-2007, 12:24 PM
Oh, sorry if this sounds ignorant, but how do I swap buffers?

CaptainOatz
11-21-2007, 12:25 PM
Thanks!