/*
* call-seq:
* set_alpha(alpha, flags=Rubygame::SRC_ALPHA)
*
* Set the per-surface alpha (opacity; non-transparency) of the surface.
*
* This function takes these arguments:
* alpha:: requested opacity of the surface. Alpha must be from 0
* (fully transparent) to 255 (fully opaque).
* flags:: 0 or Rubygame::SRC_ALPHA (default). 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_SetAlpha.
*/
VALUE rbgm_surface_set_alpha(int argc, VALUE *argv, VALUE self)
{
SDL_Surface *surf;
Uint8 alpha;
Uint32 flags = SDL_SRCALPHA;
VALUE valpha, vflags;
rb_scan_args(argc, argv, "11", &valpha, &vflags);
if( !NIL_P(vflags) )
{
flags = NUM2UINT(vflags);
}
alpha = NUM2UINT(valpha);
Data_Get_Struct(self, SDL_Surface, surf);
if( SDL_SetAlpha(surf,flags,alpha) != 0 )
rb_raise(eSDLError, "%s", SDL_GetError());
return self;
}