← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1817686-SDL-pixel-format into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1817686-SDL-pixel-format into lp:widelands.

Commit message:
Fail with SDL messagebox if SDL_BYTESPERPIXEL != 4

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1817686 in widelands: "Assert fail in Graphic::initialize"
  https://bugs.launchpad.net/widelands/+bug/1817686

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1817686-SDL-pixel-format/+merge/363729
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1817686-SDL-pixel-format into lp:widelands.
=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc	2019-02-23 11:00:49 +0000
+++ src/graphic/graphic.cc	2019-02-27 14:22:14 +0000
@@ -114,6 +114,15 @@
 		    " size %d %d\n"
 		    "**** END GRAPHICS REPORT ****\n",
 		    SDL_GetCurrentVideoDriver(), disp_mode.format, disp_mode.w, disp_mode.h);
+		const int bytes_per_pixel = SDL_BYTESPERPIXEL(disp_mode.format);
+		if (bytes_per_pixel != 4) {
+			log("ERROR: Wrong SDL_BYTESPERPIXEL, expected 4 but got %d\n", bytes_per_pixel);
+			SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Video Error",
+			                         (boost::format("SDL should report 4 bytes per pixel, but %d were reported instead.\n\nPlease check that everything's OK with your graphics driver.") % bytes_per_pixel).str().c_str(),
+			                         nullptr);
+			exit(1);
+
+		}
 		assert(SDL_BYTESPERPIXEL(disp_mode.format) == 4);
 	}
 


Follow ups