In C# XNA how is a single character drawn onto a Texture2D instead of the sprite batch ? I wish to do this in order to fill a bool[,] with the characters char\background data to analyze its shape.
In C# XNA how is a single character drawn onto a Texture2D instead of
Share
You could use a render target. The basic idea is instead of rendering your text to the back buffer, you render to a separate buffer, which can then give you a Texture2D.
See here: http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.rendertarget(v=xnagamestudio.31).aspx
question asker edit:
With permission I’ve added to this answer. At time of writing the information on the MSDN is very out of date and makes it look more complicated than it need so I wrote my own example of how to do this.
The class this is done in may have to inherit from IDisposable and implement void Dispose() which does nothing.
At which point this might be useful. http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2D/Texture_to_Colors.php