comparison gldragon.cpp @ 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
comparison
equal deleted inserted replaced
52:6343c3392a95 53:d871e4b24328
45 #define DM_GLEXT_INIT(extproctype, extprocname) extproctype extprocname = NULL; 45 #define DM_GLEXT_INIT(extproctype, extprocname) extproctype extprocname = NULL;
46 #include "dmglexts.h" 46 #include "dmglexts.h"
47 #undef DM_GLEXT_INIT 47 #undef DM_GLEXT_INIT
48 48
49 49
50 bool dmGLCheckExtension(const std::string &name) 50 void dmGLCheckExtension(const std::string &name, bool &status)
51 { 51 {
52 bool res = SDL_GL_ExtensionSupported("GL_ARB_shader_objects"); 52 if (!SDL_GL_ExtensionSupported(name.c_str()))
53 dmMsg(" - Have '%s'? %s\n", 53 {
54 name.c_str(), 54 status = false;
55 res ? "YES" : "no"); 55 dmMsg(" - '%s' NOT supported.\n",
56 return res; 56 name.c_str());
57 }
57 } 58 }
58 59
59 60
60 void * dmGLGetProcAddr(const std::string &name) 61 void * dmGLGetProcAddr(const std::string &name)
61 { 62 {
62 void *ptr = SDL_GL_GetProcAddress(name.c_str()); 63 void *ptr = SDL_GL_GetProcAddress(name.c_str());
63 64
64 dmMsg(" - Have '%s'? %s\n", 65 if (ptr == NULL)
65 name.c_str(), 66 dmMsg(" - '%s' NOT supported.\n");
66 ptr != NULL ? "YES" : "no");
67 67
68 return ptr; 68 return ptr;
69 } 69 }
70 70
71 71
75 bool ok = 75 bool ok =
76 (ptr = dmGLGetProcAddr(name)) != NULL || 76 (ptr = dmGLGetProcAddr(name)) != NULL ||
77 (ptr = dmGLGetProcAddr(name + "EXT")) != NULL || 77 (ptr = dmGLGetProcAddr(name + "EXT")) != NULL ||
78 (ptr = dmGLGetProcAddr(name + "ARB")) != NULL; 78 (ptr = dmGLGetProcAddr(name + "ARB")) != NULL;
79 79
80
81 if (!ok) 80 if (!ok)
82 status = false; 81 status = false;
83 82
84 return ptr; 83 return ptr;
85 } 84 }
86 #endif 85 #endif
87 86
88 87
89 bool dmInitGLExtensions(void) 88 bool dmInitGLExtensions(void)
90 { 89 {
91 #ifdef GL_GLEXT_PROTOTYPES
92 return true;
93 #else
94 bool status = true; 90 bool status = true;
95
96 dmMsg("Checking for required OpenGL extensions ..\n"); 91 dmMsg("Checking for required OpenGL extensions ..\n");
97 92
98 if (!dmGLCheckExtension("GL_ARB_shader_objects") || 93 #ifndef GL_GLEXT_PROTOTYPES
99 !dmGLCheckExtension("GL_ARB_shading_language_100") || 94 dmGLCheckExtension("GL_ARB_shader_objects", status);
100 !dmGLCheckExtension("GL_ARB_vertex_shader") || 95 dmGLCheckExtension("GL_ARB_shading_language_100", status);
101 !dmGLCheckExtension("GL_ARB_fragment_shader")) 96 dmGLCheckExtension("GL_ARB_vertex_shader", status);
102 { 97 dmGLCheckExtension("GL_ARB_fragment_shader", status);
103 dmError("Required OpenGL extensions not supported.\n"); 98 if (!status)
99 {
100 dmError("One or more of the required OpenGL extensions not supported.\n");
104 return false; 101 return false;
105 } 102 }
106 103
107 #define DM_GLEXT_INIT(extproctype, extprocname) \ 104 #define DM_GLEXT_INIT(extproctype, extprocname) \
108 extprocname = (extproctype) dmGLExtInit(#extprocname, status); 105 extprocname = (extproctype) dmGLExtInit(#extprocname, status);
109 #include "dmglexts.h" 106 #include "dmglexts.h"
107 #endif
108
110 return status; 109 return status;
111 #endif
112 } 110 }
113 111
114 112
115 bool dmInitSDLGL(const int width, const int height, const char *title) 113 bool dmInitSDLGL(const int width, const int height, const char *title)
116 { 114 {