• Advertisement
Sign in to follow this  

Read the bytes from a frame of the render window

This topic is 2932 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
No I'm not asking this. I need to put all the information the window would have displayed into a byte array. That's what I'm 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
Not an expert on this, but you can render to a texture. if you are using DirectX you can find a tutorial here: http://www.codesampler.com/dx9src/dx9src_7.htm#dx9_offscreen_rendering

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
Sign in to follow this  

  • Advertisement