Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6222275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:17:13+00:00 2026-05-24T08:17:13+00:00

I am writing an application in XNA that relies on render targets that are

  • 0

I am writing an application in XNA that relies on render targets that are rendered to just once, and then used indefinitely afterwards. The problem I’ve encountered is that there are certain situations where the render targets’ contents are lost or disposed, such when the computer goes to sleep or the application enters full-screen mode.

Re-rendering to each target when content is lost is an option, but likely not the best option, as it could be fairly costly when there are many targets.

I could probably save each result as a PNG image and then load that PNG back up as a texture, but that adds a lot of I/O overhead.

Suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:17:14+00:00Added an answer on May 24, 2026 at 8:17 am

    Most likely option I’ve found so far is to use GetData() and SetData() to copy from the RenderTarget2D to a new Texture2D.

    Since I want a mip mapped texture, I found that I had to copy each mip level individually to the new texture, like so. If you don’t do this, the object will turn black as you move away from it since there’s no data in the mip maps. Note that the render target must also be mip mapped.

    Texture2D copy = new Texture2D(graphicsDevice,
        renderTarget.Width, renderTarget.Height, true,
        renderTarget.Format);
    
    // Set data for each mip map level
    for (int i = 0; i < renderTarget.LevelCount; i++)
    {
        // calculate the dimensions of the mip level.
        // Math.Max because dimensions always non-zero
        int width = (int)Math.Max((renderTarget.Width / Math.Pow(2, i)), 1);
        int height = (int)Math.Max((renderTarget.Height / Math.Pow(2, i)), 1);
    
        Color[] data = new Color[width * height];
    
        renderTarget.GetData<Color>(i, null, data, 0, data.Length);
        copy.SetData<Color>(i, null, data, 0, data.Length);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im writing an application that supposed to send coordinates in an SMS, but I've
I am writing an application that allows a user to place images on a
I am writing an application that will allow an android phone and java application
I am very new to XNA framework. I am writing a sample application in
I am writing application that will add usercontrol when user clicks on client area
Writing an application in Cocoa that will take input from the user, format it
Im writing a application that reads logs from 1-many computers in the network. The
Problem Description I am writing application for Android and use native code, And test
im writing an application using Visual Studio 2010 Express Edition. I have a problem
I writing an application that draws in openGL es 1.0 in the Android NDK

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.