Archived

This topic is now archived and is closed to further replies.

Getting the damn stencil buffer to work.

This topic is 5943 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
oh boy, i knew i forgot to do something (damn depth buffer). okay, i''ll try it out. thanks for the help .


ARGH!!!!


MENTAL

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites