+
+inline void InitEventFilter(EventFilter filter_function)
+{
+#ifdef USE_SDL_LIBRARY
+ /* set event filter to filter out certain events */
+ SDL_SetEventFilter(filter_function);
+#endif
+}
+
+inline void InitBufferedDisplay(DrawBuffer *backbuffer, DrawWindow *window)
+{
+#ifdef USE_SDL_LIBRARY
+ SDLInitBufferedDisplay(backbuffer, window);
+#else
+ X11InitBufferedDisplay(backbuffer, window);
+#endif
+}
+
+inline int GetDisplayDepth(void)
+{
+#ifdef USE_SDL_LIBRARY
+ return SDL_GetVideoSurface()->format->BitsPerPixel;
+#else
+ return XDefaultDepth(display, screen);
+#endif
+}
+
+inline Bitmap CreateBitmap(int width, int height, int depth)
+{
+ int real_depth = (depth == DEFAULT_DEPTH ? GetDisplayDepth() : depth);
+
+#ifdef USE_SDL_LIBRARY
+ SDL_Surface *surface_tmp, *surface_native;
+
+ if ((surface_tmp = SDL_CreateRGBSurface(SURFACE_FLAGS, width, height,
+ real_depth, 0, 0, 0, 0))
+ == NULL)
+ Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+
+ if ((surface_native = SDL_DisplayFormat(surface_tmp)) == NULL)
+ Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
+
+ SDL_FreeSurface(surface_tmp);
+
+ return surface_native;
+#else
+ Pixmap pixmap;
+
+ if (!(pixmap = XCreatePixmap(display, window, width, height, real_depth)))
+ Error(ERR_EXIT, "cannot create pixmap");
+
+ return pixmap;
+#endif
+}