shithub: choc

Download patch

ref: e82b4c186cc1f2e65414c211c3db9c84bd2c3cdf
parent: f90f95af2624c933a49d94874e677e2d8768282e
author: Jonathan Dowland <jon+github@alcopop.org>
date: Tue Jul 12 13:47:35 EDT 2016

Add CheckGLVersion to warn about software GL

Performance with a software GL implementation is not great. Check
the GL_VERSION string and warn about possible performance problems
if we find "Mesa", suggesting hardware acceleration is not
available.

Additional LDFLAGS are needed for OS X when using SDL_opengl.h,
adjust configure.ac accordingly.

Fixes #741.

--- a/configure.ac
+++ b/configure.ac
@@ -39,6 +39,13 @@
 PKG_CHECK_MODULES(SDLNET, [SDL2_net >= 2.0.0])
 PKG_CHECK_MODULES(SDLIMAGE, [SDL2_image >= 2.0.0])
 
+# Additional LDFLAGS for OS X are required for OpenGL
+case "$host" in
+  *-darwin*)
+    LDFLAGS="$LDFLAGS -framework OpenGL"
+    ;;
+esac
+
 # Check for libsamplerate.
 AC_ARG_WITH([libsamplerate],
 AS_HELP_STRING([--without-libsamplerate],
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -19,6 +19,7 @@
 
 #include "SDL.h"
 #include "SDL_image.h"
+#include "SDL_opengl.h"
 
 #ifdef _WIN32
 #define WIN32_LEAN_AND_MEAN
@@ -1147,6 +1148,23 @@
     CreateUpscaledTexture();
 }
 
+static const char *hw_emu_warning = 
+"===========================================================================\n"
+"WARNING: it looks like you are using a software GL implementation.\n"
+"To improve performance, try setting force_software_renderer in your\n"
+"configuration file.\n"
+"===========================================================================\n";
+
+static void CheckGLVersion(void)
+{
+    const GLubyte* version = glGetString(GL_VERSION);
+
+    if (version && strstr((const char *)version, "Mesa"))
+    {
+        printf("%s", hw_emu_warning);
+    }
+}
+
 void I_InitGraphics(void)
 {
     SDL_Event dummy;
@@ -1188,6 +1206,10 @@
     // on configuration.
     AdjustWindowSize();
     SetVideoMode();
+
+    // We might have poor performance if we are using an emulated
+    // HW accelerator. Check for Mesa and warn if we're using it.
+    CheckGLVersion();
 
     // Start with a clear black screen
     // (screen will be flipped after we set the palette)