I am stuck on a problem -- I am wondering if anyone has run into this before. I am getting an unexpected mipmapping result when baking sprites into a single texture using RenderTarget2D. At a high level here is what I do:
1) Create a render target and select it.
2) Render N texture rectangles to the backbuffer.
3) Restore the previous render target.
4) Call render target GetTexture() to save texture. When I complete step four I open up the texture and I can see that mip maps are not generated. What am I doing wrong here?
Here is what the code looks like:
RenderTarget2D renderTarget = new RenderTarget2D(device, width, height, 0, SurfaceFormat.Color, RenderTargetUsage.DiscardContents);
RenderTarget2D defaultTarget = device.GetRenderTarget(0);
device.SetRenderTarget(0, renderTarget);
device.Clear(ClearOptions.Target, Color.Transparent, 0, 0);
// perform rendering to back buffer
...
device.SetRenderTarget(0, (RenderTarget2D)defaultTarget);
renderTarget.GetTexture().GenerateMipMaps(); // doesn't do anything.
renderTarget.GetTexture().Save@("C:\foo.dds", ImageFileFormat.Dds); // this produces the attached image
renderTarget.Dispose();