PDA

View Full Version : How to do a head-up Display?



08-04-2000, 02:01 AM
Hi!

Does anyone know how to draw a rectangle with a texture mapped onto it, such that it is always drawn in front of all other objects??

Another situation is how do I draw such a rectangle that is always behind all the objects??

Kilam Malik
08-04-2000, 02:56 AM
To paint it in front of all: Disable the z-buffer before painting.
To paint it behind all I'm not sure... you could try glDepthFunc to specify when the depth test should succeed.

MikeC
08-04-2000, 03:15 AM
To draw behind everything else, just draw it first with glDepthMask(GL_FALSE)

To draw in front of everything else, just draw it last with glDisable(GL_DEPTH_TEST)

warlordQ
08-04-2000, 09:44 AM
Theres tones of ways.... by far the best way is to use the stencil buffer, you draw your rectangle, mask out those bits, then draw your interior.....

Cool isn't it....

But if you don't want to use the stencil buffer ( are you crazy ?? )... Then do it the hard way, which is, draw your scene, then draw your rectangle over the top of it.... Your rectangle will have a color that is transparent, that will be the inside color.... All you have to do is texture map that onto a QUAD ( which is the size of the screen ), with the GL_BLEND turned on...

Pauly
08-04-2000, 03:34 PM
Wha?

Are you being ironic? (We Engliash are renoun for that - but I didn't get the impression you were being ironic at all).

The best way is the render your scene then disable depth buffering (if necessary) and render your HUD to a 2d projection. Simple.

Paul.

08-04-2000, 08:35 PM
Thats what I do... make it a 2d projected... with the viewport as 0,w,0,h... gives me easy access to the screen's cords..