Re: [AD] compare ALLEGRO_COLOR with memcmp

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2011-06-06, at 8:36 PM, Evert Glebbeek wrote:
> Yes, and the exact same code (the same binary) should produce identical results when run on different computers. Except there are cases where it doesn't, which is amusing (or not).
> Again, I've only seen that happen in code that does very intense numerical calculations (this particular example was due to minor differences in the way results were rounded by the CPU, but these rounding errors will propagate in a code like that and cause a cosmetic difference in the output). We're not likely to run into that with this piece of code in Allegro, so changing it is perhaps a little bit paranoid. I don't think it would be bad to change it, but there is I reason I didn't do it myself before (and it's not that I didn't see the code).

Well I have a reason too. I think there may be more than 1 place it's done, but I'm speaking of al_convert_mask_to_alpha specifically. That's a slow function. Comparing individual floats including an epsilon will make it even slower. But here's the big reason why it doesn't need to be changed (in that instance): When you create bitmaps, in whatever paint program there is, you get values ranging from 0-255. When you call al_convert_mask_to_alpha(bitmap, al_map_rgb(255, 0, 255)), the value read from the bitmap and the mapped value will always be the same. You're not going to call al_convert_mask_to_alpha(bitmap, al_map_rgb_f(0.2345, 0.525912445, 0.7812409893)) (are you?) because you know the mask color from the paint program and it's giving you 0-255 ranged numbers. Just my 2cents.

Trent



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/