Sign in to follow this  
Rookboom

SlimDX: How do you read pixels from the render target?

Recommended Posts

Rookboom    100
Hi, I am trying to copy the render target to a local texture so I can read a pixel from it. How would I do this. I have tried using CopyResource without any luck. After copying the rendertarget to a local staging texture, I am not able to read the pixels. All bytes are 0 even though I cleared the render target to white. I am using F#: //-------------------- deviceContext.CopyResource(mainRenderTargetView.Resource, localTexture) let pixelData = deviceContext.MapSubresource( localTexture, 0, width*height*sizeof<int32>, //Correct? MapMode.Read, SlimDX.Direct3D11.MapFlags.None) let marshalPixels index = Marshal.ReadInt32(pixelData.Data.DataPointer, index*4) let pixels = Array.init (width*height) marshalPixels //-------------------- Any ideas? Thanks Johan [Edited by - Rookboom on April 4, 2010 9:20:57 AM]

Share this post


Link to post
Share on other sites
Rookboom    100
Why F#? I started using simply out of curiosity. I love learning new languages. Now that I have been using it for about 4 months, I am hooked. I never want to go back to anything else. It has the terseness of dynamic languages like python or ruby, but it is type safe and has the same performance as C#. Being a functional language it also allows you to solve many problems in far fewer lines of code than you would use in an imperative language. And of course it is the only functional language that allows you to leverage the .NET framework. There is a lot to like about F#.

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