mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibWeb/WebGL: Implement WEBGL_draw_buffers extension
This commit is contained in:
parent
de77a5e3ea
commit
55f7cb4f10
Notes:
github-actions[bot]
2025-01-21 20:37:38 +00:00
Author: https://github.com/Lubrsi
Commit: 55f7cb4f10
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3239
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/kalenikaliaksandr
8 changed files with 150 additions and 0 deletions
52
Libraries/LibWeb/WebGL/Extensions/WebGLDrawBuffers.cpp
Normal file
52
Libraries/LibWeb/WebGL/Extensions/WebGLDrawBuffers.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/WebGLDrawBuffersPrototype.h>
|
||||
#include <LibWeb/WebGL/Extensions/WebGLDrawBuffers.h>
|
||||
#include <LibWeb/WebGL/OpenGLContext.h>
|
||||
#include <LibWeb/WebGL/WebGLRenderingContext.h>
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
namespace Web::WebGL::Extensions {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(WebGLDrawBuffers);
|
||||
|
||||
JS::ThrowCompletionOr<GC::Ptr<WebGLDrawBuffers>> WebGLDrawBuffers::create(JS::Realm& realm, GC::Ref<WebGLRenderingContext> context)
|
||||
{
|
||||
return realm.create<WebGLDrawBuffers>(realm, context);
|
||||
}
|
||||
|
||||
WebGLDrawBuffers::WebGLDrawBuffers(JS::Realm& realm, GC::Ref<WebGLRenderingContext> context)
|
||||
: PlatformObject(realm)
|
||||
, m_context(context)
|
||||
{
|
||||
m_context->context().request_extension("GL_EXT_draw_buffers");
|
||||
}
|
||||
|
||||
void WebGLDrawBuffers::draw_buffers_webgl(Vector<GLenum> buffers)
|
||||
{
|
||||
m_context->context().make_current();
|
||||
glDrawBuffersEXT(buffers.size(), buffers.data());
|
||||
}
|
||||
|
||||
void WebGLDrawBuffers::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(WebGLDrawBuffers);
|
||||
}
|
||||
|
||||
void WebGLDrawBuffers::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_context);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue