2011-12-08 10 views
2

かなり簡単。私は、 "Bananas"のような文字列をとり、SpriteFontをたたき、SpriteBatchのように画面に直接ではなくTexture2Dにレンダリングしたいと考えています。XNAで文字列をテクスチャに描画しますか?

できますか?別の方法として、ある種のFBO-esque機能と同様のことを達成できますか?

答えて

7

RenderTarget2Dクラスを使用できます。 http://msdn.microsoft.com/en-us/library/bb198676.aspx このようなもの:

RenderTarget2D target = new RenderTarget2D(GraphicsDevice, width,height); 
GraphicsDevice.SetRenderTarget(target);// Now the spriteBatch will render to the RenderTarget2D 

spriteBatch.Begin(); 

spriteBatch.DrawString();//Do your stuff here 

spriteBatch.End(); 

GraphicsDevice.SetRenderTarget(null);//This will set the spriteBatch to render to the screen again. 

//If you are going to create the render target inside the Draw method, do this: 
target.Dispose(); 
+0

ブリリアント。どのように私はドキュメントで、おかげでそれを逃したか分からない。 – Cheezmeister

関連する問題