Skip to main content
gamedev.net
🔒 Locked

Alpha Testing??

Started by thebbxx 1 reply 150+ views
Original Post
thebbxx
thebbxx
I am getting frustrated, all I want is to be able to specify one color in my texture to be transparent. I am using alpha testing, but I must be missing something here because it''s not working... Can someone please point me in the right direction? Thanks, Matt My image loading code:
  
D3DXCreateTextureFromFileEx( g_pd3dDevice, imageFileName,
		D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN,
		D3DPOOL_DEFAULT, D3DX_DEFAULT, 
        D3DX_DEFAULT, 0, NULL, NULL,
		&pTexture )
  
This is my rendering code:
  
        g_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE,     TRUE );
		g_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE,  TRUE );
		g_pd3dDevice->SetRenderState( D3DRS_ALPHAREF,         0x01 );
		g_pd3dDevice->SetRenderState( D3DRS_ALPHAFUNC,		  D3DCMP_GREATEREQUAL );

        g_pd3dDevice->SetTexture( 0, creatures.pTexture);
        g_pd3dDevice->SetStreamSource( 0, pVB, 0, sizeof(CUSTOMVERTEX) );
        g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
        g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 2);

	g_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE,  FALSE );

  
DrunkenHyena
DrunkenHyena
Do people read documentation anymore?

Directly from the docs:
quote:

ColorKey
[in] D3DCOLOR value to replace with transparent black, or 0 to disable the colorkey. This is always a 32-bit ARGB color, independent of the source image format. Alpha is significant and should usually be set to FF for opaque color keys. Thus, for opaque black, the value would be equal to 0xFF000000




Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.