+/* functions from SGE library */
+void sge_Line(SDL_Surface *, Sint16, Sint16, Sint16, Sint16, Uint32);
+
+static void UpdateScreen(SDL_Rect *rect)
+{
+#if 1
+ SDL_Surface *screen = backbuffer->surface;
+
+ SDL_UpdateTexture(sdl_texture, NULL, screen->pixels, screen->pitch);
+ SDL_RenderClear(sdl_renderer);
+ SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL);
+ SDL_RenderPresent(sdl_renderer);
+#else
+ if (rect)
+ SDL_UpdateWindowSurfaceRects(sdl_window, rect, 1);
+ else
+ SDL_UpdateWindowSurface(sdl_window);
+#endif
+}
+
+static void setFullscreenParameters(char *fullscreen_mode_string)
+{
+ struct ScreenModeInfo *fullscreen_mode;
+ int i;
+
+ fullscreen_mode = get_screen_mode_from_string(fullscreen_mode_string);
+
+ if (fullscreen_mode == NULL)
+ return;
+
+ for (i = 0; video.fullscreen_modes[i].width != -1; i++)
+ {
+ if (fullscreen_mode->width == video.fullscreen_modes[i].width &&
+ fullscreen_mode->height == video.fullscreen_modes[i].height)
+ {
+ fullscreen_width = fullscreen_mode->width;
+ fullscreen_height = fullscreen_mode->height;
+
+ fullscreen_xoffset = (fullscreen_width - video.width) / 2;
+ fullscreen_yoffset = (fullscreen_height - video.height) / 2;
+
+ break;
+ }
+ }
+}
+
+static void SDLSetWindowIcon(char *basename)
+{
+ /* (setting the window icon on Mac OS X would replace the high-quality
+ dock icon with the currently smaller (and uglier) icon from file) */
+
+#if !defined(PLATFORM_MACOSX)
+ char *filename = getCustomImageFilename(basename);
+ SDL_Surface *surface;
+
+ if (filename == NULL)
+ {
+ Error(ERR_WARN, "SDLSetWindowIcon(): cannot find file '%s'", basename);
+
+ return;
+ }
+
+ if ((surface = IMG_Load(filename)) == NULL)
+ {
+ Error(ERR_WARN, "IMG_Load() failed: %s", SDL_GetError());
+
+ return;
+ }
+
+ /* set transparent color */
+ SDL_SetColorKey(surface, SET_TRANSPARENT_PIXEL,
+ SDL_MapRGB(surface->format, 0x00, 0x00, 0x00));
+
+#if defined(TARGET_SDL2)
+ SDL_SetWindowIcon(sdl_window, surface);
+#else
+ SDL_WM_SetIcon(surface, NULL);
+#endif
+#endif
+}
+
+#if defined(TARGET_SDL2)
+SDL_Surface *SDL_DisplayFormat(SDL_Surface *surface)
+{
+ if (backbuffer == NULL ||
+ backbuffer->surface == NULL)
+ return NULL;
+
+ return SDL_ConvertSurface(surface, backbuffer->surface->format, 0);
+}
+#endif
+