diff --git a/Userland/Libraries/LibGL/GLContext.cpp b/Userland/Libraries/LibGL/GLContext.cpp index ac71d8f5071..4c8f7dc9774 100644 --- a/Userland/Libraries/LibGL/GLContext.cpp +++ b/Userland/Libraries/LibGL/GLContext.cpp @@ -5,6 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include "GLContext.h" #include "SoftwareGLContext.h" #include diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index 0bad6be594a..3faf9f5c93c 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -14,6 +14,16 @@ namespace GL { +#define VERIFY_CURRENT_CONTEXT() \ + if (!g_gl_context) { \ + return; \ + } + +#define VERIFY_CURRENT_CONTEXT_OR_VALUE(value) \ + if (!g_gl_context) { \ + return value; \ + } + class GLContext { public: virtual ~GLContext(); diff --git a/Userland/Libraries/LibGL/GLUtils.cpp b/Userland/Libraries/LibGL/GLUtils.cpp index b580730c727..253d2f4caec 100644 --- a/Userland/Libraries/LibGL/GLUtils.cpp +++ b/Userland/Libraries/LibGL/GLUtils.cpp @@ -67,6 +67,7 @@ void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) GLenum glGetError() { + VERIFY_CURRENT_CONTEXT_OR_VALUE(GL_NONE); return g_gl_context->gl_get_error(); } @@ -117,6 +118,7 @@ void glGetFloatv(GLenum pname, GLfloat* params) void glGetIntegerv(GLenum pname, GLint* data) { + VERIFY_CURRENT_CONTEXT(); g_gl_context->gl_get_integerv(pname, data); }