ladybird/Userland/Libraries/LibWeb/WebGL/OpenGLContext.h
Aliaksandr Kalenik 271c9d1ae9 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.
2024-01-20 18:21:56 +01:00

47 lines
1.5 KiB
C++

/*
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGfx/Bitmap.h>
#include <LibWeb/WebGL/Types.h>
namespace Web::WebGL {
class OpenGLContext {
public:
static OwnPtr<OpenGLContext> create(Gfx::Bitmap&);
virtual void activate() = 0;
virtual void present(Gfx::Bitmap&) = 0;
void clear_buffer_to_default_values();
virtual GLenum gl_get_error() = 0;
virtual void gl_get_doublev(GLenum, GLdouble*) = 0;
virtual void gl_get_integerv(GLenum, GLint*) = 0;
virtual void gl_clear(GLbitfield) = 0;
virtual void gl_clear_color(GLfloat, GLfloat, GLfloat, GLfloat) = 0;
virtual void gl_clear_depth(GLdouble) = 0;
virtual void gl_clear_stencil(GLint) = 0;
virtual void gl_active_texture(GLenum) = 0;
virtual void gl_viewport(GLint, GLint, GLsizei, GLsizei) = 0;
virtual void gl_line_width(GLfloat) = 0;
virtual void gl_polygon_offset(GLfloat, GLfloat) = 0;
virtual void gl_scissor(GLint, GLint, GLsizei, GLsizei) = 0;
virtual void gl_depth_mask(GLboolean) = 0;
virtual void gl_depth_func(GLenum) = 0;
virtual void gl_depth_range(GLdouble, GLdouble) = 0;
virtual void gl_cull_face(GLenum) = 0;
virtual void gl_color_mask(GLboolean, GLboolean, GLboolean, GLboolean) = 0;
virtual void gl_front_face(GLenum) = 0;
virtual void gl_finish() = 0;
virtual void gl_flush() = 0;
virtual void gl_stencil_op_separate(GLenum, GLenum, GLenum, GLenum) = 0;
virtual ~OpenGLContext() { }
};
}