Render buffer to texture2D object in XNA

亡梦爱人 提交于 2019-12-13 03:45:41

问题


In XNA is there a way to render the contents of a spriteBatch after drawing to a texture object before rendering to the screen?


回答1:


You'll need to switch your render target for the spritebatch and then grab the texture out of it. This MSDN article explains it pretty well.

http://msdn.microsoft.com/en-us/library/bb976073.aspx




回答2:


As Hexxagonal already answered, yes you can. But you might get into trouble, if you are using sprites with translucency. The reason is, that two overlapping sprites wont end up with the right alphavalue in your offscreen rendertarget.

To make things right you will have to make your own SpriteBatch and start using premultiplied alpha.




回答3:


Here's an additional link to Shawn Hargreaves' excellent blog where he talks about rendertarget semantics:
http://blogs.msdn.com/shawnhar/archive/2007/02/04/xna-rendertarget-semantics.aspx



来源:https://stackoverflow.com/questions/1043071/render-buffer-to-texture2d-object-in-xna

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!