Transparent Surface ?

Started by
0 comments, last by MJP 15 years, 3 months ago
Ok, I am trying to just draw 2 surfaces with transparency. (Without using SDL) I know how to draw the same thing with textures and quads and all that. But, I just want to know if what I am trying should work, and maybe I am missing some setup steps. 1) I set the back buffer to use A8R8G8B8 2) Then I do CreateOffscreenPlainSurface 3) Next, to load the image I use D3DXLoadSurfaceFromFile and pass the key for transparency. 4) I use UpdateSurface with the offscreen surface and the back buffer. Result: I get the image on the screen, and the image's transparent color is filled with black. (That's semi good news since it's supposed to be filled with transparent black.) But, why isn't it transparent? Init Code:

d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
...
g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, true);
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, true);
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);    

Thanks in advance!
Advertisement
IDirect3DDevice9::UpdateSurface won't use hardware alpha-blending, since it'll just do a straight copy of the source data to the destination surface. If you want blending you'll have to actually render primitives and use textures.

This topic is closed to new replies.

Advertisement