/*
* call-seq:
* set_colorkey(color,flags=0)
*
* Set the colorkey of the surface. See Surface#colorkey for a description
* of colorkeys.
*
* This method takes these arguments:
* color:: color to use as the key, in the form [r,g,b]. Can be +nil+ to
* un-set the colorkey.
* flags:: 0 or Rubygame::SRC_COLORKEY (default) or
* Rubygame::SRC_COLORKEY|Rubygame::SDL_RLEACCEL. Most people will
* want the default, in which case this argument can be omitted. For
* advanced users: this flag affects the surface as described in the
* docs for the SDL C function, SDL_SetColorkey.
*/
VALUE rbgm_surface_set_colorkey( int argc, VALUE *argv, VALUE self)
{
SDL_Surface *surf;
Uint32 color;
Uint32 flag;
Uint8 r,g,b;
Data_Get_Struct(self, SDL_Surface, surf);
if(argv[0] == Qnil)
{
flag = 0;
color = 0;
}
else
{
if(argc > 1)
flag = NUM2UINT(argv[1]);
else
flag = SDL_SRCCOLORKEY;
r = NUM2UINT(rb_ary_entry(argv[0],0));
g = NUM2UINT(rb_ary_entry(argv[0],1));
b = NUM2UINT(rb_ary_entry(argv[0],2));
//printf("RGB: %d,%d,%d ",r,g,b);
color = SDL_MapRGB(surf->format, r,g,b);
//printf("colorkey: %d\n", color);
}
if(SDL_SetColorKey(surf,flag,color)!=0)
rb_raise(eSDLError,"could not set colorkey: %s",SDL_GetError());
return self;
}