+ /* create additional image buffers for double-buffering */
+
+#ifdef USE_SDL_LIBRARY
+
+ /* create some native image surfaces for double-buffer purposes */
+
+ /* create double-buffer surface for background image */
+ if ((sdl_image_tmp = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ WIN_XSIZE, WIN_YSIZE,
+ WIN_SDL_DEPTH, 0, 0, 0, 0))
+ == NULL)
+ Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+
+ if ((pix[PIX_DB_BACK] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
+ Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
+
+ SDL_FreeSurface(sdl_image_tmp);
+
+ /* create double-buffer surface for door image */
+ if ((sdl_image_tmp = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ 3 * DXSIZE, DYSIZE + VYSIZE,
+ WIN_SDL_DEPTH, 0, 0, 0, 0))
+ == NULL)
+ Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+
+ if ((pix[PIX_DB_DOOR] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
+ Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
+
+ SDL_FreeSurface(sdl_image_tmp);
+
+ /* create double-buffer surface for field image */
+ if ((sdl_image_tmp = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ FXSIZE, FYSIZE,
+ WIN_SDL_DEPTH, 0, 0, 0, 0))
+ == NULL)
+ Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+
+ if ((pix[PIX_DB_FIELD] = SDL_DisplayFormat(sdl_image_tmp)) == NULL)
+ Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
+
+ SDL_FreeSurface(sdl_image_tmp);
+
+ /* SDL cannot directly draw to the visible video framebuffer like X11,
+ but always uses a backbuffer, which is then blitted to the visible
+ video framebuffer with 'SDL_UpdateRect' (or replaced with the current
+ visible video framebuffer with 'SDL_Flip', if the hardware supports
+ this). Therefore do not use an additional backbuffer for drawing, but
+ use a symbolic buffer (distinguishable from the SDL backbuffer) called
+ 'window', which indicates that the SDL backbuffer should be updated to
+ the visible video framebuffer when attempting to blit to it.
+
+ For convenience, it seems to be a good idea to create this symbolic
+ buffer 'window' at the same size as the SDL backbuffer. Although it
+ should never be drawn to directly, it would do no harm nevertheless. */
+
+ window = pix[PIX_DB_BACK]; /* 'window' is only symbolic buffer */
+ pix[PIX_DB_BACK] = backbuffer; /* 'backbuffer' is SDL screen buffer */
+
+#else /* !USE_SDL_LIBRARY */
+
+ pix[PIX_DB_BACK] = XCreatePixmap(display, window,
+ WIN_XSIZE,WIN_YSIZE,
+ XDefaultDepth(display,screen));
+ pix[PIX_DB_DOOR] = XCreatePixmap(display, window,
+ 3*DXSIZE,DYSIZE+VYSIZE,
+ XDefaultDepth(display,screen));
+ pix[PIX_DB_FIELD] = XCreatePixmap(display, window,
+ FXSIZE,FYSIZE,
+ XDefaultDepth(display,screen));
+
+ if (!pix[PIX_DB_BACK] || !pix[PIX_DB_DOOR] || !pix[PIX_DB_FIELD])
+ Error(ERR_EXIT, "cannot create additional pixmaps");
+
+#endif /* !USE_SDL_LIBRARY */
+