Added lock and unlock surface for SDL::Video and added tests
[sdlgit/SDL_perl.git] / src / Core / Video.xs
index 836fff1..87b348c 100644 (file)
@@ -8,6 +8,30 @@
 
 #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));
+       for ( i = 0; i < len+1 ; i++ ){ 
+               SV ** temp = av_fetch(av,i,0);
+             if( temp != NULL)
+               {
+                       table[i] =  (Uint16 *) SvIV(  *temp   );
+               }
+               else { table[i] =0; }
+
+       }
+       return table;
+       }
+       return NULL;
+}
+
+
+
 MODULE = SDL::Video    PACKAGE = SDL::Video    PREFIX = video_
 
 =for documentation
@@ -189,3 +213,70 @@ video_set_palette ( surface, flags, start, ... )
        OUTPUT: 
                RETVAL
 
+int
+video_set_gamma(r, g, b)
+       float r;
+       float g;
+       float b;
+       CODE:
+               RETVAL = SDL_SetGamma(r,g,b);
+       OUTPUT: 
+               RETVAL
+
+       
+int
+video_set_gamma_ramp( rt, gt, bt )
+       AV* rt;
+       AV* gt;
+       AV* bt;
+       CODE:
+               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); } 
+       OUTPUT:
+               RETVAL 
+
+
+
+Uint32
+video_map_RGB ( pixel_format, r, g, b )
+       SDL_PixelFormat *pixel_format
+       Uint8 r
+       Uint8 g
+       Uint8 b
+       CODE:
+               RETVAL = SDL_MapRGB(pixel_format,r,g,b);
+       OUTPUT:
+               RETVAL
+
+Uint32
+video_map_RGBA ( pixel_format, r, g, b, a )
+       SDL_PixelFormat *pixel_format
+       Uint8 r
+       Uint8 g
+       Uint8 b 
+       Uint8 a
+       CODE:
+               RETVAL = SDL_MapRGB(pixel_format,r,g,b);
+       OUTPUT:
+               RETVAL
+
+int
+video_lock_surface ( surface )
+       SDL_Surface *surface
+       CODE:
+               RETVAL = SDL_LockSurface(surface);
+       OUTPUT:
+               RETVAL
+
+void
+video_unlock_surface ( surface )
+       SDL_Surface *surface
+       CODE:
+               SDL_UnlockSurface(surface);
+