Added lock and unlock surface for SDL::Video and added tests
[sdlgit/SDL_perl.git] / src / Core / Video.xs
index 95749cb..87b348c 100644 (file)
@@ -16,21 +16,15 @@ static Uint16* av_to_uint16 (AV* av)
        {
        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]); } */
+                       table[i] =  (Uint16 *) SvIV(  *temp   );
                }
                else { table[i] =0; }
 
        }
-//             warn("Got %d %d %d %d \n", table[0], table[1], table[2], table[3] );
-
        return table;
        }
        return NULL;
@@ -225,12 +219,7 @@ video_set_gamma(r, g, b)
        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
 
@@ -241,11 +230,6 @@ video_set_gamma_ramp( rt, gt, bt )
        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);
@@ -254,7 +238,45 @@ video_set_gamma_ramp( rt, gt, bt )
                if( redtable != NULL) { safefree(redtable); }
                if( greentable != NULL) { safefree(greentable); }
                if( bluetable != NULL) { safefree(bluetable); } 
-#endif
        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);
+