0
这里是一个平局块:SpriteBatch将绘制到backbuffer而不是RenderTarget?
graphicsDevice.Clear(Color.CornFlowerBlue);
spriteBatch.Begin();
graphicsDevice.SetRenderTarget(renderTarget);
spriteBatch.Draw(texture2D, position, etc);
graphicsDevice.SetRenderTarget(null);
graphicsDevice.Clear(Color.Red);
spriteBatch.End();
这将产生一个红色的背景上我的Texture2D。为什么这会将我的Texture2D绘制到屏幕上?当调用spriteBatch.Draw时,RenderTarget不是后台缓冲区,并且我没有在此代码中绘制RenderTarget。不应该由于它被拖出屏幕而不显示texture2D?另外,为什么没有显示(只是黑色),除非我在结束spriteBatch之前清除屏幕?
好的,但为什么在我的倒数第二行中清除GraphicsDevice会导致屏幕从我的纹理绘制到黑色到红色? – GameKyuubi
这是关于你的代码的排序,你清理并填充屏幕之前,你结束了你的精灵批处理,这实际上是绘制精灵画面。 – XerShade
对,但在我的代码中,End()之前做的最后一件事是Clear(),但不知何故,我的Texture2D仍然可见。它会改变背景颜色,但不会删除Texture2D。 – GameKyuubi