Archived

This topic is now archived and is closed to further replies.

darkawakenings

Transparent Blitting Questions

Recommended Posts

Ok, according to the book this should work, and yet it doesn''t. I was just wondering if I was missing any obvious steps. My goal is to have a texture mapped to a polygon, and have a transparent hole through the middle of the texture. I am using DirectX 8 D3D.Currently, these are the function calls relating to this goal. These are my render states setup: pD3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); pD3DDevice->SetRenderState(D3DRS_ALPHAREF, 0x08); pD3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); Here is my load texture func: if(FAILED(D3DXCreateTextureFromFileEx(pD3DDevice, "GRASS2.bmp",D3DX_DEFAULT,D3DX_DEFAULT,D3DX_DEFAULT,0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_TRIANGLE, D3DX_FILTER_TRIANGLE, D3DCOLOR_ARGB(255,0,0,0),NULL,NULL, &pD3DT))) then i just draw my polygons with the textures on them. The book says that any black i had in the texture should be transparent, yet it isnt. I have a big black circle, and its still there! ARG!

Share this post


Link to post
Share on other sites
You need to tell DX where the alpha is coming from... and you need a black hole in your bitmap.

pDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
pDev->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

And yeah, color should be 255,0,0,0 (to replace black). Setting to 0 as funky suggested means don''t color key.

Share this post


Link to post
Share on other sites