Archived

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

Colour Key in DX8 - D3D

This topic is 5849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites