Move update_rects out of Surface.xs and make SDL::UpdateRects work
[sdlgit/SDL_perl.git] / src / SDL.xs
index 1dcddae..aa949e0 100644 (file)
@@ -1294,6 +1294,39 @@ UpdateRect ( surface, x, y, w ,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
 
 Comment out for now as it does not compile
@@ -1336,26 +1369,6 @@ SetVideoMode ( width, height, bpp, flags )
        OUTPUT:
                RETVAL
 
-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
@@ -1457,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