11 MODULE = SDL::Surface PACKAGE = SDL::Surface PREFIX = surface_
15 SDL_Surface -- Graphic surface structure
17 typedef struct SDL_Surface {
18 Uint32 flags; /* Read-only */
19 SDL_PixelFormat *format; /* Read-only */
20 int w, h; /* Read-only */
21 Uint16 pitch; /* Read-only */
22 void *pixels; /* Read-write */
23 SDL_Rect clip_rect; /* Read-only */
24 int refcount; /* Read-mostly */
26 /* This structure also contains private fields not shown here */
32 surface_new (CLASS, flags, width, height, depth, Rmask, Gmask, Bmask, Amask )
43 RETVAL = SDL_CreateRGBSurface ( flags, width, height,
44 depth, Rmask, Gmask, Bmask, Amask );
49 surface_blit ( src, src_rect, dest, dest_rect )
55 RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect);
60 surface_fill_rect ( dest, dest_rect, color )
65 Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b);
66 RETVAL = SDL_FillRect(dest,dest_rect,pixel);
71 surface_update_rect ( surface, x, y, w ,h )
78 SDL_UpdateRect(surface,x,y,w,h);
81 surface_update_rects ( surface, ... )
84 SDL_Rect *rects, *temp;
86 if ( items < 2 ) return;
87 num_rects = items - 1;
89 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
90 for(i=0;i<num_rects;i++) {
91 temp = (SDL_Rect *)SvIV(ST(i+1));
97 SDL_UpdateRects(surface,num_rects,rects);
101 surface_display ( surface )
104 char* CLASS = "SDL::Surface";
105 RETVAL = SDL_DisplayFormat(surface);
110 surface_display_alpha ( surface )
113 char* CLASS = "SDL::Surface";
114 RETVAL = SDL_DisplayFormatAlpha(surface);
119 surface_pitch( surface )
122 RETVAL = surface->pitch;
127 surface_w ( surface )
135 surface_h ( surface )
143 surface_get_pixels(surface)
146 if(!surface->pixels) croak("Incomplete surface");
147 RETVAL = PTR2IV(surface->pixels);
152 surface_set_pixels(surface, pixels)
162 p = SvPV(pixels, len);
163 if (len > surface->pitch*surface->h)
164 len = surface->pitch*surface->h;
165 memcpy(surface->pixels, p, len);
168 surface_DESTROY(surface)
171 Uint8* pixels = surface->pixels;
172 Uint32 flags = surface->flags;
173 SDL_FreeSurface(surface);
174 if (flags & SDL_PREALLOC)