Why does SpriteFont::DrawString always pass stencil test

Jan 8, 2013 at 12:33 AM

I set up stencil test in my app to restrict the graphics objects rendering inside a region. I use DirectXTK::SpriteFont::DrawString for text rendering and ID3D11Device1::Draw or ID3D11Device1::DrawIndex for the other objects like lines, textures. The issue is that the text objects are drawn both inside and outside the region as if text rendering always pass stencil test, whereas the rest graphics objects are only drawn inside the region. Could someone point out what's wrong? thanks.

Jan 8, 2013 at 2:30 AM

SpriteBatch.Begin will set all device state to default sprite rendering options.  If you want some other state to be used, you need to pass whatever state objects you want as parameters to the Begin call.

Jan 10, 2013 at 1:28 AM

I check the SpriteBatch::Begin() code and find that it uses 0 as stencil reference value, whereas I use 1 in my app.