diff --git a/Libraries/LibWeb/WebGL/WebGLActiveInfo.cpp b/Libraries/LibWeb/WebGL/WebGLActiveInfo.cpp index 6c0ff9bf62c..54feba40758 100644 --- a/Libraries/LibWeb/WebGL/WebGLActiveInfo.cpp +++ b/Libraries/LibWeb/WebGL/WebGLActiveInfo.cpp @@ -4,17 +4,34 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include +#include +#include #include namespace Web::WebGL { GC_DEFINE_ALLOCATOR(WebGLActiveInfo); -WebGLActiveInfo::WebGLActiveInfo(JS::Realm& realm) +GC::Ptr WebGLActiveInfo::create(JS::Realm& realm, String name, GLenum type, GLsizei size) +{ + return realm.create(realm, move(name), type, size); +} + +WebGLActiveInfo::WebGLActiveInfo(JS::Realm& realm, String name, GLenum type, GLsizei size) : Bindings::PlatformObject(realm) + , m_name(move(name)) + , m_type(type) + , m_size(size) { } WebGLActiveInfo::~WebGLActiveInfo() = default; +void WebGLActiveInfo::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + WEB_SET_PROTOTYPE_FOR_INTERFACE(WebGLActiveInfo); +} + } diff --git a/Libraries/LibWeb/WebGL/WebGLActiveInfo.h b/Libraries/LibWeb/WebGL/WebGLActiveInfo.h index 33d300e2815..d0786a14dc4 100644 --- a/Libraries/LibWeb/WebGL/WebGLActiveInfo.h +++ b/Libraries/LibWeb/WebGL/WebGLActiveInfo.h @@ -8,6 +8,9 @@ #include +typedef unsigned int GLenum; +typedef int GLsizei; + namespace Web::WebGL { class WebGLActiveInfo : public Bindings::PlatformObject { @@ -15,10 +18,22 @@ class WebGLActiveInfo : public Bindings::PlatformObject { GC_DECLARE_ALLOCATOR(WebGLActiveInfo); public: + static GC::Ptr create(JS::Realm&, String name, GLenum type, GLsizei size); virtual ~WebGLActiveInfo(); + GLsizei size() const { return m_size; } + GLenum type() const { return m_type; } + String const& name() const { return m_name; } + protected: - explicit WebGLActiveInfo(JS::Realm&); + explicit WebGLActiveInfo(JS::Realm&, String name, GLenum type, GLsizei size); + +private: + virtual void initialize(JS::Realm&) override; + + String m_name; + GLenum m_type { 0 }; + GLsizei m_size { 0 }; }; } diff --git a/Libraries/LibWeb/WebGL/WebGLActiveInfo.idl b/Libraries/LibWeb/WebGL/WebGLActiveInfo.idl index 978cdb12d77..a9f4d724d76 100644 --- a/Libraries/LibWeb/WebGL/WebGLActiveInfo.idl +++ b/Libraries/LibWeb/WebGL/WebGLActiveInfo.idl @@ -3,7 +3,7 @@ // https://registry.khronos.org/webgl/specs/latest/1.0/#5.11 [Exposed=(Window,Worker)] interface WebGLActiveInfo { - [FIXME] readonly attribute GLint size; - [FIXME] readonly attribute GLenum type; - [FIXME] readonly attribute DOMString name; + readonly attribute GLint size; + readonly attribute GLenum type; + readonly attribute DOMString name; }; diff --git a/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.idl b/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.idl index db747818783..696e3b3bb98 100644 --- a/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.idl +++ b/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.idl @@ -103,8 +103,8 @@ interface mixin WebGLRenderingContextBase { undefined generateMipmap(GLenum target); - [FIXME] WebGLActiveInfo? getActiveAttrib(WebGLProgram program, GLuint index); - [FIXME] WebGLActiveInfo? getActiveUniform(WebGLProgram program, GLuint index); + WebGLActiveInfo? getActiveAttrib(WebGLProgram program, GLuint index); + WebGLActiveInfo? getActiveUniform(WebGLProgram program, GLuint index); [FIXME] sequence? getAttachedShaders(WebGLProgram program); GLint getAttribLocation(WebGLProgram program, DOMString name); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp index b4c580fcd01..a18acb6635a 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWebGLRenderingContext.cpp @@ -352,6 +352,34 @@ public: continue; } + if (function.name == "getActiveUniform"sv) { + function_impl_generator.append(R"~~~( + GLint size = 0; + GLenum type = 0; + GLsizei buf_size = 256; + GLsizei length = 0; + GLchar name[256]; + glGetActiveUniform(program->handle(), index, buf_size, &length, &size, &type, name); + auto readonly_bytes = ReadonlyBytes { name, static_cast(length) }; + return WebGLActiveInfo::create(m_realm, String::from_utf8_without_validation(readonly_bytes), type, size); +)~~~"); + continue; + } + + if (function.name == "getActiveAttrib"sv) { + function_impl_generator.append(R"~~~( + GLint size = 0; + GLenum type = 0; + GLsizei buf_size = 256; + GLsizei length = 0; + GLchar name[256]; + glGetActiveAttrib(program->handle(), index, buf_size, &length, &size, &type, name); + auto readonly_bytes = ReadonlyBytes { name, static_cast(length) }; + return WebGLActiveInfo::create(m_realm, String::from_utf8_without_validation(readonly_bytes), type, size); +)~~~"); + continue; + } + Vector gl_call_arguments; for (size_t i = 0; i < function.parameters.size(); ++i) { auto const& parameter = function.parameters[i];