changeset 53:d871e4b24328

Be less verbose when checking for GL extensions, only inform when something is NOT found.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 Dec 2019 19:21:24 +0200
parents 6343c3392a95
children 73fa5fb437a0
files gldragon.cpp
diffstat 1 files changed, 18 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/gldragon.cpp	Fri Dec 06 19:09:47 2019 +0200
+++ b/gldragon.cpp	Fri Dec 06 19:21:24 2019 +0200
@@ -47,13 +47,14 @@
 #undef DM_GLEXT_INIT
 
 
-bool dmGLCheckExtension(const std::string &name)
+void dmGLCheckExtension(const std::string &name, bool &status)
 {
-    bool res = SDL_GL_ExtensionSupported("GL_ARB_shader_objects");
-    dmMsg(" - Have '%s'? %s\n",
-        name.c_str(),
-        res ? "YES" : "no");
-    return res;
+    if (!SDL_GL_ExtensionSupported(name.c_str()))
+    {
+        status = false;
+        dmMsg(" - '%s' NOT supported.\n",
+            name.c_str());
+    }
 }
 
 
@@ -61,9 +62,8 @@
 {
     void *ptr = SDL_GL_GetProcAddress(name.c_str());
 
-    dmMsg(" - Have '%s'? %s\n",
-        name.c_str(),
-        ptr != NULL ? "YES" : "no");
+    if (ptr == NULL)
+        dmMsg(" - '%s' NOT supported.\n");
 
     return ptr;
 }
@@ -77,7 +77,6 @@
         (ptr = dmGLGetProcAddr(name + "EXT")) != NULL ||
         (ptr = dmGLGetProcAddr(name + "ARB")) != NULL;
 
-
     if (!ok)
         status = false;
 
@@ -88,27 +87,26 @@
 
 bool dmInitGLExtensions(void)
 {
-#ifdef GL_GLEXT_PROTOTYPES
-    return true;
-#else
     bool status = true;
-
     dmMsg("Checking for required OpenGL extensions ..\n");
 
-    if (!dmGLCheckExtension("GL_ARB_shader_objects") ||
-        !dmGLCheckExtension("GL_ARB_shading_language_100") ||
-        !dmGLCheckExtension("GL_ARB_vertex_shader") ||
-        !dmGLCheckExtension("GL_ARB_fragment_shader"))
+#ifndef GL_GLEXT_PROTOTYPES
+    dmGLCheckExtension("GL_ARB_shader_objects", status);
+    dmGLCheckExtension("GL_ARB_shading_language_100", status);
+    dmGLCheckExtension("GL_ARB_vertex_shader", status);
+    dmGLCheckExtension("GL_ARB_fragment_shader", status);
+    if (!status)
     {
-        dmError("Required OpenGL extensions not supported.\n");
+        dmError("One or more of the required OpenGL extensions not supported.\n");
         return false;
     }
 
 #define DM_GLEXT_INIT(extproctype, extprocname) \
     extprocname = (extproctype) dmGLExtInit(#extprocname, status);
 #include "dmglexts.h"
+#endif
+
     return status;
-#endif
 }