1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:37:35 +00:00

LibGL: Implement glAlphaFunc()

This implements glAlphaFunc() for setting alpha test func and ref value
and also allows enabling and disabling GL_ALPHA_TEST
This commit is contained in:
Stephan Unverwerth 2021-05-16 16:43:09 +02:00 committed by Andreas Kling
parent b8b8b4b566
commit 1bd754882d
6 changed files with 68 additions and 2 deletions

View file

@ -688,6 +688,11 @@ void SoftwareGLContext::gl_enable(GLenum capability)
rasterizer_options.enable_blending = true;
update_rasterizer_options = true;
break;
case GL_ALPHA_TEST:
m_alpha_test_enabled = true;
rasterizer_options.enable_alpha_test = true;
update_rasterizer_options = true;
break;
default:
m_error = GL_INVALID_ENUM;
break;
@ -723,6 +728,11 @@ void SoftwareGLContext::gl_disable(GLenum capability)
rasterizer_options.enable_blending = false;
update_rasterizer_options = false;
break;
case GL_ALPHA_TEST:
m_alpha_test_enabled = false;
rasterizer_options.enable_alpha_test = false;
update_rasterizer_options = false;
break;
default:
m_error = GL_INVALID_ENUM;
break;
@ -946,6 +956,29 @@ void SoftwareGLContext::gl_shade_model(GLenum mode)
m_rasterizer.set_options(options);
}
void SoftwareGLContext::gl_alpha_func(GLenum func, GLclampf ref)
{
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_alpha_func, func, ref);
if (m_in_draw_state) {
m_error = GL_INVALID_OPERATION;
return;
}
if (func < GL_NEVER || func > GL_ALWAYS) {
m_error = GL_INVALID_ENUM;
return;
}
m_alpha_test_func = func;
m_alpha_test_ref_value = ref;
auto options = m_rasterizer.options();
options.alpha_test_func = m_alpha_test_func;
options.alpha_test_ref_value = m_alpha_test_ref_value;
m_rasterizer.set_options(options);
}
void SoftwareGLContext::present()
{
m_rasterizer.blit_to(*m_frontbuffer);