From 74712a4e193cd7aa562e183626c7881eeb3ec48e Mon Sep 17 00:00:00 2001 From: Allanis Date: Mon, 13 Nov 2017 21:08:14 +0000 Subject: [PATCH] [Change] Use 24-bit depth buffer where possible. --- src/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e80af8e..8d95fe9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,15 +74,20 @@ void L3D::Init(IniConfig& config) { fprintf(stderr, "Fatal error: Invalid screen depth in config.ini.\n"); L3D::Quit(); } - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); Uint32 flags = SDL_OPENGL; if(config.Int("StartFullscreen")) flags |= SDL_FULLSCREEN; if((L3D::scrSurface = SDL_SetVideoMode(width, height, info->vfmt->BitsPerPixel, flags)) == 0) { - fprintf(stderr, "Video mode set failed: %s\n", SDL_GetError()); - exit(-1); + /* Fall back to 16-bit depth buffer.. */ + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + fprintf(stderr,"Failed to set video mode. (%s). Re-trying with 16 bit depth buffer.\n",SDL_GetError()); + if((L3D::scrSurface = SDL_SetVideoMode(width, height, info->vfmt->BitsPerPixel, flags)) == 0) { + fprintf(stderr, "video mode set failed: %s\n", SDL_GetError()); + exit(-1); + } } L3D::scrWidth = width;