Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

This is actually a follow up to this question How to capture the screen in DirectX 9 to a raw bitmap in memory without using D3DXSaveSurfaceToFile

The proponent of the best solution suggested that I should look at a shader program to capture the screen. How could I do that. I have no clue on how can I use a shader program to do that.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Shaders don't capture the screen in and of themselves. What's being suggested in the "shader based approach" is to:

1) Use render-to-texture or the like to render your entire scene to a single texture 2) Render that texture (with, say, a fullscreen quad) to your final output (or another texture if you want to chain effects or do multi-pass effects) using pixel and/or vertex shaders written in HLSL to apply your filtering effect instead of C++.

This has the advantage of keeping everything in GPU memory instead of spending your limited memory bandwidth copying everything from GPU to system memory (where C++ can work on it) and back (where it can be rendered.)

Methods of note for wrangling pixel shaders (commonly used for operations such as bluring, depth of field effects, tinting, you name it): D3DXCompileShaderFromFile, CreatePixelShader, SetPixelShader, SetPixelShaderConstantF

And for render targets: SetRenderTarget, BeginScene, and EndScene.

share|improve this answer
    
wonderful. That makes sense. I was quite confused. –  cloudraven Nov 28 '12 at 8:24

You cannot directly use a shader program to get the screen but you can copy the back buffer from the gpu to the cpu and then do what you want with it, be it save, etc.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.