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 );
50 surface_load (CLASS, filename )
54 RETVAL = IMG_Load(filename);
59 surface_blit ( src, src_rect, dest, dest_rect )
65 RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect);
70 surface_fill_rect ( dest, dest_rect, color )
75 Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b);
76 RETVAL = SDL_FillRect(dest,dest_rect,pixel);
81 surface_update_rect ( surface, x, y, w ,h )
88 SDL_UpdateRect(surface,x,y,w,h);
91 surface_update_rects ( surface, ... )
94 SDL_Rect *rects, *temp;
96 if ( items < 2 ) return;
97 num_rects = items - 1;
99 rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
100 for(i=0;i<num_rects;i++) {
101 temp = (SDL_Rect *)SvIV(ST(i+1));
102 rects[i].x = temp->x;
103 rects[i].y = temp->y;
104 rects[i].w = temp->w;
105 rects[i].h = temp->h;
107 SDL_UpdateRects(surface,num_rects,rects);
111 surface_display ( surface )
114 char* CLASS = 'SDL::Surface\0';
115 RETVAL = SDL_DisplayFormat(surface);
120 surface_w ( surface )
128 surface_h ( surface )
136 surface_DESTROY(surface)
139 Uint8* pixels = surface->pixels;
140 Uint32 flags = surface->flags;
141 SDL_FreeSurface(surface);
142 if (flags & SDL_PREALLOC)