/*
 *  call-seq:
 *    clip = Rect or nil
 *
 *  Set the current clipping area of the Surface. See also #cliprect.
 *
 *  The clipping area of a Surface is the only part which can be drawn upon
 *  by other Surface's #blits. The clipping area will be clipped to the edges
 *  of the surface so that the clipping area for a Surface can never fall
 *  outside the edges of the Surface.
 *
 *  By default, the clipping area is the entire area of the Surface.
 *  You may set clip to +nil+, which will reset the clipping area to cover
 *  the entire Surface.
 */
VALUE rbgm_surface_set_clip( VALUE self, VALUE clip )
{
        SDL_Rect *rect;
        SDL_Surface *surf;
        Data_Get_Struct(self, SDL_Surface, surf);


        if( NIL_P(clip) )
        {
                SDL_SetClipRect(surf,NULL);
        }
        else
        { 
                clip = convert_to_array(clip);
                rect = make_rect(\
                                 NUM2INT(rb_ary_entry(clip,0)),\
                                 NUM2INT(rb_ary_entry(clip,1)),\
                                 NUM2INT(rb_ary_entry(clip,2)),\
                                 NUM2INT(rb_ary_entry(clip,3))\
                                 );

                SDL_SetClipRect(surf,rect);
                free(rect);
        }

        return self;
}