I have used your library to add an in game console to my game, and have been very impressed. I do have a problem thoughin that after the first time I render a line of text, all black parts of my model become see through and the lighting visibly changes. Do you know why? I am just using the DrawString method and have followed your intro tutorial.
Thanks,
Mike
Some RenderStates are changed...
That's a common problem because the Effect used by Nuclex.Fonts changes some render states that are likely to affect your drawing commands.
The render states changed are:
AlphaBlendEnable = trueDepthEnable = falseDepthWriteEnable = falseStencilEnable = falseCullMode = NoneIt would be possible to save and restore the render states during the
DrawString()call, but I didn't do so because some state changes are rather costly in terms of performance.The best solution for you would be to use the new
TextManagerclass and perform yourDrawString()calls through this class. It will queue any drawing operations until the end of the frame (or until you call itsDraw()) method yourself. After that, you can restore the render states indicated above. As a side effect, you will also get a performance increase :)Thanks for the help. I have
Thanks for the help. I have now succesfully migrated to the TextManager class and while I was at it version 1.2 as well!
The line that was causing me the difficulties was:
device.RenderState.StencilEnable = true;
with this at the start of my draw method it was problem solved. Thanks very much,
Mike
what is this TextManager
what is this TextManager class u speak of... cus it seems to be used in the Nuclex.fonts however im still getting the problem and i cant type device.RenderState.StencilEnable = true;
is there a download i need, or a tutorial i can look at?
It's Part of Nuclex.Fonts
TextManageris aGameComponentthat's provided with the latest Nuclex.Fonts release. The demo application already shows you how to use it.The
TextManagerwill not magically solve the problem. You still have to putdevice.RenderState.StencilEnable = trueand the other settings I posted above after you've finished drawing text or alternative when a new frame is drawn.If you're get an error when typing
device.RenderState.StencilEnable = true;trythis.graphics.GraphicsDevice.RenderState.StencilEnable = true;instead.deviceis just just some variable / field in Mike's code.Post new comment