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_update_rect ( surface, x, y, w ,h )
65 SDL_UpdateRect(surface,x,y,w,h);
68 surface_update_rects ( surface, ... )
71 SDL_Rect *rects, *temp;
73 if ( items < 2 ) return;
74 num_rects = items - 1;
76 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
77 for(i=0;i<num_rects;i++) {
78 temp = (SDL_Rect *)SvIV(ST(i+1));
84 SDL_UpdateRects(surface,num_rects,rects);
88 surface_display ( surface )
91 char* CLASS = "SDL::Surface";
92 RETVAL = SDL_DisplayFormat(surface);
97 surface_display_alpha ( surface )
100 char* CLASS = "SDL::Surface";
101 RETVAL = SDL_DisplayFormatAlpha(surface);
106 surface_pitch( surface )
109 RETVAL = surface->pitch;
114 surface_w ( surface )
122 surface_h ( surface )
130 surface_get_pixels(surface)
133 if(!surface->pixels) croak("Incomplete surface");
134 RETVAL = PTR2IV(surface->pixels);
139 surface_set_pixels(surface, pixels)
149 p = SvPV(pixels, len);
150 if (len > surface->pitch*surface->h)
151 len = surface->pitch*surface->h;
152 memcpy(surface->pixels, p, len);
155 surface_DESTROY(surface)
158 Uint8* pixels = surface->pixels;
159 Uint32 flags = surface->flags;
160 SDL_FreeSurface(surface);
161 if (flags & SDL_PREALLOC)