• ### Announcements

#### Archived

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

# D3DUtil_SetColorKey....

## Recommended Posts

Harvester    122
Greets. I use the SetColorKey, to access and set to alpha = 0 all the transparent to be pixels. However, when it performs the check, it never seems to succeed it. It never finds any pixel that is supposed to be transparent. Here''s what happens: I use a color key 0x00FF0000 the image does containt this color (exact value). when SetColorKey function scans through it, with A1R5G5B5 format, it sees that all the pixels whose color was supposed to be red, are 0xecc9. I''ve also tried black color, and the results where alike! Any ideas? p.s. After all alpha values are set, what are the states to be set, in order for the alpha effect to take place? I''ve used the following. Let me know if something is wrong, or missing.
  g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); g_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE ); g_pd3dDevice->SetRenderState( D3DRS_ALPHAREF, 0x01 ); g_pd3dDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL ); 
... LEMMINGS ... LEMMINGS ... LEMMINGS ... LEM..... SpLaSh!... Is it what we look like on the eyes of destiny or God? Are we LeMmIngS or WhAt!?

##### Share on other sites
SikCiv    122
Im not exactly sure what the problem is, though make sure your 3D card can do colorkeying in the first place. If you need something to test the card you can download my small D3D-2D wrapper (includes the source if you need it), follow the link below and click on the ''D3DX Sprite Wrapper'' picture.

##### Share on other sites
KalvinB    102
intialize your 3D offscreen surface like so:
lpDevice->SetRenderState( D3DRENDERSTATE_COLORKEYENABLE, TRUE );