ref: d5f12b2f2b2efd126c4b9b0ae8bc0b1b0acadd72
parent: cf8789f8879dc2e6ade1a273088a4b861de5ef86
author: Cameron Cawley <ccawley2011@gmail.com>
date: Mon May 18 18:57:47 EDT 2020
Add a fallback for when 24bpp screen modes are unsupported
--- a/src/Backends/Rendering/Window/Software/SDL1.cpp
+++ b/src/Backends/Rendering/Window/Software/SDL1.cpp
@@ -8,7 +8,8 @@
#include "../../../Misc.h"
-static Uint32 window_flags = SDL_HWSURFACE | SDL_DOUBLEBUF;
+static int bits_per_pixel = 24;
+static Uint32 window_flags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_ANYFORMAT;
static SDL_Surface *window_sdlsurface;
static SDL_Surface *framebuffer_sdlsurface;
@@ -20,7 +21,13 @@
else
window_flags &= ~SDL_FULLSCREEN;
- window_sdlsurface = SDL_SetVideoMode(screen_width, screen_height, 24, window_flags);
+ window_sdlsurface = SDL_SetVideoMode(screen_width, screen_height, bits_per_pixel, window_flags);
+ if (window_sdlsurface == NULL) {
+ Backend_PrintError("Couldn't create 24bpp window: %s", SDL_GetError());
+ bits_per_pixel = 32;
+ window_sdlsurface = SDL_SetVideoMode(screen_width, screen_height, bits_per_pixel, window_flags);
+ }
+
if (window_sdlsurface != NULL)
{
SDL_WM_SetCaption(window_title, NULL);
@@ -70,7 +77,7 @@
void WindowBackend_Software_HandleWindowResize(unsigned int width, unsigned int height)
{
- window_sdlsurface = SDL_SetVideoMode(width, height, 24, window_flags);
+ window_sdlsurface = SDL_SetVideoMode(width, height, bits_per_pixel, window_flags);
if (window_sdlsurface == NULL)
Backend_PrintError("Couldn't get SDL surface associated with window: %s", SDL_GetError());
}