Re: [AD] getpixel conflict with alpha blended sprites

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


Chris Jones wrote:
[snip]
Perhaps another function could be added,
"set_getpixel_use_alpha_channel(bool)" or something, so that it wouldn't
break existing programs but if the user wanted to, they could ask it to mask
out the alpha channel?

Ugg. Not another state please! That's all that more to keep track of.


Yes, the bounds check can be done with the bitmap struct members - the
problem then becomes either:
(1) you call getpixel anyway, but then the bounds checking code is done
twice

Likely getpixel() is applied in a for loop(), which has bounds checking built-in. If not, then yes, the checks will be done twice. But then, would you care? (see below)


(2) you use a switch statement to find out which _getpixel function to use
depending on the bitmap color depth

Or a function pointer.



in performance critical code, neither of these are ideal solutions, so
perhaps a new vtable entry for a "_getpixel" function for the bitmap which
would just return the pixel without bounds checking could be added?

Performence critical code should not rely on get_pixel (all versions) and put_pixel (all versions) to have any form of decent speed. get/put_pixel() is useful for prototyping algorithms, or for non time-critical code. If performence is needed, using block transfers is going to be significantly faster.


--
- Robert Jr Ohannessian
http://bob.allegronetwork.com/






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