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_fill_rect ( dest, dest_rect, color )
54 Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b);
55 RETVAL = SDL_FillRect(dest,dest_rect,pixel);
60 surface_update_rect ( surface, x, y, w ,h )
67 SDL_UpdateRect(surface,x,y,w,h);
70 surface_update_rects ( surface, ... )
73 SDL_Rect *rects, *temp;
75 if ( items < 2 ) return;
76 num_rects = items - 1;
78 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
79 for(i=0;i<num_rects;i++) {
80 temp = (SDL_Rect *)SvIV(ST(i+1));
86 SDL_UpdateRects(surface,num_rects,rects);
90 surface_display ( surface )
93 char* CLASS = "SDL::Surface";
94 RETVAL = SDL_DisplayFormat(surface);
99 surface_display_alpha ( surface )
102 char* CLASS = "SDL::Surface";
103 RETVAL = SDL_DisplayFormatAlpha(surface);
108 surface_pitch( surface )
111 RETVAL = surface->pitch;
116 surface_w ( surface )
124 surface_h ( surface )
132 surface_get_pixels(surface)
135 if(!surface->pixels) croak("Incomplete surface");
136 RETVAL = PTR2IV(surface->pixels);
141 surface_set_pixels(surface, pixels)
151 p = SvPV(pixels, len);
152 if (len > surface->pitch*surface->h)
153 len = surface->pitch*surface->h;
154 memcpy(surface->pixels, p, len);
157 surface_DESTROY(surface)
160 Uint8* pixels = surface->pixels;
161 Uint32 flags = surface->flags;
162 SDL_FreeSurface(surface);
163 if (flags & SDL_PREALLOC)