Transparent Blitting Questions

Started by
2 comments, last by darkawakenings 20 years, 8 months ago
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!
Advertisement
Not positive ( i uninstalled the sdk so i could watch jay and silent bob ) but i think the use of D3DCOLOR_ARGB(255,0,0,0) should be D3DCOLOR_ARGB(0, 0, 0, 0). A value of 255 means full alpha, or opaque.
Nope, that does nothing. I believe that it needs to be set to 255 there though, because I am reading from a bitmap and that is its maximum value. Thanks for responding though


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.

This topic is closed to new replies.

Advertisement