Skip to main content
gamedev.net
🔒 Locked

[DX9] RenderTarget issues

Started by Seabolt 3 replies 1.3k views
Original Post
Seabolt
Seabolt
Hey guys,

This one has been holding me up for awhile, so I finally buckled.

I create my render target as such:




outData->mRenderTexture = TCDirectX9Textures::CreateTextureDX9( bufferWidth, bufferHeight, format );

HRESULT result = outData->mRenderTexture->GetSurfaceLevel( 0, &outData->mRenderSurface );
assert( "Failed to get surface level" && SUCCEEDED( result ) );

result = gDeviceManager->GetDevice()->CreateRenderTarget( bufferWidth, bufferHeight,
(D3DFORMAT)format,
D3DMULTISAMPLE_NONE,
0, TRUE,
&outData->mRenderSurface,
NULL );
assert( "Failed to create render target" && SUCCEEDED( result ) );




This seems to create a render target fine.
I do your standard draw scene, bind backbuffer, draw fullscreen quad test code, but I get a black screen.
In PIX I see the render fine for the first render target, but when I bind my backbuffer, mRenderTexture is pure black. I was under the impression that when I created the Surface from the Texture, the texture would have the data from the surface, but that doesn't seem to be the case. Is there something I need to do in order to get the data from the surface back to the texture?

Thanks guys.
Perception is when one imagination clashes with another
MJP
MJP
Calling CreateRenderTarget will completely replace your surface pointer with a new surface. What you want to do instead is call CreateTexture, and pass D3DUSAGE_RENDERTARGET (also don't forget to create it in D3DPOOL_DEFAULT). Then call GetSurfaceLevel to get your surface pointer that you'll pass to SetRenderTarget. The only time you'll need to call CreateRenderTarget is if you want to use MSAA.
L. Spiro
L. Spiro
Also make sure the texture is not bound as both a write-to render target and a read-from texture.


L. Spiro
I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid
Seabolt
Seabolt
MJP, you've done it again. Thanks a lot, something so simple.

Yogurt, thanks for the input! Luckily I didn't make that mistake, (this time!)
Perception is when one imagination clashes with another
MJP
MJP
Always make sure you have the debug runtimes enabled, since it will warn you about the read/write case.

Topic Locked

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

Sign in to reply to this topic.