mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 17:40:27 +00:00
LibGL: Support missing context in glGetError
and glGetIntegerv
In its current state, ScummVM seems to invoke these methods just after destroying the current GL context. According to the OpenGL spec: "Issuing GL commands when the program does not have a current context results in undefined behavior, up to and including program termination." Our old behavior was to deref a `nullptr`, which isn't that great. For now, protect these two methods. If other ports seem to misbehave as well, we can always expand the check to other methods.
This commit is contained in:
parent
a06b69c5b5
commit
b79642ef74
Notes:
sideshowbarker
2024-07-17 22:50:29 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/b79642ef742 Pull-request: https://github.com/SerenityOS/serenity/pull/11154 Reviewed-by: https://github.com/sunverwerth ✅
3 changed files with 13 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "GLContext.h"
|
||||
#include "SoftwareGLContext.h"
|
||||
#include <LibGfx/Bitmap.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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue