summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2021-10-18 01:31:21 +0200
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-10-17 21:01:52 -0700
commita36ee213b99113b4edb2f6f1578ab21582a0adfa (patch)
tree826ddfb13541a827897332119e10c0edc4388e78 /Userland/Libraries
parentb2627c8b744ebd214bc3321b8fc94f61ec90d61f (diff)
downloadserenity-a36ee213b99113b4edb2f6f1578ab21582a0adfa.zip
LibGL: Implement `glIsEnabled()`
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGL/GL/gl.h1
-rw-r--r--Userland/Libraries/LibGL/GLContext.h1
-rw-r--r--Userland/Libraries/LibGL/GLUtils.cpp5
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.cpp22
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h1
5 files changed, 30 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h
index 9bf5609b52..dc8406d6e8 100644
--- a/Userland/Libraries/LibGL/GL/gl.h
+++ b/Userland/Libraries/LibGL/GL/gl.h
@@ -371,6 +371,7 @@ GLAPI void glVertex4sv(const GLshort* v);
GLAPI void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
GLAPI void glEnable(GLenum cap);
GLAPI void glDisable(GLenum cap);
+GLAPI GLboolean glIsEnabled(GLenum cap);
GLAPI void glCullFace(GLenum mode);
GLAPI void glFrontFace(GLenum mode);
GLAPI GLuint glGenLists(GLsizei range);
diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h
index 4063be2b17..a972e65090 100644
--- a/Userland/Libraries/LibGL/GLContext.h
+++ b/Userland/Libraries/LibGL/GLContext.h
@@ -42,6 +42,7 @@ public:
virtual void gl_viewport(GLint x, GLint y, GLsizei width, GLsizei height) = 0;
virtual void gl_enable(GLenum) = 0;
virtual void gl_disable(GLenum) = 0;
+ virtual GLboolean gl_is_enabled(GLenum) = 0;
virtual void gl_front_face(GLenum) = 0;
virtual void gl_cull_face(GLenum) = 0;
virtual GLuint gl_gen_lists(GLsizei range) = 0;
diff --git a/Userland/Libraries/LibGL/GLUtils.cpp b/Userland/Libraries/LibGL/GLUtils.cpp
index 73bad7804c..20515e9039 100644
--- a/Userland/Libraries/LibGL/GLUtils.cpp
+++ b/Userland/Libraries/LibGL/GLUtils.cpp
@@ -20,6 +20,11 @@ void glDisable(GLenum cap)
g_gl_context->gl_disable(cap);
}
+GLboolean glIsEnabled(GLenum cap)
+{
+ return g_gl_context->gl_is_enabled(cap);
+}
+
void glFrontFace(GLenum mode)
{
g_gl_context->gl_front_face(mode);
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
index 4d832ed0a8..2bc4658631 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -597,6 +597,28 @@ void SoftwareGLContext::gl_disable(GLenum capability)
m_rasterizer.set_options(rasterizer_options);
}
+GLboolean SoftwareGLContext::gl_is_enabled(GLenum capability)
+{
+ RETURN_VALUE_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION, 0);
+
+ auto rasterizer_options = m_rasterizer.options();
+
+ switch (capability) {
+ case GL_CULL_FACE:
+ return m_cull_faces;
+ case GL_DEPTH_TEST:
+ return m_depth_test_enabled;
+ case GL_BLEND:
+ return m_blend_enabled;
+ case GL_ALPHA_TEST:
+ return m_alpha_test_enabled;
+ case GL_FOG:
+ return rasterizer_options.fog_enabled;
+ }
+
+ RETURN_VALUE_WITH_ERROR_IF(true, GL_INVALID_ENUM, 0);
+}
+
void SoftwareGLContext::gl_gen_textures(GLsizei n, GLuint* textures)
{
RETURN_WITH_ERROR_IF(n < 0, GL_INVALID_VALUE);
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h
index 2d15b5f89f..0ac2c46c97 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -52,6 +52,7 @@ public:
virtual void gl_viewport(GLint x, GLint y, GLsizei width, GLsizei height) override;
virtual void gl_enable(GLenum) override;
virtual void gl_disable(GLenum) override;
+ virtual GLboolean gl_is_enabled(GLenum) override;
virtual void gl_front_face(GLenum) override;
virtual void gl_cull_face(GLenum) override;
virtual GLuint gl_gen_lists(GLsizei range) override;