summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2022-12-25 00:45:33 +0100
committerAndreas Kling <kling@serenityos.org>2022-12-25 15:48:59 +0100
commitae82b14e59dfbe0996559320aa6f9bb76066a4cf (patch)
tree9828ebe95332ba2d72ccc7f63d18c1486c22a51a /Userland/Libraries/LibGL
parentbc1293925a271976f0646c6741e402db1f48d2fd (diff)
downloadserenity-ae82b14e59dfbe0996559320aa6f9bb76066a4cf.zip
LibGL+LibWeb: Remove WebGL-specific API from GLContext
The OpenGL API has ways to retrieve these values, so let's make sure to implement them. :^)
Diffstat (limited to 'Userland/Libraries/LibGL')
-rw-r--r--Userland/Libraries/LibGL/ContextParameter.cpp14
-rw-r--r--Userland/Libraries/LibGL/GL/gl.h2
-rw-r--r--Userland/Libraries/LibGL/GLContext.h6
3 files changed, 16 insertions, 6 deletions
diff --git a/Userland/Libraries/LibGL/ContextParameter.cpp b/Userland/Libraries/LibGL/ContextParameter.cpp
index 15354eb9c3..7e901b7202 100644
--- a/Userland/Libraries/LibGL/ContextParameter.cpp
+++ b/Userland/Libraries/LibGL/ContextParameter.cpp
@@ -30,6 +30,18 @@ Optional<ContextParameter> GLContext::get_context_parameter(GLenum name)
return ContextParameter { .type = GL_INT, .value = { .integer_value = sizeof(u8) * 8 } };
case GL_CLIENT_ACTIVE_TEXTURE:
return ContextParameter { .type = GL_INT, .value = { .integer_value = static_cast<GLint>(GL_TEXTURE0 + m_client_active_texture) } };
+ case GL_COLOR_CLEAR_VALUE:
+ return ContextParameter {
+ .type = GL_DOUBLE,
+ .count = 4,
+ .value = {
+ .double_list = {
+ static_cast<GLdouble>(m_clear_color.x()),
+ static_cast<GLdouble>(m_clear_color.y()),
+ static_cast<GLdouble>(m_clear_color.z()),
+ static_cast<GLdouble>(m_clear_color.w()),
+ } }
+ };
case GL_COLOR_MATERIAL:
return ContextParameter { .type = GL_BOOL, .is_capability = true, .value = { .boolean_value = m_color_material_enabled } };
case GL_COLOR_MATERIAL_FACE:
@@ -52,6 +64,8 @@ Optional<ContextParameter> GLContext::get_context_parameter(GLenum name)
return ContextParameter { .type = GL_BOOL, .is_capability = true, .value = { .boolean_value = m_cull_faces } };
case GL_DEPTH_BITS:
return ContextParameter { .type = GL_INT, .value = { .integer_value = sizeof(float) * 8 } };
+ case GL_DEPTH_CLEAR_VALUE:
+ return ContextParameter { .type = GL_DOUBLE, .value = { .double_value = static_cast<GLdouble>(m_clear_depth) } };
case GL_DEPTH_TEST:
return ContextParameter { .type = GL_BOOL, .is_capability = true, .value = { .boolean_value = m_depth_test_enabled } };
case GL_DITHER:
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h
index 56f617ef1a..008f88e620 100644
--- a/Userland/Libraries/LibGL/GL/gl.h
+++ b/Userland/Libraries/LibGL/GL/gl.h
@@ -103,10 +103,12 @@ extern "C" {
#define GL_COLOR_MATERIAL 0x0B57
#define GL_FOG_START 0x0B63
#define GL_FOG_END 0x0B64
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_MATRIX_MODE 0x0BA0
#define GL_NORMALIZE 0x0BA1
#define GL_VIEWPORT 0x0BA2
+#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_DOUBLEBUFFER 0x0C32
#define GL_TEXTURE_GEN_S 0x0C60
#define GL_TEXTURE_GEN_T 0x0C61
diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h
index 3b1b1b27d1..1808a6bc4f 100644
--- a/Userland/Libraries/LibGL/GLContext.h
+++ b/Userland/Libraries/LibGL/GLContext.h
@@ -107,12 +107,6 @@ public:
NonnullRefPtr<Gfx::Bitmap> frontbuffer() const { return m_frontbuffer; };
void present();
- // Used by WebGL to preserve the clear values when implicitly clearing the front buffer.
- // FIXME: Add ContextParameters for these and expose them through methods such as gl_get_floatv instead of having a public API like this.
- FloatVector4 current_clear_color() const { return m_clear_color; }
- GLdouble current_clear_depth() const { return m_clear_depth; }
- GLint current_clear_stencil() const { return m_clear_stencil; }
-
void gl_begin(GLenum mode);
void gl_clear(GLbitfield mask);
void gl_clear_color(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);