mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:57:44 +00:00
LibWeb: Use platform's OpenGL in WebGL when it is available
This change makes WebGL to use LibGL only in SerenityOS, and the platform's OpenGL driver in Ladybird if it is available. This is implemented by introducing wrapper class between WebGL and OpenGL calls. This way it will also be possible to provide more complete support in Ladybird even if we don't yet have all needed calls implemented in LibGL. For now, the wrapper class makes all GL calls virtual. However, we can get rid of this and implement it at compile time in case of performance problems.
This commit is contained in:
parent
c6289fad49
commit
271c9d1ae9
9 changed files with 449 additions and 37 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -9,14 +10,16 @@
|
|||
#include <AK/RefCountForwarder.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibGL/GLContext.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/WebGL/OpenGLContext.h>
|
||||
#include <LibWeb/WebGL/WebGLContextAttributes.h>
|
||||
|
||||
namespace Web::WebGL {
|
||||
|
||||
#define GL_NO_ERROR 0
|
||||
|
||||
class WebGLRenderingContextBase : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(WebGLRenderingContextBase, Bindings::PlatformObject);
|
||||
|
||||
|
@ -64,14 +67,14 @@ public:
|
|||
void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
||||
protected:
|
||||
WebGLRenderingContextBase(JS::Realm&, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters);
|
||||
WebGLRenderingContextBase(JS::Realm&, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<OpenGLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters);
|
||||
|
||||
private:
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<HTML::HTMLCanvasElement> m_canvas_element;
|
||||
|
||||
NonnullOwnPtr<GL::GLContext> m_context;
|
||||
NonnullOwnPtr<OpenGLContext> m_context;
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#context-creation-parameters
|
||||
// Each WebGLRenderingContext has context creation parameters, set upon creation, in a WebGLContextAttributes object.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue