diff --git a/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp b/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp index cbb720e8ca..7528c547a5 100644 --- a/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp +++ b/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp @@ -195,8 +195,23 @@ Optional WebGLRenderingContextBase: }; } +// TODO: The glGetError spec allows for queueing errors which is something we should probably do, for now +// this just keeps track of one error which is also fine by the spec +GLenum WebGLRenderingContextBase::get_error_value() +{ + if (m_error == GL_NO_ERROR) + return glGetError(); + + auto error = m_error; + m_error = GL_NO_ERROR; + return error; +} + void WebGLRenderingContextBase::set_error(GLenum error) { + if (m_error != GL_NO_ERROR) + return; + auto context_error = glGetError(); if (context_error != GL_NO_ERROR) m_error = context_error; diff --git a/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h b/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h index f927d6da83..d062690f8c 100644 --- a/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h +++ b/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h @@ -138,6 +138,7 @@ protected: return result; } + GLenum get_error_value(); void set_error(GLenum error); // UNPACK_FLIP_Y_WEBGL of type boolean diff --git a/Libraries/LibWeb/WebGL/WebGLRenderingContextImpl.cpp b/Libraries/LibWeb/WebGL/WebGLRenderingContextImpl.cpp index 1eecfccee7..9933420a1f 100644 --- a/Libraries/LibWeb/WebGL/WebGLRenderingContextImpl.cpp +++ b/Libraries/LibWeb/WebGL/WebGLRenderingContextImpl.cpp @@ -1535,7 +1535,7 @@ JS::Value WebGLRenderingContextImpl::get_parameter(WebIDL::UnsignedLong pname) WebIDL::UnsignedLong WebGLRenderingContextImpl::get_error() { m_context->make_current(); - return glGetError(); + return get_error_value(); } JS::Value WebGLRenderingContextImpl::get_program_parameter(GC::Root program, WebIDL::UnsignedLong pname)