Jump to content
  • Advertisement
Sign in to follow this  

Textures and multiple colour palettes

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

I've been thinking about textures that have multiple colour palettes, I haven't quite got to them but now that they are on the tip of my tongue I might as well ask. With D3DCreateTextureFromFileEx you can specify a colour palette, now that's great and all but down the road I plan on making a small war RTS. What does this mean to me? Does this mean I'm going to have to load up several of the same texture with different colours palettes, or is there some other way I can avoid this? (First thing that comes to mind is pixel shaders but I haven't gotten there yet ...) Thanks.

Share this post

Link to post
Share on other sites
Those arguments allow to store a loaded palette from a P8 image. You must give it null or a pointer to 256 COLORENTRYs (or some name like that...). D3DX will fill in the palette data from the file.

You can then use SetPaletteEntries to set this up as a palette on your device. D3D allows upto something like 16000 palettes to be programmed at once. If your device support it the flags field will actually be alpha. (TEXTURECAPS_ALPHAPALETTE).

You can then use SetCurrentTexturePalette to activate one of your 16000 palettes.

Things to note about palettes:

The palette you specify applies to ALL texture stages, meaning you cannot use multitexturing with two textures with different palettes. (trivia: This does not apply to certain non-PC, but Windows and DirectX based systems).

A GeForce3 in a DX8 app does have P8 support (but not L8 or A8L8).

A GeForce3 in a DX9 app does NOT have P8 support (but has L8 and A8L8).

Other cards my similarly phase out P8.

On GeForce3Ti200s and regular GeForce3s (possibly all cards. Not sure if it was an nVidia or DirectX bug) I noticed that modifying the palette quickly caused a reboot. Inserting Sleep() calls to allow D3D to finish drawing before changing palettes fixed the issue. This meant palettes were nearly useless.

In the end I determined palettes in D3D, if supported, can be used as either an A8 or L8 texture. You set the palette once at device creation / reset and never again. This avoids the reboots. Other fixed palette uses can be used.

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!