LibGL: Implenent glGetBooleanv

This commit is contained in:
Jesse Buhagiar 2021-08-17 18:38:34 +10:00 committed by Andreas Kling
parent 5d146628e1
commit 0b67369830
Notes: sideshowbarker 2024-07-18 05:34:26 +09:00
5 changed files with 32 additions and 0 deletions

View file

@ -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);

View file

@ -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;
};

View file

@ -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);

View file

@ -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);

View file

@ -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: