From: Leon Brocard Date: Mon, 2 Nov 2009 16:46:17 +0000 (+0000) Subject: Implement set_clip_rect, get_clip_rect X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3a95710ed5846416cd8fe3cd91bb3965a95baf1f;p=sdlgit%2FSDL_perl.git Implement set_clip_rect, get_clip_rect --- diff --git a/src/Core/Video.xs b/src/Core/Video.xs index 3df52a9..b7e8706 100644 --- a/src/Core/Video.xs +++ b/src/Core/Video.xs @@ -404,3 +404,17 @@ blit_surface ( src, src_rect, dest, dest_rect ) RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect); OUTPUT: RETVAL + +void +set_clip_rect ( surface, rect ) + SDL_Surface *surface + SDL_Rect *rect + CODE: + SDL_SetClipRect(surface,rect); + +void +get_clip_rect ( surface, rect ) + SDL_Surface *surface + SDL_Rect *rect; + CODE: + SDL_GetClipRect(surface, rect); diff --git a/src/SDL.xs b/src/SDL.xs index 3ef0b9a..1e38e3f 100644 --- a/src/SDL.xs +++ b/src/SDL.xs @@ -2148,21 +2148,6 @@ JoyBallEventYrel ( e ) OUTPUT: RETVAL -void -SetClipRect ( surface, rect ) - SDL_Surface *surface - SDL_Rect *rect - CODE: - SDL_SetClipRect(surface,rect); - -void -GetClipRect ( surface, rect ) - SDL_Surface *surface - SDL_Rect *rect; - CODE: - SDL_GetClipRect(surface, rect); - - #ifdef HAVE_SDL_NET int diff --git a/t/core_video.t b/t/core_video.t index 3860f83..93b3b76 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 => 33); +plan ( tests => 41); use_ok( 'SDL::Video' ); @@ -43,6 +43,8 @@ my @done = save_BMP fill_rect blit_surface + set_clip_rect + get_clip_rect /; can_ok ('SDL::Video', @done); @@ -159,10 +161,21 @@ my $pixel = SDL::Video::map_RGB( $display->format, 255, 127, 0 ); SDL::Video::fill_rect( $display, SDL::Rect->new( 0, 0, 32, 32 ), $pixel ); ok( 1, '[fill_rect] filled rect' ); +my $clip_rect = SDL::Rect->new(0, 0, 10, 20); +SDL::Video::get_clip_rect($display, $clip_rect); +is($clip_rect->x, 0, '[get_clip_rect] returns a rect with x 0'); +is($clip_rect->y, 0, '[get_clip_rect] returns a rect with y 0'); +is($clip_rect->w, 640, '[get_clip_rect] returns a rect with w 640'); +is($clip_rect->h, 480, '[get_clip_rect] returns a rect with h 480'); +SDL::Video::set_clip_rect($display, SDL::Rect->new(10, 20, 100, 200)); +SDL::Video::get_clip_rect($display, $clip_rect); +is($clip_rect->x, 10, '[get_clip_rect] returns a rect with x 10'); +is($clip_rect->y, 20, '[get_clip_rect] returns a rect with y 20'); +is($clip_rect->w, 100, '[get_clip_rect] returns a rect with w 100'); +is($clip_rect->h, 200, '[get_clip_rect] returns a rect with h 200'); + my @left = qw/ get_gamma_ramp - set_clip_rect - get_clip_rect GL_load_library GL_get_proc_address GL_get_attribute