Skip to content

Commit 0d7aa66

Browse files
committed
Better error handling for glGetString(GL_VERSION)
1 parent b98e4e8 commit 0d7aa66

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

impl/gui/gl/src/gui_gl_renderer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ renderer::renderer(const vector2ui& window_dimensions, bool init_glew [[maybe_un
5353
}
5454

5555
std::string renderer::get_name() const {
56-
std::string full_version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
56+
const char* gl_version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
57+
if (gl_version == nullptr) {
58+
throw gui::exception("Cannot get OpenGL version; check that an OpenGL context exists");
59+
}
60+
61+
std::string full_version = gl_version;
5762
#if defined(LXGUI_OPENGL3)
5863
# if defined(LXGUI_COMPILER_EMSCRIPTEN)
5964
return "WebGL (" + full_version + ")";

0 commit comments

Comments
 (0)