LibWeb/WebGL: Implement createFramebuffer

This commit is contained in:
Luke Wilde 2024-12-05 10:55:34 +00:00 committed by Alexander Kalenik
parent 2ac8408fef
commit c5e9615c29
Notes: github-actions[bot] 2024-12-05 20:43:53 +00:00
4 changed files with 21 additions and 4 deletions

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/WebGLFramebufferPrototype.h>
#include <LibWeb/WebGL/WebGLFramebuffer.h>
@ -11,8 +12,13 @@ namespace Web::WebGL {
GC_DEFINE_ALLOCATOR(WebGLFramebuffer);
WebGLFramebuffer::WebGLFramebuffer(JS::Realm& realm)
: WebGLObject(realm, 0)
GC::Ptr<WebGLFramebuffer> WebGLFramebuffer::create(JS::Realm& realm, GLuint handle)
{
return realm.heap().allocate<WebGLFramebuffer>(realm, handle);
}
WebGLFramebuffer::WebGLFramebuffer(JS::Realm& realm, GLuint handle)
: WebGLObject(realm, handle)
{
}

View file

@ -15,10 +15,12 @@ class WebGLFramebuffer final : public WebGLObject {
GC_DECLARE_ALLOCATOR(WebGLFramebuffer);
public:
static GC::Ptr<WebGLFramebuffer> create(JS::Realm& realm, GLuint handle);
virtual ~WebGLFramebuffer();
protected:
explicit WebGLFramebuffer(JS::Realm&);
explicit WebGLFramebuffer(JS::Realm&, GLuint handle);
};
}

View file

@ -69,7 +69,7 @@ interface mixin WebGLRenderingContextBase {
[FIXME] undefined copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
WebGLBuffer? createBuffer();
[FIXME] WebGLFramebuffer? createFramebuffer();
WebGLFramebuffer? createFramebuffer();
WebGLProgram? createProgram();
[FIXME] WebGLRenderbuffer? createRenderbuffer();
WebGLShader? createShader(GLenum type);

View file

@ -415,6 +415,15 @@ public:
continue;
}
if (function.name == "createFramebuffer"sv) {
function_impl_generator.append(R"~~~(
GLuint handle = 0;
glGenFramebuffers(1, &handle);
return WebGLFramebuffer::create(m_realm, handle);
)~~~");
continue;
}
if (function.name == "shaderSource"sv) {
function_impl_generator.append(R"~~~(
Vector<GLchar*> strings;