Lookup-tables for colors?
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
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.
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.
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
JoeMont001@aol.com www.polarisoft.n3.net
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement