Re: [AD] Allegro5 and colors

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


> Javier Gonzalez wrote:
> > What about using a double (8 bytes) and typecasting it
> 
> Yuck :-)
> 
> Besides, ANSI says nothing about the size of a double versus the size of 
> other types. Some platform may have sizeof(double)<8.
> 
> Also, IMHO whatever type we are using, it should be straightforward to 
> extract r,g,b components from it, without typecasting.
> 
> I also think that an optimizing compiler might get confused and put it 
> in a floating point register, making it much slower.
> 
> I think that the best way to pass big size parameters is by a pointer to 
> a struct.


Ok, then can I suggest that?

>AL_COLOR color;
>al_map_rgba_b(bmp, &color, r, g, b, a);
>al_put_pixel(bmp, x, y, &color);

>or:

>AL_COLOR color;
>al_put_pixel(bmp, x, y, al_map_rgba_b(bmp, &color, r, g, b, a));

al_map_rgba_b could take NULL as a pointer and in that case
return an internal static structure to avoid dummies?
You know, to be able to do something like
al_put_pixel(bmp, x, y, al_map_rgba_b(bmp, NULL, r, g, b, a));

where al_map_rgba_b would do:
{
  static AL_COLOR static_color;
  if (color_pointer == NULL)
    color_pointer = &static_color;
  ...
  return color_pointer;
}



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