Getting the damn stencil buffer to work.

Started by
3 comments, last by MENTAL 22 years, 6 months ago
Okay, here''s the deal. I have a square in the middle of the screen, and a mesh circling around it. when the mesh gets behind the quad, i want another mesh to be drawn instead (i know it sounds strange, but i''ll post a completed demo and you will be amazed at how cool it looks with the rest of the effects). anyway, i figured it would go like this: draw the initial mesh. draw the quad stencil in the outline of the quad draw the second mesh, but only when the depth test fails. only draw in the stenciled area. i''ve been hacking away at this for god knows how many hours and still it refuses to work. any suggestions welcome, and please, PLEASE, with some source code . MENTAL
Advertisement
Hi there,

well i did somthing simular -

draw the initial mesh.
draw the quad
stencil in the outline of the quad

(* Clear the depth buffer *)
glClear(GL_DEPTH_BUFFER_BIT)

draw the second mesh in the stenciled area.

(* Restore depth buffer *)
ReRender the scene with color buffer writes turned off.

(* Re Enable color buffer writes *)

you may want to scissor the area of the quad to speed things
up. Use glColorMask to switch color buffer writes on and off.

Hope it helps

Mark.



Edited by - MButchers on October 10, 2001 7:05:20 AM
oh boy, i knew i forgot to do something (damn depth buffer). okay, i''ll try it out. thanks for the help .


ARGH!!!!


MENTAL
Hey MENTAL! Haven''t heard from you in a *LONG* while! COME BACK TO #GAMEDEV!

Anyhoo, here are my two cents: the stencil buffer isn''t the best idea to use right now... A lot of cards still don''t have very good support for it, and is pretty slow.

------------------------------
Trent (ShiningKnight)
E-mail me
ShiningKnight Games
bleh been busy with coding cool stuff. i lied. been bogged down with college work .

i still cant understand the OpenGL stencil buffer, it definaly needs a GL_DWIM contant in there.

oh, SK, i dont suppose you can send me just the DX8 libs and headers please? i dont particularly want a 45mb download just so i can compile your tuts .

i''ll be back in #gd this weekend hopefully.

see ya later

MENTAL

This topic is closed to new replies.

Advertisement