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_format ( surface )
52 char* CLASS = "SDL::PixelFormat";
53 RETVAL = surface->format;
58 surface_fill_rect ( dest, dest_rect, color )
63 Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b);
64 RETVAL = SDL_FillRect(dest,dest_rect,pixel);
69 surface_update_rect ( surface, x, y, w ,h )
76 SDL_UpdateRect(surface,x,y,w,h);
79 surface_update_rects ( surface, ... )
82 SDL_Rect *rects, *temp;
84 if ( items < 2 ) return;
85 num_rects = items - 1;
87 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
88 for(i=0;i<num_rects;i++) {
89 temp = (SDL_Rect *)SvIV(ST(i+1));
95 SDL_UpdateRects(surface,num_rects,rects);
99 surface_display ( surface )
102 char* CLASS = "SDL::Surface";
103 RETVAL = SDL_DisplayFormat(surface);
108 surface_display_alpha ( surface )
111 char* CLASS = "SDL::Surface";
112 RETVAL = SDL_DisplayFormatAlpha(surface);
117 surface_pitch( surface )
120 RETVAL = surface->pitch;
125 surface_w ( surface )
133 surface_h ( surface )
141 surface_get_pixels(surface)
144 if(!surface->pixels) croak("Incomplete surface");
145 RETVAL = PTR2IV(surface->pixels);
150 surface_set_pixels(surface, pixels)
160 p = SvPV(pixels, len);
161 if (len > surface->pitch*surface->h)
162 len = surface->pitch*surface->h;
163 memcpy(surface->pixels, p, len);
166 surface_DESTROY(surface)
169 Uint8* pixels = surface->pixels;
170 Uint32 flags = surface->flags;
171 SDL_FreeSurface(surface);
172 if (flags & SDL_PREALLOC)