Skip to content

Commit 044ac2d

Browse files
cqundefineawesomekling
authored andcommitted
LibWeb: Fix WebGL getError
getError was just calling out to glGetError and never checking our error value that we were maintaining ourselves.
1 parent e7aeb71 commit 044ac2d

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,23 @@ Optional<WebGLRenderingContextBase::ConvertedTexture> WebGLRenderingContextBase:
195195
};
196196
}
197197

198+
// TODO: The glGetError spec allows for queueing errors which is something we should probably do, for now
199+
// this just keeps track of one error which is also fine by the spec
200+
GLenum WebGLRenderingContextBase::get_error_value()
201+
{
202+
if (m_error == GL_NO_ERROR)
203+
return glGetError();
204+
205+
auto error = m_error;
206+
m_error = GL_NO_ERROR;
207+
return error;
208+
}
209+
198210
void WebGLRenderingContextBase::set_error(GLenum error)
199211
{
212+
if (m_error != GL_NO_ERROR)
213+
return;
214+
200215
auto context_error = glGetError();
201216
if (context_error != GL_NO_ERROR)
202217
m_error = context_error;

Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class WebGLRenderingContextBase {
138138
return result;
139139
}
140140

141+
GLenum get_error_value();
141142
void set_error(GLenum error);
142143

143144
// UNPACK_FLIP_Y_WEBGL of type boolean

Libraries/LibWeb/WebGL/WebGLRenderingContextImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ JS::Value WebGLRenderingContextImpl::get_parameter(WebIDL::UnsignedLong pname)
15351535
WebIDL::UnsignedLong WebGLRenderingContextImpl::get_error()
15361536
{
15371537
m_context->make_current();
1538-
return glGetError();
1538+
return get_error_value();
15391539
}
15401540

15411541
JS::Value WebGLRenderingContextImpl::get_program_parameter(GC::Root<WebGLProgram> program, WebIDL::UnsignedLong pname)

0 commit comments

Comments
 (0)