我有以下声明:
ResolveTexture2D rightTex;
我把它用在
Draw
方法如下:
GraphicsDevice.ResolveBackBuffer(rightTex);
现在,我用
SpriteBatch
:
spriteBatch.Draw(rightTex, new Rectangle(0, 0, 800, 600), Color.Cyan);
这在XNA 3.1中非常有效。但是,现在我要转换到XNA 4,
ResolveTexture2D
以及
ResolveBackBuffer
方法已被删除。为了在XNA 4.0中工作,我如何重新编码?
编辑
所以,这里还有一些代码可以帮助您。在这里,我初始化renderTargets:
PresentationParameters pp = GraphicsDevice.PresentationParameters;
leftTex = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, true, pp.BackBufferFormat, pp.DepthStencilFormat);
rightTex = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, true, pp.BackBufferFormat, pp.DepthStencilFormat);
然后,在我的
画
方法:
GraphicsDevice.Clear(Color.Gray);
rightCam.render(model, Matrix.CreateScale(0.1f), modelAbsTrans);
GraphicsDevice.SetRenderTarget(rightTex);
GraphicsDevice.SetRenderTarget(null);
GraphicsDevice.Clear(Color.Gray);
leftCam.render(model, Matrix.CreateScale(0.1f), modelAbsTrans);
GraphicsDevice.SetRenderTarget(leftTex);
GraphicsDevice.SetRenderTarget(null);
GraphicsDevice.Clear(Color.Black);
//start the SpriteBatch with Additive Blend Mode
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive);
spriteBatch.Draw(rightTex, new Rectangle(0, 0, 800, 600), Color.Cyan);
spriteBatch.Draw(leftTex, new Rectangle(0, 0, 800, 600), Color.Red);
spriteBatch.End();