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_rects ( surface, ... )
61 SDL_Rect *rects, *temp;
63 if ( items < 2 ) return;
64 num_rects = items - 1;
66 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
67 for(i=0;i<num_rects;i++) {
68 temp = (SDL_Rect *)SvIV(ST(i+1));
74 SDL_UpdateRects(surface,num_rects,rects);
78 surface_display ( surface )
81 char* CLASS = "SDL::Surface";
83 SDL_Surface *new_surface = SDL_DisplayFormat(surface);
84 SDL_FreeSurface(surface);
90 surface_display_alpha ( surface )
93 char* CLASS = "SDL::Surface";
94 SDL_Surface *new_surface = SDL_DisplayFormatAlpha(surface);
95 SDL_FreeSurface(surface);
101 surface_pitch( surface )
104 RETVAL = surface->pitch;
109 surface_w ( surface )
117 surface_h ( surface )
125 surface_get_pixels(surface)
128 if(!surface->pixels) croak("Incomplete surface");
129 RETVAL = PTR2IV(surface->pixels);
134 surface_set_pixels(surface, pixels)
144 p = SvPV(pixels, len);
145 if (len > surface->pitch*surface->h)
146 len = surface->pitch*surface->h;
147 memcpy(surface->pixels, p, len);
150 surface_DESTROY(surface)
153 Uint8* pixels = surface->pixels;
154 Uint32 flags = surface->flags;
155 SDL_FreeSurface(surface);
156 if (flags & SDL_PREALLOC)