mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-16 07:20:46 +00:00
LibWeb/WebGL: Implement uniform{1,2,3,4}iv
This commit is contained in:
parent
2e1640a6c5
commit
7b0c067f4d
Notes:
github-actions[bot]
2024-12-05 20:42:50 +00:00
Author: https://github.com/Lubrsi
Commit: 7b0c067f4d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2791
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/shannonbooth
2 changed files with 26 additions and 4 deletions
|
@ -12,6 +12,9 @@ typedef (ImageBitmap or
|
||||||
// FIXME: BufferSource should be a Float32Array
|
// FIXME: BufferSource should be a Float32Array
|
||||||
typedef (BufferSource or sequence<GLfloat>) Float32List;
|
typedef (BufferSource or sequence<GLfloat>) Float32List;
|
||||||
|
|
||||||
|
// FIXME: BufferSource should be a Int32Array
|
||||||
|
typedef (BufferSource or sequence<GLint>) Int32List;
|
||||||
|
|
||||||
// https://registry.khronos.org/webgl/specs/latest/1.0/#5.14
|
// https://registry.khronos.org/webgl/specs/latest/1.0/#5.14
|
||||||
interface mixin WebGLRenderingContextOverloads {
|
interface mixin WebGLRenderingContextOverloads {
|
||||||
undefined bufferData(GLenum target, GLsizeiptr size, GLenum usage);
|
undefined bufferData(GLenum target, GLsizeiptr size, GLenum usage);
|
||||||
|
@ -35,10 +38,10 @@ interface mixin WebGLRenderingContextOverloads {
|
||||||
undefined uniform3fv(WebGLUniformLocation? location, Float32List v);
|
undefined uniform3fv(WebGLUniformLocation? location, Float32List v);
|
||||||
undefined uniform4fv(WebGLUniformLocation? location, Float32List v);
|
undefined uniform4fv(WebGLUniformLocation? location, Float32List v);
|
||||||
|
|
||||||
[FIXME] undefined uniform1iv(WebGLUniformLocation? location, Int32List v);
|
undefined uniform1iv(WebGLUniformLocation? location, Int32List v);
|
||||||
[FIXME] undefined uniform2iv(WebGLUniformLocation? location, Int32List v);
|
undefined uniform2iv(WebGLUniformLocation? location, Int32List v);
|
||||||
[FIXME] undefined uniform3iv(WebGLUniformLocation? location, Int32List v);
|
undefined uniform3iv(WebGLUniformLocation? location, Int32List v);
|
||||||
[FIXME] undefined uniform4iv(WebGLUniformLocation? location, Int32List v);
|
undefined uniform4iv(WebGLUniformLocation? location, Int32List v);
|
||||||
|
|
||||||
// FIXME: Float32Array should be a Float32List
|
// FIXME: Float32Array should be a Float32List
|
||||||
undefined uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32List value);
|
undefined uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32List value);
|
||||||
|
|
|
@ -633,6 +633,25 @@ public:
|
||||||
continue;
|
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<Vector<int>>()) {
|
||||||
|
auto& data = v.get<Vector<int>>();
|
||||||
|
glUniform@number_of_matrix_elements@iv(location->handle(), data.size() / @number_of_matrix_elements@, data.data());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& typed_array_base = static_cast<JS::TypedArrayBase&>(*v.get<GC::Root<WebIDL::BufferSource>>()->raw_object());
|
||||||
|
auto& int32_array = verify_cast<JS::Int32Array>(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) {
|
if (function.name == "getParameter"sv) {
|
||||||
generate_get_parameter(function_impl_generator);
|
generate_get_parameter(function_impl_generator);
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue