summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL
diff options
context:
space:
mode:
authorJesse Buhagiar <jooster669@gmail.com>2021-08-17 18:58:21 +1000
committerAndreas Kling <kling@serenityos.org>2021-08-18 00:35:26 +0200
commit8ad42e67712966e0531696da4def97c4b9efa07e (patch)
treea8d39b96dda620ecc4ed7d570f889b66fce51775 /Userland/Libraries/LibGL
parent0b673698301fe1b95d7a8aeb0121aedfebf154c8 (diff)
downloadserenity-8ad42e67712966e0531696da4def97c4b9efa07e.zip
LibGL: Implement `glGetIntegerv`
Diffstat (limited to 'Userland/Libraries/LibGL')
-rw-r--r--Userland/Libraries/LibGL/GL/gl.h3
-rw-r--r--Userland/Libraries/LibGL/GLContext.h1
-rw-r--r--Userland/Libraries/LibGL/GLUtils.cpp5
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.cpp18
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h1
5 files changed, 28 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h
index d3679291ca..605f1578d0 100644
--- a/Userland/Libraries/LibGL/GL/gl.h
+++ b/Userland/Libraries/LibGL/GL/gl.h
@@ -64,6 +64,8 @@ extern "C" {
// Alpha blending
#define GL_BLEND 0x0BE2
+#define GL_BLEND_SRC_ALPHA 0x0302
+#define GL_BLEND_DST_ALPHA 0x0304
// Utility
#define GL_VENDOR 0x1F00
@@ -358,6 +360,7 @@ 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 glGetIntegerv(GLenum pname, GLint* 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 c04fcf350b..d269026635 100644
--- a/Userland/Libraries/LibGL/GLContext.h
+++ b/Userland/Libraries/LibGL/GLContext.h
@@ -73,6 +73,7 @@ public:
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 gl_get_integerv(GLenum pname, GLint* data) = 0;
virtual void present() = 0;
};
diff --git a/Userland/Libraries/LibGL/GLUtils.cpp b/Userland/Libraries/LibGL/GLUtils.cpp
index aaaed19c57..95f2b68cc6 100644
--- a/Userland/Libraries/LibGL/GLUtils.cpp
+++ b/Userland/Libraries/LibGL/GLUtils.cpp
@@ -100,6 +100,11 @@ void glGetBooleanv(GLenum pname, GLboolean* data)
g_gl_context->gl_get_booleanv(pname, data);
}
+void glGetIntegerv(GLenum pname, GLint* data)
+{
+ g_gl_context->gl_get_integerv(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 38647271e0..a3370a1e9a 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -1416,6 +1416,24 @@ void SoftwareGLContext::gl_get_booleanv(GLenum pname, GLboolean* data)
}
}
+void SoftwareGLContext::gl_get_integerv(GLenum pname, GLint* data)
+{
+ RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
+
+ switch (pname) {
+ case GL_BLEND_SRC_ALPHA:
+ *data = m_blend_source_factor;
+ break;
+ case GL_BLEND_DST_ALPHA:
+ *data = m_blend_destination_factor;
+ 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 fb2d169f01..abcdf7f19e 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -83,6 +83,7 @@ public:
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 gl_get_integerv(GLenum pname, GLint* data) override;
virtual void present() override;
private: