LibWeb/WebGL: Implement getActiveAttrib() and getActiveUniform()

This commit is contained in:
Aliaksandr Kalenik 2024-12-01 00:10:44 +01:00 committed by Alexander Kalenik
commit 3c2ac309ca
Notes: github-actions[bot] 2024-12-03 22:36:52 +00:00
5 changed files with 67 additions and 7 deletions

View file

@ -4,17 +4,34 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/WebGLActiveInfoPrototype.h>
#include <LibWeb/WebGL/WebGLActiveInfo.h>
namespace Web::WebGL {
GC_DEFINE_ALLOCATOR(WebGLActiveInfo);
WebGLActiveInfo::WebGLActiveInfo(JS::Realm& realm)
GC::Ptr<WebGLActiveInfo> WebGLActiveInfo::create(JS::Realm& realm, String name, GLenum type, GLsizei size)
{
return realm.create<WebGLActiveInfo>(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);
}
}

View file

@ -8,6 +8,9 @@
#include <LibWeb/Bindings/PlatformObject.h>
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<WebGLActiveInfo> 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 };
};
}

View file

@ -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;
};

View file

@ -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<WebGLShader>? getAttachedShaders(WebGLProgram program);
GLint getAttribLocation(WebGLProgram program, DOMString name);