From: Leon Brocard Date: Fri, 16 Oct 2009 09:47:23 +0000 (+0100) Subject: Remove fill_rect from surface, fix SDL::FillRect X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=34a219f78b8882f5cee508265a87b4dfec27eb26;p=sdlgit%2FSDL_perl.git Remove fill_rect from surface, fix SDL::FillRect --- diff --git a/src/Core/objects/Surface.xs b/src/Core/objects/Surface.xs index 587ddc5..993a3eb 100644 --- a/src/Core/objects/Surface.xs +++ b/src/Core/objects/Surface.xs @@ -54,17 +54,6 @@ surface_format ( surface ) OUTPUT: RETVAL -int -surface_fill_rect ( dest, dest_rect, color ) - SDL_Surface *dest - SDL_Color *color - SDL_Rect *dest_rect - CODE: - Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b); - RETVAL = SDL_FillRect(dest,dest_rect,pixel); - OUTPUT: - RETVAL - void surface_update_rect ( surface, x, y, w ,h ) SDL_Surface *surface diff --git a/src/SDL.xs b/src/SDL.xs index 6e07fe1..256cb40 100644 --- a/src/SDL.xs +++ b/src/SDL.xs @@ -1528,15 +1528,11 @@ ConvertRGBA ( surface ) =cut int -FillRect ( dest, dest_rect, color ) +FillRect ( dest, dest_rect, pixel ) SDL_Surface *dest - - SDL_Color *color - SDL_Rect *dest_rect - + Uint32 pixel CODE: - Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b); RETVAL = SDL_FillRect(dest,dest_rect,pixel); OUTPUT: RETVAL diff --git a/t/core_surface.t b/t/core_surface.t index bfdf4e8..a047948 100644 --- a/t/core_surface.t +++ b/t/core_surface.t @@ -57,9 +57,7 @@ is( $pixel_format->alpha, 255, '255 alpha' ); my $pixel = SDL::MapRGB( $pixel_format, 255, 127, 0 ); is( $pixel, 32767, '32767 pixel' ); - -$surface->fill_rect( SDL::Rect->new( 0, 0, 32, 32 ), - SDL::Color->new( 200, 200, 200 ) ); +SDL::FillRect( $surface, SDL::Rect->new( 0, 0, 32, 32 ), $pixel ); ok( 1, 'Managed to fill_rect' ); my $small_rect = SDL::Rect->new( 0, 0, 64, 64 ); @@ -87,13 +85,16 @@ isa_ok( $image_format, 'SDL::Surface' ); my $image_format_alpha = $image->display_alpha; isa_ok( $image_format_alpha, 'SDL::Surface' ); -my $rect = SDL::Rect->new( 0, 0, $app->w, $app->h ); +my $app_pixel_format = $app->format; -my $blue = SDL::Color->new( 0x00, 0x00, 0xff, ); +my $rect = SDL::Rect->new( 0, 0, $app->w, $app->h ); -$app->fill_rect( $rect, $blue ); +my $blue_pixel = SDL::MapRGB( $app_pixel_format, 0x00, 0x00, 0xff ); +SDL::FillRect( $app, $rect, $blue_pixel ); +SDL::Surface::update_rect( $app, 0, 0, 0, 0 ); diag( 'This is in surface : ' . SDL::Surface::get_pixels($app) ); pass 'did this pass'; +SDL::Delay(100); diff --git a/t/intergation1.t b/t/intergation1.t index 1947864..9bbc491 100644 --- a/t/intergation1.t +++ b/t/intergation1.t @@ -60,32 +60,23 @@ can_ok ('SDL::App', qw/ sync attribute /); -my $app = SDL::App->new(-title => "Test", -width => 640, -height => 480, -init => SDL_INIT_VIDEO); + my $app = SDL::App->new(-title => "Test", -width => 640, -height => 480, -init => SDL_INIT_VIDEO); my $rect = SDL::Rect->new( 0,0, $app->w, $app->h); - my $blue = SDL::Color->new( - 0x00, - 0x00, - 0xff, - ); - - my $col = SDL::Color->new( - 0xf0, - 0x00, - 0x33, - ); + my $pixel_format = $app->format; + my $blue_pixel = SDL::MapRGB( $pixel_format, 0x00, 0x00, 0xff ); + my $col_pixel = SDL::MapRGB( $pixel_format, 0xf0, 0x00, 0x33 ); my $grect = SDL::Game::Rect->new(10, 10, 30, 35); foreach(0..80) { - $grect->x($_ ); $grect->centery($_ * 3); $grect->size( ($_ / 40) * $_, ($_/38) * $_ ); - $app->fill_rect($rect, $blue); - $app->fill_rect($grect, $col); + SDL::FillRect( $app, $rect, $blue_pixel ); + SDL::FillRect( $app, $grect, $col_pixel ); SDL::Surface::update_rect($app, 0, 0, 640, 480); SDL::Delay(10);