Skip to content

Commit

Permalink
Encourage 32bpp mode when going fullscreen
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LionsPhil committed Mar 19, 2016
1 parent 9cc77bc commit 9ae6a3a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ strangelp_SOURCES = \
main.cpp \
modconfig.cpp \
resource.h \
sais_version.h \
scaledvideo.cpp \
scaledvideo.hpp \
sdl_iface.cpp \
Expand Down
13 changes: 10 additions & 3 deletions src/sdl_iface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 2 additions & 3 deletions src/sdl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "typedefs.h"
#include "gfx.h"
#include "scaledvideo.hpp"
#include "sais_version.h"

int my_main();
int sound_init();
Expand All @@ -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)
{
Expand Down

0 comments on commit 9ae6a3a

Please sign in to comment.