Implemented and Tested SDL::Video::set_color_key, SDL::Video::set_alpha. Also did...
Kartik Thakore [Mon, 2 Nov 2009 14:12:59 +0000 (09:12 -0500)]
src/Core/Video.xs
t/core_video.t

index 8612aae..e7a9a0e 100644 (file)
@@ -297,8 +297,9 @@ video_convert_surface( src, fmt, flags)
 SDL_Surface *
 video_display_format ( surface )
        SDL_Surface *surface
-       CODE:
+       PREINIT:
                char* CLASS = "SDL::Surface";
+       CODE:
                RETVAL = SDL_DisplayFormat(surface);
        OUTPUT:
                RETVAL
@@ -306,9 +307,33 @@ video_display_format ( surface )
 SDL_Surface *
 video_display_format_alpha ( surface )
        SDL_Surface *surface
-       CODE:
+       PREINIT:
                char* CLASS = "SDL::Surface";
+       CODE:
                RETVAL = SDL_DisplayFormatAlpha(surface);
        OUTPUT:
                RETVAL
 
+
+int
+video_set_color_key ( surface, flag, key )
+       SDL_Surface *surface
+       Uint32 flag
+       SDL_Color *key
+       CODE:
+               Uint32 pixel = SDL_MapRGB(surface->format,key->r,key->g,key->b);
+               RETVAL = SDL_SetColorKey(surface,flag,pixel);
+       OUTPUT:
+               RETVAL
+
+int
+video_set_alpha ( surface, flag, alpha )
+       SDL_Surface *surface
+       Uint32 flag
+       Uint8 alpha
+       CODE:
+               RETVAL = SDL_SetAlpha(surface,flag,alpha);
+       OUTPUT:
+               RETVAL
+
+
index 0637ec1..2da9788 100644 (file)
@@ -9,7 +9,7 @@ use Data::Dumper;
 use Test::More;
 use SDL::Rect;
 
-plan ( tests => 26);
+plan ( tests => 28);
 
 use_ok( 'SDL::Video' ); 
 
@@ -35,7 +35,8 @@ my @done =
        convert_surface
        display_format
        display_format_alpha
-
+       set_color_key
+       set_alpha
        /;
 
 can_ok ('SDL::Video', @done); 
@@ -128,14 +129,22 @@ isa_ok(SDL::Video::convert_surface( $display , $hwdisplay->format, SDL_SRCALPHA)
 isa_ok(SDL::Video::display_format( $display ), 'SDL::Surface', '[display_format] Returns a SDL::Surface');
 isa_ok(SDL::Video::display_format_alpha( $display ), 'SDL::Surface', '[display_format_alpha] Returns a SDL::Surface');
 
+is(  SDL::Video::set_color_key($display, SDL_SRCCOLORKEY, SDL::Color->new( 0, 10, 0 ) ),
+   0,  '[set_color_key] Returns 0 on success' 
+   ) ;
+
+is(  SDL::Video::set_alpha($display, SDL_SRCALPHA, 100 ),
+   0,  '[set_alpha] Returns 0 on success' 
+   ) ;
+
+
+
 my @left = qw/
        get_gamma_ramp
        get_RGB
        get_RGBA
        load_BMP
        save_BMP
-       set_color_key
-       set_alpha
        set_clip_rect
        get_clip_rect
        blit_surface