From: Kartik Thakore Date: Mon, 2 Nov 2009 14:12:59 +0000 (-0500) Subject: Implemented and Tested SDL::Video::set_color_key, SDL::Video::set_alpha. Also did... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=213b9caf2f2f852bac2490ad0b811dff934e9ead;p=sdlgit%2FSDL_perl.git Implemented and Tested SDL::Video::set_color_key, SDL::Video::set_alpha. Also did preinit in SDL::Video xs. 55% imple on SDL::Video now. --- diff --git a/src/Core/Video.xs b/src/Core/Video.xs index 8612aae..e7a9a0e 100644 --- a/src/Core/Video.xs +++ b/src/Core/Video.xs @@ -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 + + diff --git a/t/core_video.t b/t/core_video.t index 0637ec1..2da9788 100644 --- a/t/core_video.t +++ b/t/core_video.t @@ -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