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

  • Home
  • SEARCH
  • 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 9010899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:35:07+00:00 2026-06-16T02:35:07+00:00

I have a windows platform game coded in C# XNA 4.0 using the Reach

  • 0

I have a windows platform game coded in C# XNA 4.0 using the Reach graphics settings. My project is based on the GameStateManagement sample but I later added Bloom and spriteSheet/spriteBatch functionality to it.

I desire to have a screenshot saved of the final screen output. However, when I save my screenshot it only shows the render before Bloom was applied and before my HUD text is displayed (which I draw after the Bloom). I have my screenshot saved at the end of my Draw method, after these two processes.

I have tried all kinds of things. Andrew’s answer here Take screen shot in XNA was helpful and does save out an image; however, it is not saving out the final render.

I have a feeling it has something to do with the bloom process or maybe the spritebatch.

Here is my code:

    example {
    public override void Draw(GameTime gameTime)
    {
        ScreenManager.GraphicsDevice.SetRenderTarget(sceneRenderTarget);
        // Clear the screen to black
        ScreenManager.GraphicsDevice.Clear(ClearOptions.Target,
                                           Color.Black, 0, 0);
        SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
        spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);

    // then i draw all my game stuff

        spriteBatch.End();

        #region Post-Processing & Bloom
        ScreenManager.GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;

        // Pass 1: draw the scene into rendertarget 1, using a
        // shader that extracts only the brightest parts of the image.
        bloomExtractEffect.Parameters["BloomThreshold"].SetValue(
            Settings.BloomThreshold);

        DrawFullscreenQuad(sceneRenderTarget, renderTarget1,
                           bloomExtractEffect,
                           IntermediateBuffer.PreBloom);

        // Pass 2: draw from rendertarget 1 into rendertarget 2,
        // using a shader to apply a horizontal gaussian blur filter.
        SetBlurEffectParameters(1.0f / (float)renderTarget1.Width, 0);

        DrawFullscreenQuad(renderTarget1, renderTarget2,
                           gaussianBlurEffect,
                           IntermediateBuffer.BlurredHorizontally);

        // Pass 3: draw from rendertarget 2 back into rendertarget 1,
        // using a shader to apply a vertical gaussian blur filter.
        SetBlurEffectParameters(0, 1.0f / (float)renderTarget1.Height);

        DrawFullscreenQuad(renderTarget2, renderTarget1,
                           gaussianBlurEffect,
                           IntermediateBuffer.BlurredBothWays);

        // Pass 4: draw both rendertarget 1 and the original scene
        // image back into the main backbuffer, using a shader that
        // combines them to produce the final bloomed result.
        ScreenManager.GraphicsDevice.SetRenderTarget(null);

        EffectParameterCollection parameters = bloomCombineEffect.Parameters;

        parameters["BloomIntensity"].SetValue(Settings.BloomIntensity);
        parameters["BaseIntensity"].SetValue(Settings.BaseIntensity);
        parameters["BloomSaturation"].SetValue(Settings.BloomSaturation);
        parameters["BaseSaturation"].SetValue(Settings.BaseSaturation);

        ScreenManager.GraphicsDevice.Textures[1] = sceneRenderTarget;

        Viewport viewport = ScreenManager.GraphicsDevice.Viewport;

        DrawFullscreenQuad(renderTarget1,
                           viewport.Width, viewport.Height,
                           bloomCombineEffect,
                           IntermediateBuffer.FinalResult);

        #endregion

        spriteBatch.Begin();
        // Draw HUD
        spriteBatch.End();


        if (screenShotTake)
        {
            using (FileStream fs = File.Open(@"screenshot" + (screenshotNumber) + @".png", FileMode.OpenOrCreate))
            {
                // Right here I try to save out the screen shot Texture2D
                sceneRenderTarget.SaveAsPng(fs, (int)viewportSize.X, (int)viewportSize.Y); // save render target to disk
            }
        }
    }




    #region PostProcess & Bloom
    void DrawFullscreenQuad(Texture2D texture, RenderTarget2D renderTarget,
                            Effect effect, IntermediateBuffer currentBuffer)
    {
        ScreenManager.GraphicsDevice.SetRenderTarget(renderTarget);

        DrawFullscreenQuad(texture,
                           renderTarget.Width, renderTarget.Height,
                           effect, currentBuffer);


    }

    void DrawFullscreenQuad(Texture2D texture, int width, int height,
                            Effect effect, IntermediateBuffer currentBuffer)
    {
        if (showBuffer < currentBuffer)
        {
            effect = null;
        }

        spriteBatch.Begin(0, BlendState.Opaque, null, null, null, effect);
        spriteBatch.Draw(texture, new Rectangle(0, 0, width, height), Color.White);
        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-16T02:35:08+00:00Added an answer on June 16, 2026 at 2:35 am

    The problem is here:

    ScreenManager.GraphicsDevice.SetRenderTarget(null);
    

    Because of this line, you draw the effects to the back buffer, but the render target you’re saving is left alone. You see the results of the effects because it’s drawn directly, but what you save is not what you’ve drawn to the back buffer. To fix this, draw the effects to another RenderTarget, and then draw that as a single texture to the back buffer. Obviously this is another draw call to process, but it’s a minimal cost. By doing that, you can then grab the texture from the new RenderTarget and save it however you like.

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

Sidebar

Related Questions

I have installed Qt for windows CE using this link http://qt.nokia.com/products/platform/qt-for-windows-ce for visual studio8,
i have installed lxml2.2.2 on windows platform(i m using python version 2.6.5).i tried this
I have written a server based on boost::asio in windows platform. I want to
Utility: NMake Platform : Windows 7 I have the following Makefile FILE = $(shell)
I have created a Windows CE6 Image through Platform Builder, and I now want
I am developing a simple platform game using Java using BlueJ as the IDE.
I have my application on Windows platform and want a java function to be
I am just starting out with git on the Windows platform. I have mysygit
I have created a simple XNA Windows Class Library with XNA 4.0 called NivekGameEngine.
What would be a good tool/IDE/app to build a GUI? Platform: preferably Windows, but

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.