diff --git a/Libraries/LibWeb/WebGL/WebGLRenderingContextOverloads.idl b/Libraries/LibWeb/WebGL/WebGLRenderingContextOverloads.idl index e2a3dbef089..4d2570d8080 100644 --- a/Libraries/LibWeb/WebGL/WebGLRenderingContextOverloads.idl +++ b/Libraries/LibWeb/WebGL/WebGLRenderingContextOverloads.idl @@ -12,6 +12,9 @@ typedef (ImageBitmap or // FIXME: BufferSource should be a Float32Array typedef (BufferSource or sequence) Float32List; +// FIXME: BufferSource should be a Int32Array +typedef (BufferSource or sequence) Int32List; + // https://registry.khronos.org/webgl/specs/latest/1.0/#5.14 interface mixin WebGLRenderingContextOverloads { undefined bufferData(GLenum target, GLsizeiptr size, GLenum usage); @@ -35,10 +38,10 @@ interface mixin WebGLRenderingContextOverloads { undefined uniform3fv(WebGLUniformLocation? location, Float32List v); undefined uniform4fv(WebGLUniformLocation? location, Float32List v); - [FIXME] undefined uniform1iv(WebGLUniformLocation? location, Int32List v); - [FIXME] undefined uniform2iv(WebGLUniformLocation? location, Int32List v); - [FIXME] undefined uniform3iv(WebGLUniformLocation? location, Int32List v); - [FIXME] undefined uniform4iv(WebGLUniformLocation? location, Int32List v); + undefined uniform1iv(WebGLUniformLocation? location, Int32List v); + undefined uniform2iv(WebGLUniformLocation? location, Int32List v); + undefined uniform3iv(WebGLUniformLocation? location, Int32List v); + undefined uniform4iv(WebGLUniformLocation? location, Int32List v); // FIXME: Float32Array should be a Float32List undefined uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32List value); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp index 67f5c898bca..083dadccc44 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp @@ -633,6 +633,25 @@ public: continue; } + if (function.name == "uniform1iv"sv || function.name == "uniform2iv"sv || function.name == "uniform3iv"sv || function.name == "uniform4iv"sv) { + auto number_of_matrix_elements = function.name.substring_view(7, 1); + function_impl_generator.set("number_of_matrix_elements", number_of_matrix_elements); + function_impl_generator.append(R"~~~( + if (v.has>()) { + auto& data = v.get>(); + glUniform@number_of_matrix_elements@iv(location->handle(), data.size() / @number_of_matrix_elements@, data.data()); + return; + } + + auto& typed_array_base = static_cast(*v.get>()->raw_object()); + auto& int32_array = verify_cast(typed_array_base); + int const* data = int32_array.data().data(); + auto count = int32_array.array_length().length() / @number_of_matrix_elements@; + glUniform@number_of_matrix_elements@iv(location->handle(), count, data); +)~~~"); + continue; + } + if (function.name == "getParameter"sv) { generate_get_parameter(function_impl_generator); continue;