|
|
|
@ -35,7 +35,7 @@
|
|
|
|
|
|
|
|
|
|
static FVideoDriver_SDL iFVideoDriver_SDL;
|
|
|
|
|
|
|
|
|
|
static SDL_Surface *_sdl_screen;
|
|
|
|
|
static SDL_Surface *_sdl_surface;
|
|
|
|
|
static SDL_Surface *_sdl_realscreen;
|
|
|
|
|
static bool _all_modes;
|
|
|
|
|
|
|
|
|
@ -77,11 +77,11 @@ static void UpdatePalette(bool init = false)
|
|
|
|
|
pal[i].unused = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_SetColors(_sdl_screen, pal, _local_palette.first_dirty, _local_palette.count_dirty);
|
|
|
|
|
SDL_SetColors(_sdl_surface, pal, _local_palette.first_dirty, _local_palette.count_dirty);
|
|
|
|
|
|
|
|
|
|
if (_sdl_screen != _sdl_realscreen && init) {
|
|
|
|
|
if (_sdl_surface != _sdl_realscreen && init) {
|
|
|
|
|
/* When using a shadow surface, also set our palette on the real screen. This lets SDL
|
|
|
|
|
* allocate as much colors (or approximations) as
|
|
|
|
|
* allocate as many colors (or approximations) as
|
|
|
|
|
* possible, instead of using only the default SDL
|
|
|
|
|
* palette. This allows us to get more colors exactly
|
|
|
|
|
* right and might allow using better approximations for
|
|
|
|
@ -103,7 +103,7 @@ static void UpdatePalette(bool init = false)
|
|
|
|
|
SDL_SetColors(_sdl_realscreen, pal, _local_palette.first_dirty, _local_palette.count_dirty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_sdl_screen != _sdl_realscreen && !init) {
|
|
|
|
|
if (_sdl_surface != _sdl_realscreen && !init) {
|
|
|
|
|
/* We're not using real hardware palette, but are letting SDL
|
|
|
|
|
* approximate the palette during shadow -> screen copy. To
|
|
|
|
|
* change the palette, we need to recopy the entire screen.
|
|
|
|
@ -114,7 +114,7 @@ static void UpdatePalette(bool init = false)
|
|
|
|
|
* best mapping of shadow palette colors to real palette
|
|
|
|
|
* colors from scratch.
|
|
|
|
|
*/
|
|
|
|
|
SDL_BlitSurface(_sdl_screen, nullptr, _sdl_realscreen, nullptr);
|
|
|
|
|
SDL_BlitSurface(_sdl_surface, nullptr, _sdl_realscreen, nullptr);
|
|
|
|
|
SDL_UpdateRect(_sdl_realscreen, 0, 0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -159,17 +159,20 @@ static void DrawSurfaceToScreen()
|
|
|
|
|
if (n == 0) return;
|
|
|
|
|
|
|
|
|
|
_num_dirty_rects = 0;
|
|
|
|
|
|
|
|
|
|
if (n > MAX_DIRTY_RECTS) {
|
|
|
|
|
if (_sdl_screen != _sdl_realscreen) {
|
|
|
|
|
SDL_BlitSurface(_sdl_screen, nullptr, _sdl_realscreen, nullptr);
|
|
|
|
|
if (_sdl_surface != _sdl_realscreen) {
|
|
|
|
|
SDL_BlitSurface(_sdl_surface, nullptr, _sdl_realscreen, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_UpdateRect(_sdl_realscreen, 0, 0, 0, 0);
|
|
|
|
|
} else {
|
|
|
|
|
if (_sdl_screen != _sdl_realscreen) {
|
|
|
|
|
if (_sdl_surface != _sdl_realscreen) {
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
SDL_BlitSurface(_sdl_screen, &_dirty_rects[i], _sdl_realscreen, &_dirty_rects[i]);
|
|
|
|
|
SDL_BlitSurface(_sdl_surface, &_dirty_rects[i], _sdl_realscreen, &_dirty_rects[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_UpdateRects(_sdl_realscreen, n, _dirty_rects);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -312,7 +315,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
|
|
|
|
|
if (want_hwpalette) DEBUG(driver, 1, "SDL: requesting hardware palette");
|
|
|
|
|
|
|
|
|
|
/* Free any previously allocated shadow surface */
|
|
|
|
|
if (_sdl_screen != nullptr && _sdl_screen != _sdl_realscreen) SDL_FreeSurface(_sdl_screen);
|
|
|
|
|
if (_sdl_surface != nullptr && _sdl_surface != _sdl_realscreen) SDL_FreeSurface(_sdl_surface);
|
|
|
|
|
|
|
|
|
|
if (_sdl_realscreen != nullptr) {
|
|
|
|
|
if (_requested_hwpalette != want_hwpalette) {
|
|
|
|
@ -379,7 +382,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
|
|
|
|
|
_screen.height = newscreen->h;
|
|
|
|
|
_screen.pitch = newscreen->pitch / (bpp / 8);
|
|
|
|
|
_screen.dst_ptr = newscreen->pixels;
|
|
|
|
|
_sdl_screen = newscreen;
|
|
|
|
|
_sdl_surface = newscreen;
|
|
|
|
|
|
|
|
|
|
/* When in full screen, we will always have the mouse cursor
|
|
|
|
|
* within the window, even though SDL does not give us the
|
|
|
|
@ -614,7 +617,7 @@ const char *VideoDriver_SDL::Start(const StringList &parm)
|
|
|
|
|
} else if (SDL_WasInit(SDL_INIT_VIDEO) == 0) {
|
|
|
|
|
ret_code = SDL_InitSubSystem(SDL_INIT_VIDEO);
|
|
|
|
|
}
|
|
|
|
|
if (ret_code == -1) return SDL_GetError();
|
|
|
|
|
if (ret_code < 0) return SDL_GetError();
|
|
|
|
|
|
|
|
|
|
GetVideoModes();
|
|
|
|
|
if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {
|
|
|
|
|