• Advertisement

Archived

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

Lookup-tables for colors?

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

The current method i use for creating a color dword for direct draw is something like this: ((red/dwShadesOfRed) << dwRedBitShift) | ((green/dwShadesOfGreen) << dwGreenBitShift) | ((blue/dwShadesOfBlue) << dwBlueBitShift)) Would it be a good idea to have three pregenerated tables like Color_R[255], Color_G[255], Color_B[255], each containing the bit representation of a color component of that value. And then create colors with: (Color_R[red] | Color_G[green] | Color_B[blue]) Wich would be faster? /CMN Edited by - cmn on 9/2/00 4:16:11 AM Edited by - CMN on 9/2/00 4:17:39 AM

Share this post


Link to post
Share on other sites
Advertisement
The lookup table would be faster since divisions are slow.

However, if dwShadesOfRed, dwShadesOfGreen, dwShadesOfBlue are powers of 2 (2,4,8,...) you can do the division using a shift and it might be faster than a lookup table.

Share this post


Link to post
Share on other sites
As Micheal Abrash said, knowing what to optimize is more important than knowing how to optimize. In this case, processors these days are fast enough to handle, *gasp* divisions. It''s really up to you what you end up doing.

JoeMont001@aol.com www.polarisoft.n3.net

Share this post


Link to post
Share on other sites

  • Advertisement