Move update_rects out of Surface.xs and make SDL::UpdateRects work
[sdlgit/SDL_perl.git] / src / SDL.xs
index 13d265c..aa949e0 100644 (file)
@@ -858,6 +858,19 @@ GetKeyName ( sym )
        OUTPUT:
                RETVAL
 
+#ifdef HAVE_SDL_IMAGE
+
+SDL_Surface *
+IMG_Load ( filename )
+       char *filename
+       CODE:
+               char* CLASS = "SDL::Surface";
+               RETVAL = IMG_Load(filename);
+       OUTPUT:
+               RETVAL
+
+#endif
+
 =for comment
 
 Comment out for now as it does not compile
@@ -883,18 +896,6 @@ CreateRGBSurfaceFrom (pixels, width, height, depth, pitch, Rmask, Gmask, Bmask,
        OUTPUT: 
                RETVAL
 
-#ifdef HAVE_SDL_IMAGE
-
-SDL_Surface *
-IMGLoad ( fname )
-       char *fname
-       CODE:
-               RETVAL = IMG_Load(fname);
-       OUTPUT:
-               RETVAL
-
-#endif
-
 SDL_Surface*
 SurfaceCopy ( surface )
        SDL_Surface *surface
@@ -1261,6 +1262,70 @@ Flip ( surface )
        OUTPUT:
                RETVAL
 
+int
+BlitSurface ( src, src_rect, dest, dest_rect )
+       SDL_Surface *src
+       SDL_Surface *dest
+       SDL_Rect *src_rect
+       SDL_Rect *dest_rect
+       CODE:
+               RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect);
+       OUTPUT:
+               RETVAL
+
+Uint32
+MapRGB ( 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
+
+void
+UpdateRect ( surface, x, y, w ,h )
+       SDL_Surface *surface
+       int x
+       int y
+       int w
+       int h
+       CODE:
+               SDL_UpdateRect(surface,x,y,w,h);
+
+SDL_Surface *
+DisplayFormat ( surface )
+       SDL_Surface *surface
+       CODE:
+               char* CLASS = "SDL::Surface";
+               RETVAL = SDL_DisplayFormat(surface);
+       OUTPUT:
+               RETVAL
+
+SDL_Surface *
+DisplayFormatAlpha ( surface )
+       SDL_Surface *surface
+       CODE:
+               char* CLASS = "SDL::Surface";
+               RETVAL = SDL_DisplayFormatAlpha(surface);
+       OUTPUT:
+               RETVAL
+
+void
+UpdateRects ( surface, ... )
+       SDL_Surface *surface
+       CODE:
+               SDL_Rect *rects;
+               int num_rects,i;
+               if ( items < 2 ) return;
+               num_rects = items - 1;
+               rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
+               for(i=0;i<num_rects;i++) {
+                       rects[i] = *(SDL_Rect *)SvIV((SV*)SvRV( ST(i + 1) ));
+               }
+               SDL_UpdateRects(surface,num_rects,rects);
+               safefree(rects);
 
 =for comment
 
@@ -1304,36 +1369,6 @@ SetVideoMode ( width, height, bpp, flags )
        OUTPUT:
                RETVAL
 
-void
-UpdateRect ( surface, x, y, w ,h )
-       SDL_Surface *surface
-       int x
-       int y
-       int w
-       int h
-       CODE:
-               SDL_UpdateRect(surface,x,y,w,h);
-
-void
-UpdateRects ( surface, ... )
-       SDL_Surface *surface
-       CODE:
-               SDL_Rect *rects, *temp;
-               int num_rects,i;
-               if ( items < 2 ) return;
-               num_rects = items - 1;
-               SDL_UpdateRects(surface,num_rects,rects);                       
-               rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
-               for(i=0;i<num_rects;i++) {
-                       temp = (SDL_Rect *)SvIV(ST(i+1));
-                       rects[i].x = temp->x;
-                       rects[i].y = temp->y;
-                       rects[i].w = temp->w;
-                       rects[i].h = temp->h;
-               } 
-               SDL_UpdateRects(surface,num_rects,rects);
-               safefree(rects);
-
 int
 Flip ( surface )
        SDL_Surface *surface
@@ -1365,17 +1400,6 @@ all_done:
                RETVAL
 
 Uint32
-MapRGB ( surface, r, g, b )
-       SDL_Surface *surface
-       Uint8 r
-       Uint8 g
-       Uint8 b
-       CODE:
-               RETVAL = SDL_MapRGB(surface->format,r,g,b);
-       OUTPUT:
-               RETVAL
-
-Uint32
 MapRGBA ( surface, r, g, b, a )
        SDL_Surface *surface
        Uint8 r
@@ -1446,22 +1470,6 @@ SetAlpha ( surface, flag, alpha )
        OUTPUT:
                RETVAL
 
-SDL_Surface *
-DisplayFormat ( surface )
-       SDL_Surface *surface
-       CODE:
-               RETVAL = SDL_DisplayFormat(surface);
-       OUTPUT:
-               RETVAL
-
-SDL_Surface*
-DisplayFormatAlpha ( surface )
-       SDL_Surface *surface
-       CODE:
-               RETVAL = SDL_DisplayFormatAlpha(surface);
-       OUTPUT:
-               RETVAL
-
 SDL_Surface*
 ConvertRGB ( surface )
        SDL_Surface * surface
@@ -1514,32 +1522,14 @@ ConvertRGBA ( surface )
        OUTPUT:
                RETVAL
 
-int
-BlitSurface ( src, src_rect, dest, dest_rect )
-       SDL_Surface *src
-
-       SDL_Surface *dest
-
-       SDL_Rect *src_rect
-
-       SDL_Rect *dest_rect
-       CODE:
-               RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect);
-       OUTPUT:
-               RETVAL
-
 =cut
 
 int
-FillRect ( dest, dest_rect, color )
+FillRect ( dest, dest_rect, pixel )
        SDL_Surface *dest
-       
-       SDL_Color *color
-       
        SDL_Rect *dest_rect
-
+       Uint32 pixel
        CODE:
-               Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b);
                RETVAL = SDL_FillRect(dest,dest_rect,pixel);
        OUTPUT:
                RETVAL