Made Windows not use Gamma Functions
[sdlgit/SDL_perl.git] / src / Core / Video.xs
index 836fff1..95749cb 100644 (file)
@@ -8,6 +8,36 @@
 
 #include <SDL.h>
 
+
+static Uint16* av_to_uint16 (AV* av)
+{
+       int len = av_len(av);
+       if( len != -1)
+       {
+       int i;
+       Uint16* table = (Uint16 *)safemalloc(sizeof(Uint16)*(len));
+               //fprintf( stderr, "Expecting 1,2,5,6 \n Length is %d \n", len);
+       for ( i = 0; i < len+1 ; i++ ){ 
+               SV ** temp = av_fetch(av,i,0);
+             if( temp != NULL)
+               {
+               table[i] =  (Uint16 *) SvIV(  *temp   )  ;
+               /* fprintf( stderr, "table[%d] = ", i);
+                if (table[i] == NULL) { fprintf ( stderr, " NULL\n"); }
+               else{ fprintf(stderr, " %d \n", table[i]); } */
+               }
+               else { table[i] =0; }
+
+       }
+//             warn("Got %d %d %d %d \n", table[0], table[1], table[2], table[3] );
+
+       return table;
+       }
+       return NULL;
+}
+
+
+
 MODULE = SDL::Video    PACKAGE = SDL::Video    PREFIX = video_
 
 =for documentation
@@ -189,3 +219,42 @@ video_set_palette ( surface, flags, start, ... )
        OUTPUT: 
                RETVAL
 
+int
+video_set_gamma(r, g, b)
+       float r;
+       float g;
+       float b;
+       CODE:
+               RETVAL = -1;
+#ifdef WINDOWS 
+               warn( "SDL_SetGamma is unsupported in Windows. ");
+#else
+               RETVAL = SDL_SetGamma(r,g,b);
+#endif 
+       OUTPUT: 
+               RETVAL
+
+       
+int
+video_set_gamma_ramp( rt, gt, bt )
+       AV* rt;
+       AV* gt;
+       AV* bt;
+       CODE:
+
+               RETVAL = -1;
+#ifdef WINDOWS 
+               warn( "SDL_SetGammaRamp is unsupported in Windows. " );
+#else
+               Uint16 *redtable, *greentable, *bluetable;
+               redtable = av_to_uint16(rt);
+               greentable = av_to_uint16(gt);
+               bluetable = av_to_uint16(bt);
+               RETVAL =  SDL_SetGammaRamp(redtable, greentable, bluetable);
+               if( redtable != NULL) { safefree(redtable); }
+               if( greentable != NULL) { safefree(greentable); }
+               if( bluetable != NULL) { safefree(bluetable); } 
+#endif
+       OUTPUT:
+               RETVAL 
+