extensions.insert(exts.begin(), exts.end());
}
- string renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
- if(renderer.find("Radeon")!=string::npos || renderer.find("AMD")!=string::npos)
+ if(const char *renderer_ptr = reinterpret_cast<const char *>(glGetString(GL_RENDERER)))
{
- /* Radeon doesn't process NV_primitive_restart correctly and treats
- the restart index as a normal element if the indices are stored in a
- buffer. */
- extensions.erase("GL_NV_primitive_restart");
-
- /* AMD's uniform buffer objects only work with the core version of
- shaders. */
- if(!(get_gl_version()>=Version(2, 0)))
- extensions.erase("GL_ARB_uniform_buffer_object");
+ string renderer = renderer_ptr;
+ if(renderer.find("Radeon")!=string::npos || renderer.find("AMD")!=string::npos)
+ {
+ /* Radeon doesn't process NV_primitive_restart correctly and treats
+ the restart index as a normal element if the indices are stored in a
+ buffer. */
+ extensions.erase("GL_NV_primitive_restart");
+
+ /* AMD's uniform buffer objects only work with the core version of
+ shaders. */
+ if(!(get_gl_version()>=Version(2, 0)))
+ extensions.erase("GL_ARB_uniform_buffer_object");
+ }
}
if(const char *disable_ptr = getenv("MSPGL_DISABLE_EXTENSIONS"))
inline Version _get_gl_version()
{
- string gl_ver = reinterpret_cast<const char *>(glGetString(GL_VERSION));
+ const char *gl_ver_ptr = reinterpret_cast<const char *>(glGetString(GL_VERSION));
+ if(!gl_ver_ptr)
+ throw runtime_error("OpenGL version not available");
+
+ string gl_ver = gl_ver_ptr;
if(!gl_ver.compare(0, 10, "OpenGL ES "))
gl_ver.erase(0, 10);
inline Version _get_glsl_version()
{
- string glsl_ver = reinterpret_cast<const char *>(glGetString(GL_SHADING_LANGUAGE_VERSION));
+ const char *glsl_ver_ptr = reinterpret_cast<const char *>(glGetString(GL_SHADING_LANGUAGE_VERSION));
+ if(!glsl_ver_ptr)
+ throw runtime_error("GLSL version not available");
+
+ string glsl_ver = glsl_ver_ptr;
if(!glsl_ver.compare(0, 18, "OpenGL ES GLSL ES "))
glsl_ver.erase(0, 18);