Blting TGA with alpha channel to back buffer

Started by
1 comment, last by Scrotumulus 20 years, 6 months ago
I''m looking to create a heads-up-display overlay for an existing Direct3D 9 application. I''m looking to blt to the backbuffer after the scene has been rendered but before presentation to the front buffer, but am currently having problems wrt alpha channels in the loaded targa file. Firstly, i''m unsure whether to load the targa into a texture, and then grab a pointer to the top surface level, or just to load the file directly into a surface. The former method would be ideal, as this means that my cTexture class is a one-class-fits-all implementation that may be handled by the texture manager. However, employing StretchRect from the texture''s surface to the backbuffer fails... (?) The second method of loading the targa directly into a surface, then rendering works, but the alpha channel is ignored, and as far as I know the render states are setup correctly: display.GetDevice().SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); display.GetDevice().SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); display.GetDevice().SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); To conclude, firstly I want to know if it''s possible to load a texture and then blt the surface to backbuffer. Secondly I need to employ the alpha channel when performing this blt, and was wondering if any additional code is required. Unfortunately, this doesn''t seem to be a topic which is widely catered for in reference texts or on the internet.
Advertisement
quote:Original post by Scrotumulus
Unfortunately, this doesn't seem to be a topic which is widely catered for in reference texts or on the internet.



Are you kidding?
I wrote 5 (yes, seriously!) replies about exactly same kind of operations just last week!

Use the search function, with "alpha blending".

kind rgds, Nik

EDIT: It's not exactly possible to _blit_ the image directly using alpha factors, but you should render two triangles that cover the screen, and use the image as a texture in the process. And, you should set the alphablendenable and the src and dest factor renderstates (steps you have already taken, except for invsrcalpha in dest factor).


[edited by - Nik02 on October 5, 2003 11:37:26 AM]

Niko Suni

Cheers - I think i was just looking for the wrong things.

Anyone who reads this - I came to the conclusion that I should be using textured quads in screen space.

This topic is closed to new replies.

Advertisement