LibWeb/WebGL: Implement getAttachedShaders

This commit is contained in:
Luke Wilde 2025-01-09 19:16:19 +00:00 committed by Andreas Kling
parent aa99853a5c
commit 4cb5a980e5
Notes: github-actions[bot] 2025-01-21 20:38:24 +00:00
2 changed files with 29 additions and 1 deletions

View file

@ -106,7 +106,7 @@ interface mixin WebGLRenderingContextBase {
WebGLActiveInfo? getActiveAttrib(WebGLProgram program, GLuint index); WebGLActiveInfo? getActiveAttrib(WebGLProgram program, GLuint index);
WebGLActiveInfo? getActiveUniform(WebGLProgram program, GLuint index); WebGLActiveInfo? getActiveUniform(WebGLProgram program, GLuint index);
[FIXME] sequence<WebGLShader>? getAttachedShaders(WebGLProgram program); sequence<WebGLShader>? getAttachedShaders(WebGLProgram program);
GLint getAttribLocation(WebGLProgram program, DOMString name); GLint getAttribLocation(WebGLProgram program, DOMString name);

View file

@ -55,6 +55,16 @@ static ByteString to_cpp_type(const IDL::Type& type, const IDL::Interface& inter
return "Optional<String>"sv; return "Optional<String>"sv;
return "String"sv; return "String"sv;
} }
if (type.name() == "sequence") {
auto& parameterized_type = as<IDL::ParameterizedType>(type);
auto sequence_cpp_type = idl_type_name_to_cpp_type(parameterized_type.parameters().first(), interface);
if (type.is_nullable()) {
return ByteString::formatted("Optional<Vector<{}>>", sequence_cpp_type.name);
}
return ByteString::formatted("Vector<{}>", sequence_cpp_type.name);
}
auto cpp_type = idl_type_name_to_cpp_type(type, interface); auto cpp_type = idl_type_name_to_cpp_type(type, interface);
return cpp_type.name; return cpp_type.name;
} }
@ -1044,6 +1054,24 @@ public:
continue; continue;
} }
if (function.name == "getAttachedShaders"sv) {
generate_webgl_object_handle_unwrap(function_impl_generator, "program"sv, "OptionalNone {}"sv);
function_impl_generator.append(R"~~~(
(void)program_handle;
Vector<GC::Root<WebGLShader>> result;
if (program->attached_vertex_shader())
result.append(GC::make_root(*program->attached_vertex_shader()));
if (program->attached_fragment_shader())
result.append(GC::make_root(*program->attached_fragment_shader()));
return result;
)~~~");
continue;
}
if (function.name == "bufferData"sv && function.overload_index == 0) { if (function.name == "bufferData"sv && function.overload_index == 0) {
function_impl_generator.append(R"~~~( function_impl_generator.append(R"~~~(
glBufferData(target, size, 0, usage); glBufferData(target, size, 0, usage);