XNA draw / paint onto a Texture2D at runtime

前端 未结 1 1677
北恋
北恋 2021-02-14 04:05

Morning all (if its morning where you are)

I have been looking around and have not seen a satisfactory method for doing this so thought I would ask around...

Ide

相关标签:
1条回答
  • 2021-02-14 05:08

    You can either use a RenderTarget2D (MSDN), which is itself a Texture2D (so you can use it in SpriteBatch.Draw). This allows you to render onto a texture in the same way you render onto the screen. You need to use GraphicsDevice.SetRenderTarget (MSDN) to set this up.

    Or you can use Texture2D.SetData (MSDN) to manipulate pixels directly. You can construct a transparent Texture2D directly (MSDN). Don't forget to Dispose of any textures or other resources you create yourself!

    0 讨论(0)
提交回复
热议问题