Sign in to follow this  
muku

Read the bytes from a frame of the render window

Recommended Posts

Hi, What I want to achieve is get all the pixel data of my rendering window without necessarily showing the window. I use a volume texture mapped onto multiple quads and with the use of alpha blending I display volumetric data. In some occasions I use just a single quad with a slice of the volume texture mapped onto it with no blending. Some of my work is done in shaders. Anyway, I need to get all the data of a frame displayed in the rendering window. Think of it as reading all the bytes from a still image. My ultimate goal is to pass this data (bytes) into a medical imaging viewer to use the image editing tools of the viewer. I could do all these operations on the CPU without using directX but it's slow and so I've done much of my work on the GPU side and ultimately I need this calculated image to be displayed via the viewer. It must be possible, isn't it? I use direct3D 9.

Share this post


Link to post
Share on other sites
Quote:
without necessarily showing the window

If this is your concern, when you create the window, don't call ShowWindow. Also, in your rendering loop, no need to call Present().

Is that what you're asking?

Share this post


Link to post
Share on other sites
Search the documentation for a function called GetRenderTargetData, you probably want to use that to copy the render target data to a surface you have created in D3DPOOL_SYSTEMMEM, then you can Lock that surface to get the actual bytes.

Share this post


Link to post
Share on other sites
Thanks for the replies guys you were both helpful. I had read about rendering to texture but I wanted to know about the most optimized way to do what I try to do. I assume Hinch's method is better and I'm going to look at it.

Is there any particular reason to prefer the System Memory than the Default pool Hinch?

Share this post


Link to post
Share on other sites
Yes, default pool for textures normally means in GPU memory, so you wouldn't be able to access the bytes directly :) The docs for GetRenderTargetData state specifically "The destination surface must be either an off-screen plain surface or a level of a texture (mipmap or cube texture) created with D3DPOOL_SYSTEMMEM".

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this