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 8162213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:39:33+00:00 2026-06-06T18:39:33+00:00

So I am trying to store the result from a render target into an

  • 0

So I am trying to store the result from a render target into an array of Colors so I can manipulate them individually with an iterator. For some reason, the below code sets every value in the array to R=0, G=0, B=0, A=0. As though it was never initialized. Is the GetData method used incorrectly? Is it something else? It should be a very colorful image, and definitely not transparent.

The issue is NOT that the textures are not drawing properly, I executed the code with no set render target (using the default backbuffer) and the game ran perfectly fine.

            //Creating a new render target and setting it
        RenderTarget2D unprocessed = new RenderTarget2D(graphics.GraphicsDevice, Window.ClientBounds.Width, Window.ClientBounds.Height,false,SurfaceFormat.Color,DepthFormat.Depth24,4,RenderTargetUsage.PreserveContents);
        graphics.GraphicsDevice.SetRenderTarget(unprocessed);

        //Drawing background and main player
        spriteBatch.Draw(bgTex,new Rectangle(0,0,Window.ClientBounds.Width,Window.ClientBounds.Height),Color.White);
        mainPlayer.Draw(spriteBatch);

        //resetting render target
        graphics.GraphicsDevice.SetRenderTarget(null);

        //creating array of Color to copy render to
        Color[] baseImage = new Color[Window.ClientBounds.Width * Window.ClientBounds.Height];
        //I pause the program here and baseImage is an array of black transparent colors
        unprocessed.GetData<Color>(baseImage);

        spriteBatch.End();
  • 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-06-06T18:39:34+00:00Added an answer on June 6, 2026 at 6:39 pm

    I believe there are a couple of problems. The first of which is that you need to call spriteBatch.End() prior to acessing the render target. I also just noticed there is no call to spriteBatch.Begin().

    RenderTarget2D unprocessed = new RenderTarget2D( /*...*/);
    graphics.GraphicsDevice.SetRenderTarget(unprocessed);
    graphics.GraphicsDevice.Clear(Color.Black);
    
    //Drawing
    spriteBatch.Begin();
    spriteBatch.Draw(/*...*/);
    spriteBatch.End();
    
    //Getting
    graphics.GraphicsDevice.SetRenderTarget(null);
    

    You just answered your own question so…. Nevermind then.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to select some data from db and store in an array. Suppose
Morning, im trying to store the results of any SProc call, from SQL Server2008,
I am trying to execute the following command, setting store=result, for the row where
I'm trying to store and retrieve numbers in android so later I can do
I'm trying to store an image into an SQL database without using temporary files.
I am trying to store the result of a sum in a variable to
I am trying to store sub-query result in session variable using MySQL, but the
Newbie here. I am trying to store the result of my search onto a
Im trying to get the result of an SQL statement and store it in
I'm trying to get some simple data into a JsonStore, but it doesn't seem

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.