From 7abc79ece70fa8a479d25b416a1083d1f68231bb Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Thu, 5 Dec 2024 19:25:39 -0700 Subject: [PATCH] LibWeb/WebGL: Add stub class for WebGLVertexArrayObject This is a WebGL 2.0 class --- Libraries/LibWeb/CMakeLists.txt | 1 + .../LibWeb/WebGL/WebGLVertexArrayObject.cpp | 34 +++++++++++++++++++ .../LibWeb/WebGL/WebGLVertexArrayObject.h | 29 ++++++++++++++++ .../LibWeb/WebGL/WebGLVertexArrayObject.idl | 6 ++++ Libraries/LibWeb/idl_files.cmake | 1 + .../Text/expected/all-window-properties.txt | 1 + 6 files changed, 72 insertions(+) create mode 100644 Libraries/LibWeb/WebGL/WebGLVertexArrayObject.cpp create mode 100644 Libraries/LibWeb/WebGL/WebGLVertexArrayObject.h create mode 100644 Libraries/LibWeb/WebGL/WebGLVertexArrayObject.idl diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 70510e9501b..2a35012bdc3 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -821,6 +821,7 @@ set(SOURCES WebGL/WebGLTexture.cpp WebGL/WebGLTransformFeedback.cpp WebGL/WebGLUniformLocation.cpp + WebGL/WebGLVertexArrayObject.cpp WebIDL/AbstractOperations.cpp WebIDL/Buffers.cpp WebIDL/CallbackType.cpp diff --git a/Libraries/LibWeb/WebGL/WebGLVertexArrayObject.cpp b/Libraries/LibWeb/WebGL/WebGLVertexArrayObject.cpp new file mode 100644 index 00000000000..4c567494475 --- /dev/null +++ b/Libraries/LibWeb/WebGL/WebGLVertexArrayObject.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024, Andrew Kaster + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include +#include + +namespace Web::WebGL { + +GC_DEFINE_ALLOCATOR(WebGLVertexArrayObject); + +GC::Ref WebGLVertexArrayObject::create(JS::Realm& realm, GLuint handle) +{ + return realm.create(realm, handle); +} + +WebGLVertexArrayObject::WebGLVertexArrayObject(JS::Realm& realm, GLuint handle) + : WebGLObject(realm, handle) +{ +} + +WebGLVertexArrayObject::~WebGLVertexArrayObject() = default; + +void WebGLVertexArrayObject::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + WEB_SET_PROTOTYPE_FOR_INTERFACE(WebGLVertexArrayObject); +} + +} diff --git a/Libraries/LibWeb/WebGL/WebGLVertexArrayObject.h b/Libraries/LibWeb/WebGL/WebGLVertexArrayObject.h new file mode 100644 index 00000000000..e347f267a12 --- /dev/null +++ b/Libraries/LibWeb/WebGL/WebGLVertexArrayObject.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024, Andrew Kaster + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include + +namespace Web::WebGL { + +class WebGLVertexArrayObject : public WebGLObject { + WEB_PLATFORM_OBJECT(WebGLVertexArrayObject, WebGLObject); + GC_DECLARE_ALLOCATOR(WebGLVertexArrayObject); + +public: + static GC::Ref create(JS::Realm& realm, GLuint handle); + + virtual ~WebGLVertexArrayObject() override; + +protected: + explicit WebGLVertexArrayObject(JS::Realm&, GLuint handle); + + virtual void initialize(JS::Realm&) override; +}; + +} diff --git a/Libraries/LibWeb/WebGL/WebGLVertexArrayObject.idl b/Libraries/LibWeb/WebGL/WebGLVertexArrayObject.idl new file mode 100644 index 00000000000..ce738132fe9 --- /dev/null +++ b/Libraries/LibWeb/WebGL/WebGLVertexArrayObject.idl @@ -0,0 +1,6 @@ +#import + +// https://registry.khronos.org/webgl/specs/latest/2.0/#3.6 +[Exposed=(Window,Worker)] +interface WebGLVertexArrayObject : WebGLObject { +}; diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake index ffe6d657379..999aa8a0671 100644 --- a/Libraries/LibWeb/idl_files.cmake +++ b/Libraries/LibWeb/idl_files.cmake @@ -385,6 +385,7 @@ libweb_js_bindings(WebGL/WebGLSync) libweb_js_bindings(WebGL/WebGLTexture) libweb_js_bindings(WebGL/WebGLTransformFeedback) libweb_js_bindings(WebGL/WebGLUniformLocation) +libweb_js_bindings(WebGL/WebGLVertexArrayObject) libweb_js_bindings(WebIDL/DOMException) libweb_js_bindings(WebSockets/WebSocket) libweb_js_bindings(WebVTT/VTTCue) diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt index 8e813e91d64..29d660164ff 100644 --- a/Tests/LibWeb/Text/expected/all-window-properties.txt +++ b/Tests/LibWeb/Text/expected/all-window-properties.txt @@ -414,6 +414,7 @@ WebGLSync WebGLTexture WebGLTransformFeedback WebGLUniformLocation +WebGLVertexArrayObject WebKitCSSMatrix WebSocket WheelEvent