From 9ae6a3afdb80959cc6eb6cf8498415f321a0cf49 Mon Sep 17 00:00:00 2001 From: LionsPhil Date: Sat, 19 Mar 2016 12:55:47 +0000 Subject: [PATCH] Encourage 32bpp mode when going fullscreen Works around problems on my Win7/nVidia box, where it will merrily go "sure, I can do 8bpp fullscreen modes", then screw up the palette. I doubt I'm alone in this, and the arbitrary converting scaler is fast enough. Fix sais_version.h header being missing from automakefile last commit. --- src/Makefile.am | 1 + src/sdl_iface.cpp | 13 ++++++++++--- src/sdl_main.cpp | 5 ++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index b008837..848091e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,6 +23,7 @@ strangelp_SOURCES = \ main.cpp \ modconfig.cpp \ resource.h \ + sais_version.h \ scaledvideo.cpp \ scaledvideo.hpp \ sdl_iface.cpp \ diff --git a/src/sdl_iface.cpp b/src/sdl_iface.cpp index bd45a6c..66809cb 100644 --- a/src/sdl_iface.cpp +++ b/src/sdl_iface.cpp @@ -294,25 +294,32 @@ void ik_hidecursor() } void gfx_resize() { - int w, h; + int w, h, bpp; int flags = SDL_SWSURFACE | SDL_HWPALETTE; ScaledVideo* old_scaler = g_scaled_video; if(gfx_fullscreen) { w = g_native_resolution.w; h = g_native_resolution.h; - // Add ANYFORMAT since we don't want to *force* 8bpp + /* Some systems, even with ANYFORMAT, will drop to 8bpp if they + * think they can support it, but then screw up the palette (I + * guess it's not a focus of graphics driver testing any more!). + * So ask for 32bpp and eat a possible inefficiency. Flag + * SDL_ANYFORMAT so if we're on a machine that can only do 8bpp, + * somehow, we still at least try. */ + bpp = 32; flags |= SDL_FULLSCREEN | SDL_ANYFORMAT; } else { w = gfx_window_width; h = gfx_window_height; if(w < gfx_width ) { w = gfx_width; } if(h < gfx_height) { h = gfx_height; } + bpp = 8; // window should be able to provide this flags |= SDL_RESIZABLE; } try { - g_scaled_video = get_scaled_video(sdlsurf, w, h, 8, flags); + g_scaled_video = get_scaled_video(sdlsurf, w, h, bpp, flags); delete old_scaler; diff --git a/src/sdl_main.cpp b/src/sdl_main.cpp index 6b0a12f..8d358cd 100644 --- a/src/sdl_main.cpp +++ b/src/sdl_main.cpp @@ -6,6 +6,7 @@ #include "typedefs.h" #include "gfx.h" #include "scaledvideo.hpp" +#include "sais_version.h" int my_main(); int sound_init(); @@ -25,10 +26,8 @@ int main(int argc, char *argv[]) c_maxx=gfx_width; c_maxy=gfx_height; -#ifndef WINDOWS - fprintf(stderr, "Strange Adventures in Infinite Space\n"); + fprintf(stderr, "Strange Adventures in Infinite Space - v" SAIS_VERSION_STRING "\n"); fprintf(stderr, "Unofficial fork by Philip Boulain et. al. (see README.md)\n"); -#endif if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO) < 0) {