je la déclaration suivante:ResolveTexture2D - Le cauchemar XNA 4
ResolveTexture2D rightTex;
Et je l'utilise dans la méthode Draw
comme ceci:
GraphicsDevice.ResolveBackBuffer(rightTex);
Maintenant, je dessine ensuite à l'aide du SpriteBatch
:
spriteBatch.Draw(rightTex, new Rectangle(0, 0, 800, 600), Color.Cyan);
Cela fonctionne fantastique dans XNA 3.1. Mais, maintenant je suis en train de convertir en XNA 4, ResolveTexture2D
et la méthode ResolveBackBuffer
ont été supprimés. Comment est-ce que je re-code cela pour travailler dans XNA 4.0?
EDIT
Donc, voici un peu plus de code pour aider peut-être. Ici, j'Initialise le 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);
Ensuite, dans ma méthode Draw
je:
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();
Parfait! Juste pour régler un problème de transparence, mais génial: D –