XS for redtable done for set_gamma_ramp
Kartik Thakore [Wed, 28 Oct 2009 16:30:50 +0000 (12:30 -0400)]
src/Core/Video.xs
t/core_video.t

index 083db5f..14a0b28 100644 (file)
@@ -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 
 
index de5f141..3159925 100644 (file)
@@ -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 ';