Skip to main content
1 of 2
Joel
  • 1.5k
  • 1
  • 12
  • 28

Reusing a render target to create multiple Texture2D's (XNA)

i want to be able to loop through a hole bunch of textures, and render them on an object. I then want the rendered image to be placed onto a texture2D.

The point? well hopefully i will end up with an array of Texture2D's containing a model with multiple skins.

Here's my code:

        for (byte i = 1; i < allBlockIso.Count(); i++)
        {
            DisplayBox.SetValue(i);
            GraphicsDevice.SetRenderTarget(cubeTarget);
            GraphicsDevice.Clear(Color.Transparent);
            DrawIsoCube();
            GraphicsDevice.SetRenderTarget(null);
            allBlockIso[i] = (Texture2D)cubeTarget;
        }

Pretty simple yet it's not working. It appears that whatever the last image being rendered is, is shown in every image of the allBlockIso array.

Anyone know a fix? Cheers.

P.S. sorry if this wan't explained well. I'm not very good at explaining :P

Joel
  • 1.5k
  • 1
  • 12
  • 28