Jump to content
  • Advertisement
Sign in to follow this  
Sync Views

Direct3D colour key

This topic is 3886 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

How can I set the colour key to be always the bottom left pixel of the image? Is there away to find out what the bottom left pixel is before loading the image or setting the colour key after loading rather than on load?
IDirect3DTexture9 *load_texture(char *path)
{
  IDirect3DTexture9 *texture;
  D3DXIMAGE_INFO scr_info;

  //Use a magenta colourkey
  D3DCOLOR colourkey = 0xFFFF00FF;

  // Load image from file
  if (FAILED(D3DXCreateTextureFromFileEx (d3d_device, path, 0, 0, 1, 0, 
        D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_DEFAULT, 
        colourkey, &scr_info, NULL, &texture)))
	    return NULL;

  //Return the newly made texture
  return texture;
}

Share this post


Link to post
Share on other sites
Advertisement
0) Pretty much everyone handles this by just picking a standard colour-key colour.
1) Why bottom-left?
2) It depends on the file format and how much of the work you intend to do yourself. I don't think you can "re-key" an already-loaded image, but I haven't actually worked with DirectX directly, so I don't really know.
3) Returning NULL for a failed texture load might not be such a good idea. You might want instead to return a pointer to some shared, easily recognizable "dummy" texture (or perhaps, a recognizable one while debugging, and a fully transparent one for release). This avoids lots of debugging hell when you forget to check for NULL return values, and lots of extra work when you remember. ;) See also.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!