mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/WebGL2: Implement getActiveUniforms
This commit is contained in:
parent
071a445015
commit
f1b81b1ae2
Notes:
github-actions[bot]
2025-02-09 00:01:54 +00:00
Author: https://github.com/Lubrsi
Commit: f1b81b1ae2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3385
2 changed files with 39 additions and 1 deletions
|
@ -420,7 +420,7 @@ interface mixin WebGL2RenderingContextBase {
|
||||||
undefined bindBufferRange(GLenum target, GLuint index, WebGLBuffer? buffer, GLintptr offset, GLsizeiptr size);
|
undefined bindBufferRange(GLenum target, GLuint index, WebGLBuffer? buffer, GLintptr offset, GLsizeiptr size);
|
||||||
[FIXME] any getIndexedParameter(GLenum target, GLuint index);
|
[FIXME] any getIndexedParameter(GLenum target, GLuint index);
|
||||||
[FIXME] sequence<GLuint>? getUniformIndices(WebGLProgram program, sequence<DOMString> uniformNames);
|
[FIXME] sequence<GLuint>? getUniformIndices(WebGLProgram program, sequence<DOMString> uniformNames);
|
||||||
[FIXME] any getActiveUniforms(WebGLProgram program, sequence<GLuint> uniformIndices, GLenum pname);
|
any getActiveUniforms(WebGLProgram program, sequence<GLuint> uniformIndices, GLenum pname);
|
||||||
GLuint getUniformBlockIndex(WebGLProgram program, DOMString uniformBlockName);
|
GLuint getUniformBlockIndex(WebGLProgram program, DOMString uniformBlockName);
|
||||||
any getActiveUniformBlockParameter(WebGLProgram program, GLuint uniformBlockIndex, GLenum pname);
|
any getActiveUniformBlockParameter(WebGLProgram program, GLuint uniformBlockIndex, GLenum pname);
|
||||||
DOMString? getActiveUniformBlockName(WebGLProgram program, GLuint uniformBlockIndex);
|
DOMString? getActiveUniformBlockName(WebGLProgram program, GLuint uniformBlockIndex);
|
||||||
|
|
|
@ -1547,6 +1547,44 @@ public:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (function.name == "getActiveUniforms"sv) {
|
||||||
|
generate_webgl_object_handle_unwrap(function_impl_generator, "program"sv, "{}"sv);
|
||||||
|
function_impl_generator.append(R"~~~(
|
||||||
|
auto params = MUST(ByteBuffer::create_zeroed(uniform_indices.size() * sizeof(GLint)));
|
||||||
|
Span<GLint> params_span(reinterpret_cast<GLint*>(params.data()), uniform_indices.size());
|
||||||
|
glGetActiveUniformsiv(program_handle, uniform_indices.size(), uniform_indices.data(), pname, params_span.data());
|
||||||
|
|
||||||
|
Vector<JS::Value> params_as_values;
|
||||||
|
params_as_values.ensure_capacity(params.size());
|
||||||
|
for (GLint param : params_span) {
|
||||||
|
switch (pname) {
|
||||||
|
case GL_UNIFORM_TYPE:
|
||||||
|
params_as_values.unchecked_append(JS::Value(static_cast<GLenum>(param)));
|
||||||
|
break;
|
||||||
|
case GL_UNIFORM_SIZE:
|
||||||
|
params_as_values.unchecked_append(JS::Value(static_cast<GLuint>(param)));
|
||||||
|
break;
|
||||||
|
case GL_UNIFORM_BLOCK_INDEX:
|
||||||
|
case GL_UNIFORM_OFFSET:
|
||||||
|
case GL_UNIFORM_ARRAY_STRIDE:
|
||||||
|
case GL_UNIFORM_MATRIX_STRIDE:
|
||||||
|
params_as_values.unchecked_append(JS::Value(param));
|
||||||
|
break;
|
||||||
|
case GL_UNIFORM_IS_ROW_MAJOR:
|
||||||
|
params_as_values.unchecked_append(JS::Value(param == GL_TRUE));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dbgln("Unknown WebGL uniform parameter name in getActiveUniforms: 0x{:04x}", pname);
|
||||||
|
set_error(GL_INVALID_ENUM);
|
||||||
|
return JS::js_null();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return JS::Array::create_from(m_realm, params_as_values);
|
||||||
|
)~~~");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (function.name == "getActiveAttrib"sv) {
|
if (function.name == "getActiveAttrib"sv) {
|
||||||
generate_webgl_object_handle_unwrap(function_impl_generator, "program"sv, "{}"sv);
|
generate_webgl_object_handle_unwrap(function_impl_generator, "program"sv, "{}"sv);
|
||||||
function_impl_generator.append(R"~~~(
|
function_impl_generator.append(R"~~~(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue