Skip to main content
gamedev.net
🔒 Locked

Locking Rendertarget...

Started by devronious 4 replies 2.1k views
Original Post
devronious
devronious
I have a rendertarget and I want to convert it to a Bitmap. I can't seem to lock the buffer for it. Is there a way around this? What is the best way to approach something like this? Thanks in Advance, Devin
Demirug
Demirug
IDirect3DDevice9::GetRenderTargetData is your friend. Use it to copy the render target content to a system memory surface. Then you can do whatever you want.
devronious
devronious
Cool, that's what I was looking for!

Thanks Much,

-Devin
devronious
devronious
Oops. I'm getting some sort of Invalid Call Exception was Unhandled exception

[source lang = "c#"]                this.initializer.Device.GetRenderTargetData(this.renderTarget.GetSurfaceLevel(0), tex.GetSurfaceLevel(0));


Any ideas why?
circlesoft
circlesoft
From the docs:

Quote:

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.

The source surface must be a regular render target or a level of a render-target texture (mipmap or cube texture) created with POOL_DEFAULT.

This method will fail if:

The render target is multisampled.
The source render target is a different size than the destination surface.
The source render target and destination surface formats do not match.


Check the debug runtime output.
devronious
devronious
I figured out that I had to set the Pool to SystemMemory. Duh on my part :(

Thanks,

Devin

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.