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

Started by
1 comment, last by stona 18 years, 1 month ago
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?
Advertisement
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 RTLPDIRECT3DTEXTURE9 pPrevRT = NULL;pDevice->GetRenderTarget( 0, &pPrevRT );// Acquire the top-level surfaceLPDIRECT3DTEXTURE9 pTempSurf = NULL;pTexture->GetSurfaceLevel( 0, &pTempSurf );pDevice->SetRenderTarget( 0, pTempSurf );// do some rendering magic here// Restore the previous RTpDevice->SetRenderTarget( 0, pPrevRT );// Clean upSAFE_RELEASE( pPrevRT );SAFE_RELEASE( pTempSurf );// Now use your original texture as an input:pEffect->SetTexture( "texShaderInput", pTexture );


hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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

This topic is closed to new replies.

Advertisement