TextBatch and depth buffers

Mar 4, 2010 at 11:51 AM

Hi there

This is a bit of a newbie question I guess, but I was wondering how the TextBatch.DrawText() method handles the depth buffer. Is this something that is handled internally by the TextBatch class? I'm having problems with certain xna Models appearing above the rendered text when they should be appearing below. I've tried playing around with various renderState settings regarding the depth buffer and it doesn't seem to have have any affect.

I'm using this overload.. DrawText(extrudedText,textTransform,Color.Green). Maybe I should be using the on that takes an Effect to get control over the depth buffer?

Thanks

 

Coordinator
Mar 4, 2010 at 4:35 PM
Edited Mar 4, 2010 at 4:36 PM

Yes, either that or you could draw the text after those models (at least unless those models are flying around the text or something like that :D)

By Default, the TextBatch uses this simple effect to draw the text, which disables depth buffering and depth writing, so the text will come out on top and anything rendered after the text will draw over the text. I figured this would be the most useful default since I assumed most of the time, text would be drawn on top of everything else in the scene.

You can just clone the effect from the link above and remove the ZEnable and ZWriteEnable lines. Don't forget to set the ViewProjection and TextColor parameters yourself when using this as a custom effect ;)

Mar 14, 2010 at 11:33 PM

Hi Cygon, Thanks for the reply.

I tried the drawing the text after the models and it solved it. But I will also try the Effect approach later when I get some time (I will be needing the depth buffer later). 

Thanks for making such a handy library!

Aicos