Skip to content

Commit b5037b1

Browse files
committed
LibWeb: Implement WebGL getParameter(GL_VERTEX_ARRAY_BINDING)
1 parent ee44ab7 commit b5037b1

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

Libraries/LibWeb/WebGL/WebGL2RenderingContextImpl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,8 @@ void WebGL2RenderingContextImpl::delete_vertex_array(GC::Root<WebGLVertexArrayOb
12081208
}
12091209

12101210
glDeleteVertexArrays(1, &vertex_array_handle);
1211+
if (m_current_vertex_array == vertex_array)
1212+
m_current_vertex_array = nullptr;
12111213
}
12121214

12131215
bool WebGL2RenderingContextImpl::is_vertex_array(GC::Root<WebGLVertexArrayObject> vertex_array)
@@ -1239,7 +1241,9 @@ void WebGL2RenderingContextImpl::bind_vertex_array(GC::Root<WebGLVertexArrayObje
12391241
}
12401242
array_handle = handle_or_error.release_value();
12411243
}
1244+
12421245
glBindVertexArray(array_handle);
1246+
m_current_vertex_array = array;
12431247
}
12441248

12451249
void WebGL2RenderingContextImpl::compressed_tex_image3d(WebIDL::UnsignedLong target, WebIDL::Long level, WebIDL::UnsignedLong internalformat, WebIDL::Long width, WebIDL::Long height, WebIDL::Long depth, WebIDL::Long border, GC::Root<WebIDL::ArrayBufferView> src_data, WebIDL::UnsignedLongLong src_offset, WebIDL::UnsignedLong src_length_override)

Libraries/LibWeb/WebGL/WebGLRenderingContextImpl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,11 @@ JS::Value WebGLRenderingContextImpl::get_parameter(WebIDL::UnsignedLong pname)
15261526
glGetIntegervRobustANGLE(GL_UNPACK_SKIP_ROWS, 1, nullptr, &result);
15271527
return JS::Value(result);
15281528
}
1529+
case GL_VERTEX_ARRAY_BINDING: { // FIXME: Allow this for VERTEX_ARRAY_BINDING_OES
1530+
if (!m_current_vertex_array)
1531+
return JS::js_null();
1532+
return JS::Value(m_current_vertex_array);
1533+
}
15291534
case MAX_CLIENT_WAIT_TIMEOUT_WEBGL:
15301535
// FIXME: Make this an actual limit
15311536
return JS::js_infinity();
@@ -2286,6 +2291,7 @@ void WebGLRenderingContextImpl::visit_edges(JS::Cell::Visitor& visitor)
22862291
visitor.visit(m_transform_feedback_binding);
22872292
visitor.visit(m_pixel_pack_buffer_binding);
22882293
visitor.visit(m_pixel_unpack_buffer_binding);
2294+
visitor.visit(m_current_vertex_array);
22892295
}
22902296

22912297
}

Libraries/LibWeb/WebGL/WebGLRenderingContextImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class WebGLRenderingContextImpl : public WebGLRenderingContextBase {
163163
GC::Ptr<WebGLTexture> m_texture_binding_2d_array;
164164
GC::Ptr<WebGLTexture> m_texture_binding_3d;
165165
GC::Ptr<WebGLTransformFeedback> m_transform_feedback_binding;
166+
GC::Ptr<WebGLVertexArrayObject> m_current_vertex_array;
166167

167168
NonnullOwnPtr<OpenGLContext> m_context;
168169
};

0 commit comments

Comments
 (0)