PDA

View Full Version : non-rectangular viewport, stencil and alpha



uruloki
09-19-2003, 03:40 AM
hi

i'm trying to implement a non rectangular viewport in a scene (to make a radar ppi). that's how i'm doing it right now:
- enable stencil
- draw the masking geometry, putting 1 in the stencil buffer where i draw
- draw the scene where stencil bit =1

it works fine as long as i use opengl triangles as region, but if i want to use instead a textured quad with an alpha texture it doesn't work anymore. Is there a wayaround, maybe using the depth buffer, or should i stick to non textured geometry to define my region?

i can post some pseudo code if you like

regards

Nicolas

[This message has been edited by uruloki (edited 09-19-2003).]

ioquan
09-19-2003, 02:13 PM
You could just draw your textured quad with alpha on top of your scene after you draw it, and not use the stencil buffer.

The stencil buffer doesnt care if the pixel you are drawing is completely invisible due to alpha, the pixel still gets drawn into the stencil buffer.

uruloki
09-21-2003, 10:52 PM
that wouldn't work, because i wanted to use the textured quad as a region to define the shape of my ppi viewport. I guess I'll use some triangles instead, it will be coarse but i guess it's the only way (depth didn't work neither).
thanks for your support
Nicolas

Bert
09-22-2003, 05:09 AM
if you enable alpha test (not just blending) it should work fine to set the stencil from an alpha quad.

uruloki
09-22-2003, 05:24 AM
I know i was missing something pretty obvious http://www.opengl.org/discussion_boards/ubb/smile.gif
it works very well now, thank you very much.
regards
Nicolas