Sign in to follow this  
stona

CreateTexture(...) and SetRenderTarget(...) fails

Recommended Posts

unfortunately i'm having following problem. i created a texture that is supposed to be used as an render target: ... IDirect3DTexture9* pT; ... pDevice->CreateTexture(WIDTH, HEIGHT, 0, D3DUSAGE_RENDERTARGET, D3DFMT_G16R16, D3DPOOL_DEFAULT, &pT, NULL); ... but i can't use pDevice->SetRenderTarget() to set the create texture from above as a render target, see the parameters of SetRenderTarget(): HRESULT SetRenderTarget( DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget ); does anybody know a solution to this problem? i've looked on the web quite a bit.. maybe i'm just adressing the problem from the wrong way.. thank you.. if anybody wonders, why i just don't create a surface, there's a reason to it: the output stored in the render target will be input to the render pipeline again and i can only pass textures to the render pipeline and no surfaces, right?

Share this post


Link to post
Share on other sites
You need to grab the top-level surface (I'd also recommend you set the 3rd parameter of CreateTexture to be "1" so you don't generate a mip-chain)...

// Make a backup of the previous RT
LPDIRECT3DTEXTURE9 pPrevRT = NULL;
pDevice->GetRenderTarget( 0, &pPrevRT );

// Acquire the top-level surface
LPDIRECT3DTEXTURE9 pTempSurf = NULL;
pTexture->GetSurfaceLevel( 0, &pTempSurf );
pDevice->SetRenderTarget( 0, pTempSurf );

// do some rendering magic here

// Restore the previous RT
pDevice->SetRenderTarget( 0, pPrevRT );

// Clean up
SAFE_RELEASE( pPrevRT );
SAFE_RELEASE( pTempSurf );

// Now use your original texture as an input:
pEffect->SetTexture( "texShaderInput", pTexture );


hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
You need to grab the top-level surface (I'd also recommend you set the 3rd parameter of CreateTexture to be "1" so you don't generate a mip-chain)...

*** Source Snippet Removed ***

hth
Jack


jack,

thanks A LOT! that SOLVED one of my problems.. but i already have another one posted.. that i am stuck with for quite a bit now..

http://www.gamedev.net/community/forums/topic.asp?topic_id=381359

christian

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