Draw String - textures missing

Topics: Developer Forum, Project Management Forum, User Forum
Feb 26, 2008 at 12:18 AM
Edited Feb 26, 2008 at 12:26 AM
Hi everybody,

I have a little problem with my project and I need urgent help.
I have a project with my own terrain whitch is created from *.bmp file. The terrain have grass texture and everything is pretty fine. But if i want to draw string to display then all textures are "lost" and the terrain is just like colored, no textured, but the text (string) is written good.

for drawing text I used SpriteBatchmySpriteBatch object. And in a jiffy when I begin with spriteBatch.Begin() method all textures are missing.

part of drawing code:


// Define string for drawing

// Find the center of the string

// Draw the string


Is any choice to draw string or how can i fix that?

thnx a lot.
Feb 26, 2008 at 1:07 AM
Edited Feb 26, 2008 at 1:09 AM
Actually this problem is likely to relate to spritebatch - and not the component library.
Spritebatch messes around with the render states, so the most simple way is to use

spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState);

The last arugment is the important one - using SaveState the SpriteBatch restores modified render states at spriteBatch.End();

When finetuning your code, you would only restore the render states you really need since this gives a performance increase compared to restoring all render states.