mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-03 17:02:56 +00:00
LibWeb/WebGL: Implement getActiveAttrib() and getActiveUniform()
This commit is contained in:
parent
f3a24d1569
commit
3c2ac309ca
Notes:
github-actions[bot]
2024-12-03 22:36:52 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 3c2ac309ca
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2688
Reviewed-by: https://github.com/ADKaster ✅
5 changed files with 67 additions and 7 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<size_t>(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<size_t>(length) };
|
||||
return WebGLActiveInfo::create(m_realm, String::from_utf8_without_validation(readonly_bytes), type, size);
|
||||
)~~~");
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector<ByteString> gl_call_arguments;
|
||||
for (size_t i = 0; i < function.parameters.size(); ++i) {
|
||||
auto const& parameter = function.parameters[i];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue