From: Kartik Thakore Date: Wed, 28 Oct 2009 16:30:50 +0000 (-0400) Subject: XS for redtable done for set_gamma_ramp X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8b7c3ac88365da7f48ecf38e313ccbb9db13161c;p=sdlgit%2FSDL_perl.git XS for redtable done for set_gamma_ramp --- diff --git a/src/Core/Video.xs b/src/Core/Video.xs index 083db5f..14a0b28 100644 --- a/src/Core/Video.xs +++ b/src/Core/Video.xs @@ -201,10 +201,31 @@ video_set_gamma(r, g, b) RETVAL int -video_set_gamma_ramp( ... ) +video_set_gamma_ramp( rt, gt, bt ) + AV* rt; + AV* gt; + AV* bt; CODE: - Uint16 *redtable, *greentable, *bluetable; - RETVAL = SDL_SetGammaRamp(NULL, NULL, NULL); + Uint16 *redtable, *greentable, *bluetable, *temp; + int srt = av_len(rt); + int sgt = av_len(gt); + int sbt = av_len(bt); + int i; + if( srt == -1 ) + { + redtable = NULL; + } + else + { + redtable = (Uint16 *)safemalloc(sizeof(Uint16)*(srt+1)); + for ( i = 0; i < srt ; i++ ){ + temp = (Uint16 *)ST(i); + redtable[i] = *temp; + } + + } + + RETVAL = SDL_SetGammaRamp(redtable, NULL, NULL); OUTPUT: RETVAL diff --git a/t/core_video.t b/t/core_video.t index de5f141..3159925 100644 --- a/t/core_video.t +++ b/t/core_video.t @@ -76,7 +76,9 @@ $value = SDL::Video::set_palette($display, SDL_LOGPAL|SDL_PHYSPAL, 0); is( $value , 0, '[set_palette] returns 0 trying to write to 32 bit surface' ); -SDL::Video::set_gamma_ramp( 0, 0, 0 ); pass '[set_gamma_ramp] ran'; +my @redtable = (0,0,0,0); + +SDL::Video::set_gamma_ramp( \@redtable , [0,1,2,3], [2,3,4,5]); pass '[set_gamma_ramp] ran'; SDL::Video::set_gamma( 1.0, 1.0, 1.0 ); pass '[set_gamma] ran ';