LibWeb/WebGL2: Implement vertexAttribI4(u)i(v)

This commit is contained in:
Luke Wilde 2025-10-20 18:11:59 +01:00 committed by Jelle Raaijmakers
parent 35763ffe53
commit 2c13a2a68c
3 changed files with 42 additions and 4 deletions

View File

@ -355,10 +355,10 @@ interface mixin WebGL2RenderingContextBase {
undefined uniformMatrix3x4fv(WebGLUniformLocation? location, GLboolean transpose, Float32List data, optional unsigned long long srcOffset = 0, optional GLuint srcLength = 0);
// Vertex attributes
[FIXME] undefined vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
[FIXME] undefined vertexAttribI4iv(GLuint index, Int32List values);
[FIXME] undefined vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
[FIXME] undefined vertexAttribI4uiv(GLuint index, Uint32List values);
undefined vertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
undefined vertexAttribI4iv(GLuint index, Int32List values);
undefined vertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
undefined vertexAttribI4uiv(GLuint index, Uint32List values);
undefined vertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
// Writing to the drawing buffer

View File

@ -340,6 +340,40 @@ void WebGL2RenderingContextImpl::uniform_matrix3x4fv(GC::Root<WebGLUniformLocati
glUniformMatrix3x4fv(location->handle(), span.size() / matrix_size, transpose, span.data());
}
void WebGL2RenderingContextImpl::vertex_attrib_i4i(WebIDL::UnsignedLong index, WebIDL::Long x, WebIDL::Long y, WebIDL::Long z, WebIDL::Long w)
{
m_context->make_current();
glVertexAttribI4i(index, x, y, z, w);
}
void WebGL2RenderingContextImpl::vertex_attrib_i4iv(WebIDL::UnsignedLong index, Int32List values)
{
m_context->make_current();
auto span = MUST(span_from_int32_list(values, /* src_offset= */ 0));
if (span.size() < 4) [[unlikely]] {
set_error(GL_INVALID_VALUE);
return;
}
glVertexAttribI4iv(index, span.data());
}
void WebGL2RenderingContextImpl::vertex_attrib_i4ui(WebIDL::UnsignedLong index, WebIDL::UnsignedLong x, WebIDL::UnsignedLong y, WebIDL::UnsignedLong z, WebIDL::UnsignedLong w)
{
m_context->make_current();
glVertexAttribI4ui(index, x, y, z, w);
}
void WebGL2RenderingContextImpl::vertex_attrib_i4uiv(WebIDL::UnsignedLong index, Uint32List values)
{
m_context->make_current();
auto span = MUST(span_from_uint32_list(values, /* src_offset= */ 0));
if (span.size() < 4) [[unlikely]] {
set_error(GL_INVALID_VALUE);
return;
}
glVertexAttribI4uiv(index, span.data());
}
void WebGL2RenderingContextImpl::vertex_attrib_i_pointer(WebIDL::UnsignedLong index, WebIDL::Long size, WebIDL::UnsignedLong type, WebIDL::Long stride, WebIDL::LongLong offset)
{
m_context->make_current();

View File

@ -53,6 +53,10 @@ public:
void uniform_matrix4x3fv(GC::Root<WebGLUniformLocation> location, bool transpose, Float32List data, WebIDL::UnsignedLongLong src_offset, WebIDL::UnsignedLong src_length);
void uniform_matrix2x4fv(GC::Root<WebGLUniformLocation> location, bool transpose, Float32List data, WebIDL::UnsignedLongLong src_offset, WebIDL::UnsignedLong src_length);
void uniform_matrix3x4fv(GC::Root<WebGLUniformLocation> location, bool transpose, Float32List data, WebIDL::UnsignedLongLong src_offset, WebIDL::UnsignedLong src_length);
void vertex_attrib_i4i(WebIDL::UnsignedLong index, WebIDL::Long x, WebIDL::Long y, WebIDL::Long z, WebIDL::Long w);
void vertex_attrib_i4iv(WebIDL::UnsignedLong index, Int32List values);
void vertex_attrib_i4ui(WebIDL::UnsignedLong index, WebIDL::UnsignedLong x, WebIDL::UnsignedLong y, WebIDL::UnsignedLong z, WebIDL::UnsignedLong w);
void vertex_attrib_i4uiv(WebIDL::UnsignedLong index, Uint32List values);
void vertex_attrib_i_pointer(WebIDL::UnsignedLong index, WebIDL::Long size, WebIDL::UnsignedLong type, WebIDL::Long stride, WebIDL::LongLong offset);
void vertex_attrib_divisor(WebIDL::UnsignedLong index, WebIDL::UnsignedLong divisor);
void draw_arrays_instanced(WebIDL::UnsignedLong mode, WebIDL::Long first, WebIDL::Long count, WebIDL::Long instance_count);