Jump to content
  • Advertisement
Sign in to follow this  
fluke

SetPalette in DirectX9?

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

what is the dx9 equivilent method (aka. work-around) of ddraws CreatePalette and SetPalette? eg.
ddraw->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256,pe,&lpddpal,NULL);
lpddsurface->SetPalette(lpddpal);
i noticed the IDirect3D9 and IDirect3DSurface9 interfaces don't have any direct palette support, so i guess i'm looking for a more indirect/diy approach. thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by fluke
what is the dx9 equivilent method (aka. work-around) of ddraws CreatePalette and SetPalette?

eg.

ddraw->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256,pe,&lpddpal,NULL);
lpddsurface->SetPalette(lpddpal);


i noticed the IDirect3D9 and IDirect3DSurface9 interfaces don't have any direct palette support, so i guess i'm looking for a more indirect/diy approach.

thanks in advance.


Take a look at the IDirect3DDevice9::SetPaletteEntries method. Palettes in D3D9 are shared and managed on the device as that is closer to how the underlying hardware functions.

Paul

Share this post


Link to post
Share on other sites
Note that many recent hardware do not support paletted surfaces nor textures at all.

Share this post


Link to post
Share on other sites
Most cards these days disable D3DFMT_P8 in the driver. For example a GeForce3 using DX8 supports P8, while using DX9 (same driver) P8 is gone, but L8 and A8L8 appear.

If you find a card that still supports palettes, here's how to use them:

IDirect3DDevice9::SetPaletteEntries() sets 256 colors for one of 16384 palettes.
IDirect3DDevice9::SetCurrentTexturePalette() sets which palette is in use.

All texture stages share the same palette, so multi-texturing with various textures of different palettes will not work.

In my experience some cards (or drivers) cause a reboot when setting the palette often. On both my work and home machines attempting to use palette will reboot. Putting a Sleep(10) before drawing removed the reboots. In the end I just used palettes for allowing greyscale and alpha textures on cards without L8 or A8 support, setting the palette once at device creation/reset time, and never again.

Share this post


Link to post
Share on other sites
thanks for the replies. one last question:

maybe i'm reading too much into the name with SetCurrentTexturePalette, but wouldn't i want something like SetCurrentSurfacePalette if i'm locking the surface, making updates, unlocking and then copying the surface to a texture with GetSurfaceLevel/UpdateSurface/etc.

a demo on this would be grand, but i think palettes are becoming antiquated...

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!