- pixmap = new Pixmap;
- pixmap->width = screen_rect.width;
- pixmap->height = screen_rect.height;
- pixmap->pixels = (unsigned char*)fbsurf->pixels;
+ if(!(gfx->pixmap = (Pixmap*)sh_malloc(sizeof(Pixmap)))) {
+ fprintf(stderr, "Failed to allocate pixmap.\n");
+ return false;
+ }
+
+ gfx->pixmap->width = gfx->screen_rect.width;
+ gfx->pixmap->height = gfx->screen_rect.height;
+
+ int fbsize = gfx->pixmap->width * gfx->pixmap->height * gfx->color_depth / 8;
+ if(!(gfx->pixmap->pixels = (unsigned char*)sh_malloc(fbsize))) {
+ fprintf(stderr, "failed to allocate the pixmap framebuffer.\n");
+ return false;
+ }
+
+ set_clipping_rect(gfx->screen_rect);