• Advertisement
Sign in to follow this  

Transparent background for render targets

This topic is 1657 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone,
 
I'm a beginner on directx 9 programming and I have a problem regarding render targets where I wanted to set the backgound to be transparent (transparent to the backbufffer). I used the Clear method and used D3DCOLOR_ARGB where I set the Alpha value to 0. I also have my render target to have a A8R8G8B8 format but the clear ignores the transparency. And when I take the Clear code away, the background messes up with some lines on it. Here is my code:

3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 1.0f, 0  );

Here is how I set up my render target:

pd3dDevice->CreateTexture( 400, 400, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pTextureTarget, 0);
m_pTextureTarget->GetSurfaceLevel( 0, &m_pSurfaceTarget );

3dDevice->SetRenderTarget( 0, m_pSurfaceTarget );

    
3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 1.0f, 0  );

I'm just not sure if I'm missing something. Hopefully, you guys could help out. If you need more info please just ask.

Edited by Daenyx

Share this post


Link to post
Share on other sites
Advertisement

That code should be binding your render target and clearing it fine. I assume the next step is that you draw some things into the render target (with alpha values greater than 0), and then you somehow composite this render-target over the top of the back-buffer.

What does that compositing step look like?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement