summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL
diff options
context:
space:
mode:
authorJesse Buhagiar <jooster669@gmail.com>2021-08-17 18:38:34 +1000
committerAndreas Kling <kling@serenityos.org>2021-08-18 00:35:26 +0200
commit0b673698301fe1b95d7a8aeb0121aedfebf154c8 (patch)
treea37b19166aad1c9dbcbf01cabdfe431cded50624 /Userland/Libraries/LibGL
parent5d146628e12438cadd5818f990338987a009ca0c (diff)
downloadserenity-0b673698301fe1b95d7a8aeb0121aedfebf154c8.zip
LibGL: Implenent `glGetBooleanv`
Diffstat (limited to 'Userland/Libraries/LibGL')
-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.cpp24
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h1
5 files changed, 32 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h
index 4ccd382f65..d3679291ca 100644
--- a/Userland/Libraries/LibGL/GL/gl.h
+++ b/Userland/Libraries/LibGL/GL/gl.h
@@ -357,6 +357,7 @@ GLAPI void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
GLAPI void glBindTexture(GLenum target, GLuint texture);
GLAPI void glActiveTexture(GLenum texture);
GLAPI void glGetFloatv(GLenum pname, GLfloat* params);
+GLAPI void glGetBooleanv(GLenum pname, GLboolean* data);
GLAPI void glDepthMask(GLboolean flag);
GLAPI void glEnableClientState(GLenum cap);
GLAPI void glDisableClientState(GLenum cap);
diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h
index 4c1c3ade5a..c04fcf350b 100644
--- a/Userland/Libraries/LibGL/GLContext.h
+++ b/Userland/Libraries/LibGL/GLContext.h
@@ -72,6 +72,7 @@ public:
virtual void gl_draw_arrays(GLenum mode, GLint first, GLsizei count) = 0;
virtual void gl_draw_elements(GLenum mode, GLsizei count, GLenum type, const void* indices) = 0;
virtual void gl_color_mask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) = 0;
+ virtual void gl_get_booleanv(GLenum pname, GLboolean* data) = 0;
virtual void present() = 0;
};
diff --git a/Userland/Libraries/LibGL/GLUtils.cpp b/Userland/Libraries/LibGL/GLUtils.cpp
index 67536bee26..aaaed19c57 100644
--- a/Userland/Libraries/LibGL/GLUtils.cpp
+++ b/Userland/Libraries/LibGL/GLUtils.cpp
@@ -95,6 +95,11 @@ void glGetFloatv(GLenum pname, GLfloat* params)
g_gl_context->gl_get_floatv(pname, params);
}
+void glGetBooleanv(GLenum pname, GLboolean* data)
+{
+ g_gl_context->gl_get_booleanv(pname, data);
+}
+
void glDepthMask(GLboolean flag)
{
g_gl_context->gl_depth_mask(flag);
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
index 01cb90f209..38647271e0 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -1392,6 +1392,30 @@ void SoftwareGLContext::gl_get_floatv(GLenum pname, GLfloat* params)
}
}
+void SoftwareGLContext::gl_get_booleanv(GLenum pname, GLboolean* data)
+{
+ RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
+
+ switch (pname) {
+ case GL_BLEND:
+ *data = m_blend_enabled ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_ALPHA_TEST:
+ *data = m_alpha_test_func ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_DEPTH_TEST:
+ *data = m_depth_test_enabled ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_CULL_FACE:
+ *data = m_cull_faces ? GL_TRUE : GL_FALSE;
+ break;
+ default:
+ // According to the Khronos docs, we always return GL_INVALID_ENUM if we encounter a non-accepted value
+ // for `pname`
+ RETURN_WITH_ERROR_IF(true, GL_INVALID_ENUM);
+ }
+}
+
void SoftwareGLContext::gl_depth_mask(GLboolean flag)
{
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_depth_mask, flag);
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h
index 05a49456f7..fb2d169f01 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -82,6 +82,7 @@ public:
virtual void gl_draw_arrays(GLenum mode, GLint first, GLsizei count) override;
virtual void gl_draw_elements(GLenum mode, GLsizei count, GLenum type, const void* indices) override;
virtual void gl_color_mask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) override;
+ virtual void gl_get_booleanv(GLenum pname, GLboolean* data) override;
virtual void present() override;
private: