Jump to content
  • Advertisement
Sign in to follow this  
D_a_M_a_G_e_D

Stencil buffer

This topic is 4597 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

Can any body explain to me how the stencil buffer works and how to use it with Direct3D 9.0b, i have read some articles talking about it but none helped me. Thank you.

Share this post


Link to post
Share on other sites
Advertisement
a Stencil buffer is a per pixel buffer that allows the user to stencil out parts that the user don't want to render. Stencilling as it's called is like masking out parts of the scene that you don't want rendered. The most typical usage of the stencil buffers are usually mirrors and shadows. You can look at these tutorials on using the stencil buffer.
Stencil Buffer Tutorial from NVidia
Stencil Buffer Tutorial from Me

I hope this helps.
Take care.

Share this post


Link to post
Share on other sites
These are some typical present params that I use:

[source lang=c#]
this.presentParams.Windowed = true;//I'm using windowed mode
this.presentParams.SwapEffect = SwapEffect.Discard;
this.presentParams.AutoDepthStencilFormat = DepthFormat.D16;
this.presentParams.EnableAutoDepthStencil = true;



but you have to remember to clear the depth buffer at the beginning of the scene:

[source lang=c#]
this.device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.Black, 1.0f, 0);
this.device.BeginScene();
//...Your draw code goes here
this.device.EndScene();



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!