2025-01-10 13:36:00 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/Realm.h>
|
|
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2026-04-18 05:54:06 -03:00
|
|
|
#include <LibWeb/Bindings/WebGLDrawBuffers.h>
|
2025-01-10 13:36:00 -03:00
|
|
|
#include <LibWeb/WebGL/Extensions/WebGLDrawBuffers.h>
|
2026-06-15 14:37:51 -03:00
|
|
|
#include <LibWeb/WebGL/WebGLContextProxy.h>
|
2026-03-05 15:37:33 -03:00
|
|
|
#include <LibWeb/WebGL/WebGLRenderingContextBase.h>
|
2025-01-10 13:36:00 -03:00
|
|
|
|
|
|
|
|
#include <GLES2/gl2.h>
|
|
|
|
|
#include <GLES2/gl2ext.h>
|
|
|
|
|
|
2026-04-22 10:33:59 -03:00
|
|
|
namespace Web::WebGL {
|
2025-01-10 13:36:00 -03:00
|
|
|
|
|
|
|
|
GC_DEFINE_ALLOCATOR(WebGLDrawBuffers);
|
|
|
|
|
|
2026-03-05 16:47:29 -03:00
|
|
|
JS::ThrowCompletionOr<GC::Ref<JS::Object>> WebGLDrawBuffers::create(JS::Realm& realm, GC::Ref<WebGLRenderingContextBase> context)
|
2025-01-10 13:36:00 -03:00
|
|
|
{
|
|
|
|
|
return realm.create<WebGLDrawBuffers>(realm, context);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 15:37:33 -03:00
|
|
|
WebGLDrawBuffers::WebGLDrawBuffers(JS::Realm& realm, GC::Ref<WebGLRenderingContextBase> context)
|
2025-01-10 13:36:00 -03:00
|
|
|
: PlatformObject(realm)
|
|
|
|
|
, m_context(context)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WebGLDrawBuffers::draw_buffers_webgl(Vector<GLenum> buffers)
|
|
|
|
|
{
|
|
|
|
|
m_context->context().make_current();
|
2026-06-10 17:43:02 -03:00
|
|
|
m_context->context().draw_buffers_ext(buffers.size(), buffers.data());
|
2025-01-10 13:36:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WebGLDrawBuffers::initialize(JS::Realm& realm)
|
|
|
|
|
{
|
|
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(WebGLDrawBuffers);
|
2025-04-20 11:22:57 -03:00
|
|
|
Base::initialize(realm);
|
2025-01-10 13:36:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WebGLDrawBuffers::visit_edges(Visitor& visitor)
|
|
|
|
|
{
|
|
|
|
|
Base::visit_edges(visitor);
|
|
|
|
|
visitor.visit(m_context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|