← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1536377-fail-gracefully-on-graphics-driver-problems into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1536377-fail-gracefully-on-graphics-driver-problems into lp:widelands.

Commit message:
Show a basic SDL error message box to the user if the shading language can't be detected or is too old.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1536377 in widelands: "Appveyor builds: The texture atlas must use at least 2048 as size (1024 was given)"
  https://bugs.launchpad.net/widelands/+bug/1536377

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1536377-fail-gracefully-on-graphics-driver-problems/+merge/355757

Some UI feedback for the user if we can't work with what the graphics driver is giving us.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1536377-fail-gracefully-on-graphics-driver-problems into lp:widelands.
=== modified file 'src/graphic/gl/initialize.cc'
--- src/graphic/gl/initialize.cc	2018-09-10 06:11:01 +0000
+++ src/graphic/gl/initialize.cc	2018-09-27 09:32:24 +0000
@@ -20,6 +20,7 @@
 #include "graphic/gl/initialize.h"
 
 #include <csignal>
+#include <cstdlib>
 
 #include <SDL.h>
 
@@ -177,8 +178,30 @@
 	glGetIntegerv(GL_MAX_TEXTURE_SIZE, max_texture_size);
 	log("Graphics: OpenGL: Max texture size: %u\n", *max_texture_size);
 
-	log("Graphics: OpenGL: ShadingLanguage: \"%s\"\n",
-	    reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
+	// TODO(GunChleoc): Localize the on-screen error messages
+	// Exit if we can't detect the shading language version
+	const char* const shading_language_version_string = reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION));
+	if (!strcmp(shading_language_version_string, "(null)")) {
+		log("ERROR: Unable to detect the shading language version!\n");
+		SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
+								 "OpenGL Error",
+								 "Widelands won’t work because we were unable to detect the shading language version – there is an unknown problem with reading the information from the graphics driver.",
+								 NULL);
+		exit(1);
+	}
+
+	log("Graphics: OpenGL: ShadingLanguage: \"%s\"\n", shading_language_version_string);
+
+	// Exit if the shading language version is too old
+	const double shading_language_version = atof(shading_language_version_string);
+	if (shading_language_version < 1.20) {
+		log("ERROR: Shading language version is too old!\n");
+		SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
+								 "OpenGL Error",
+								 "Widelands won’t work because your graphics driver is too old.",
+								 NULL);
+		exit(1);
+	}
 
 	glDrawBuffer(GL_BACK);
 


Follow ups