Colour Key in DX8 - D3D

Started by
1 comment, last by GodsEvening 22 years, 4 months ago
Hi all, I tryed to create a 2D game using DX8 and D3D, but i have some problem about colour key. since i had been created two planes, one put in the back as a background. Another one used to create sprite animation. but something is happened, when i rander this two palnes. i''am using following code to load texture.
  
  void Texture::LoadTexture(char* filename)
{
     // Set black as our source color key. Use 0xFFFF00FF for magenta instead.

     // Use 0x00000000 for no ''color key'' substitution

     D3DCOLOR colorkey = 0xFF000000;
     // The D3DX function will fill in the following image info for us 

     D3DXIMAGE_INFO SrcInfo; // Optional 


     // Load image from file - maintain size of original file.

     // It is also possible to specify a new height/width and ask D3DX to      filter

     // the image to the new size (stretch/shrink). See SDK docs for details.

     D3DXCreateTextureFromFileEx( MyD3D.m_pd3dDevice, filename, 0, 0, 1, 0, 
          D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_DEFAULT, 
          colorkey, &SrcInfo , NULL, &pTexture);
}
   
screen : please help thx
Advertisement
Try changing the D3DTSS_MAGFILTER TextureStageState to D3DTEXF_NONE.

Also use alpha test to sharpen the transparent edges.


The video adapter is filtering the transparent alpha into the opaque alpha when the texture is stretched (magnified).

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Thanks S1CA,
One more question: how to set the background of the plane (the bottom one) to transparent (i.e. can see the texture of the larger image) ?

This topic is closed to new replies.

Advertisement