#endif
}
-void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window,
- boolean fullscreen)
+void SDLInitVideoBuffer(boolean fullscreen)
{
video.window_scaling_percent = setup.window_scaling_percent;
video.window_scaling_quality = setup.window_scaling_quality;
#endif
/* open SDL video output device (window or fullscreen mode) */
- if (!SDLSetVideoMode(backbuffer, fullscreen))
+ if (!SDLSetVideoMode(fullscreen))
Error(ERR_EXIT, "setting video mode failed");
/* !!! SDL2 can only set the window icon if the window already exists !!! */
should never be drawn to directly, it would do no harm nevertheless. */
/* create additional (symbolic) buffer for double-buffering */
- ReCreateBitmap(window, video.width, video.height, video.depth);
+ ReCreateBitmap(&window, video.width, video.height, video.depth);
}
-static SDL_Surface *SDLCreateScreen(DrawBuffer **backbuffer,
- boolean fullscreen)
+static boolean SDLCreateScreen(boolean fullscreen)
{
SDL_Surface *new_surface = NULL;
video.window_width = window_scaling_factor * width;
video.window_height = window_scaling_factor * height;
- if ((*backbuffer)->surface)
- {
- SDL_FreeSurface((*backbuffer)->surface);
- (*backbuffer)->surface = NULL;
- }
-
#if USE_TARGET_TEXTURE
if (sdl_texture_stream)
{
new_surface = SDL_CreateRGBSurface(0, width, height, 32, 0,0,0, 0);
if (new_surface == NULL)
- Error(ERR_WARN, "SDL_CreateRGBSurface() failed: %s",
- SDL_GetError());
+ Error(ERR_WARN, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
}
else
{
Error(ERR_WARN, "SDL_CreateWindow() failed: %s", SDL_GetError());
}
-#else
- new_surface = SDL_SetVideoMode(width, height, video.depth, surface_flags);
+#else // TARGET_SDL
+
+ if (gfx.final_screen_bitmap == NULL)
+ gfx.final_screen_bitmap = CreateBitmapStruct();
+
+ gfx.final_screen_bitmap->width = width;
+ gfx.final_screen_bitmap->height = height;
+
+ gfx.final_screen_bitmap->surface =
+ SDL_SetVideoMode(width, height, video.depth, surface_flags);
+
+ if (gfx.final_screen_bitmap->surface != NULL)
+ {
+ new_surface =
+ SDL_CreateRGBSurface(surface_flags, width, height, video.depth, 0,0,0, 0);
+
+ if (new_surface == NULL)
+ Error(ERR_WARN, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+
+#if 0
+ new_surface = gfx.final_screen_bitmap->surface;
+ gfx.final_screen_bitmap = NULL;
+#endif
+
+ }
+ else
+ {
+ Error(ERR_WARN, "SDL_SetVideoMode() failed: %s", SDL_GetError());
+ }
#endif
#if defined(TARGET_SDL2)
fullscreen_enabled = fullscreen;
#endif
- return new_surface;
+ if (backbuffer == NULL)
+ backbuffer = CreateBitmapStruct();
+
+ backbuffer->width = video.width;
+ backbuffer->height = video.height;
+
+ if (backbuffer->surface)
+ SDL_FreeSurface(backbuffer->surface);
+
+ backbuffer->surface = new_surface;
+
+ return (new_surface != NULL);
}
-boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
+boolean SDLSetVideoMode(boolean fullscreen)
{
- boolean success = TRUE;
- SDL_Surface *new_surface = NULL;
+ boolean success = FALSE;
SetWindowTitle();
- if (*backbuffer == NULL)
- *backbuffer = CreateBitmapStruct();
-
- /* (real bitmap might be larger in fullscreen mode with video offsets) */
- (*backbuffer)->width = video.width;
- (*backbuffer)->height = video.height;
-
if (fullscreen && !video.fullscreen_enabled && video.fullscreen_available)
{
/* switch display to fullscreen mode, if available */
- new_surface = SDLCreateScreen(backbuffer, TRUE);
+ success = SDLCreateScreen(TRUE);
- if (new_surface == NULL)
+ if (!success)
{
- /* switching display to fullscreen mode failed */
- Error(ERR_WARN, "SDL_SetVideoMode() failed: %s", SDL_GetError());
-
- /* do not try it again */
+ /* switching display to fullscreen mode failed -- do not try it again */
video.fullscreen_available = FALSE;
-
- success = FALSE;
}
else
{
- (*backbuffer)->surface = new_surface;
-
video.fullscreen_enabled = TRUE;
-
- success = TRUE;
}
}
- if ((!fullscreen && video.fullscreen_enabled) || new_surface == NULL)
+ if ((!fullscreen && video.fullscreen_enabled) || !success)
{
/* switch display to window mode */
- new_surface = SDLCreateScreen(backbuffer, FALSE);
+ success = SDLCreateScreen(FALSE);
- if (new_surface == NULL)
+ if (!success)
{
/* switching display to window mode failed -- should not happen */
- Error(ERR_WARN, "SDL_SetVideoMode() failed: %s", SDL_GetError());
-
- success = FALSE;
}
else
{
- (*backbuffer)->surface = new_surface;
-
video.fullscreen_enabled = FALSE;
video.window_scaling_percent = setup.window_scaling_percent;
video.window_scaling_quality = setup.window_scaling_quality;
-
- success = TRUE;
}
}
src_bitmap->surface_masked : src_bitmap->surface),
&src_rect, real_dst_bitmap->surface, &dst_rect);
-#if defined(TARGET_SDL2)
if (dst_bitmap == window)
- {
- // SDL_UpdateWindowSurface(sdl_window);
- // SDL_UpdateWindowSurfaceRects(sdl_window, &dst_rect, 1);
UpdateScreen(&dst_rect);
- }
-#else
- if (dst_bitmap == window)
- {
- // SDL_UpdateRect(backbuffer->surface, dst_x, dst_y, width, height);
- UpdateScreen(&dst_rect);
- }
-#endif
}
void SDLBlitTexture(Bitmap *bitmap,
SDL_FillRect(real_dst_bitmap->surface, &rect, color);
-#if defined(TARGET_SDL2)
if (dst_bitmap == window)
- {
- // SDL_UpdateWindowSurface(sdl_window);
- // SDL_UpdateWindowSurfaceRects(sdl_window, &rect, 1);
UpdateScreen(&rect);
- }
-#else
- if (dst_bitmap == window)
- {
- // SDL_UpdateRect(backbuffer->surface, x, y, width, height);
- UpdateScreen(&rect);
- }
-#endif
}
void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height,