mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
LibSoftGPU: Remove OpenGL type for alpha test func
Replaces the OpenGL enum used for setting the alpha test func in RasterizerOptions with out own enum.
This commit is contained in:
parent
7d49015403
commit
40bd73bdef
3 changed files with 53 additions and 10 deletions
|
@ -1159,7 +1159,36 @@ void SoftwareGLContext::gl_alpha_func(GLenum func, GLclampf ref)
|
||||||
m_alpha_test_ref_value = ref;
|
m_alpha_test_ref_value = ref;
|
||||||
|
|
||||||
auto options = m_rasterizer.options();
|
auto options = m_rasterizer.options();
|
||||||
options.alpha_test_func = m_alpha_test_func;
|
|
||||||
|
switch (func) {
|
||||||
|
case GL_NEVER:
|
||||||
|
options.alpha_test_func = SoftGPU::AlphaTestFunction::Never;
|
||||||
|
break;
|
||||||
|
case GL_ALWAYS:
|
||||||
|
options.alpha_test_func = SoftGPU::AlphaTestFunction::Always;
|
||||||
|
break;
|
||||||
|
case GL_LESS:
|
||||||
|
options.alpha_test_func = SoftGPU::AlphaTestFunction::Less;
|
||||||
|
break;
|
||||||
|
case GL_LEQUAL:
|
||||||
|
options.alpha_test_func = SoftGPU::AlphaTestFunction::LessOrEqual;
|
||||||
|
break;
|
||||||
|
case GL_EQUAL:
|
||||||
|
options.alpha_test_func = SoftGPU::AlphaTestFunction::Equal;
|
||||||
|
break;
|
||||||
|
case GL_NOTEQUAL:
|
||||||
|
options.alpha_test_func = SoftGPU::AlphaTestFunction::NotEqual;
|
||||||
|
break;
|
||||||
|
case GL_GEQUAL:
|
||||||
|
options.alpha_test_func = SoftGPU::AlphaTestFunction::GreaterOrEqual;
|
||||||
|
break;
|
||||||
|
case GL_GREATER:
|
||||||
|
options.alpha_test_func = SoftGPU::AlphaTestFunction::Greater;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
|
||||||
options.alpha_test_ref_value = m_alpha_test_ref_value;
|
options.alpha_test_ref_value = m_alpha_test_ref_value;
|
||||||
m_rasterizer.set_options(options);
|
m_rasterizer.set_options(options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,11 +396,11 @@ static void rasterize_triangle(const RasterizerOptions& options, Gfx::Bitmap& re
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.enable_alpha_test && options.alpha_test_func != GL_ALWAYS) {
|
if (options.enable_alpha_test && options.alpha_test_func != AlphaTestFunction::Always) {
|
||||||
// FIXME: I'm not sure if this is the right place to test this.
|
// FIXME: I'm not sure if this is the right place to test this.
|
||||||
// If we tested this right at the beginning of our rasterizer routine
|
// If we tested this right at the beginning of our rasterizer routine
|
||||||
// we could skip a lot of work but the GL spec might disagree.
|
// we could skip a lot of work but the GL spec might disagree.
|
||||||
if (options.alpha_test_func == GL_NEVER)
|
if (options.alpha_test_func == AlphaTestFunction::Never)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (int y = 0; y < RASTERIZER_BLOCK_SIZE; y++) {
|
for (int y = 0; y < RASTERIZER_BLOCK_SIZE; y++) {
|
||||||
|
@ -412,24 +412,27 @@ static void rasterize_triangle(const RasterizerOptions& options, Gfx::Bitmap& re
|
||||||
bool passed = true;
|
bool passed = true;
|
||||||
|
|
||||||
switch (options.alpha_test_func) {
|
switch (options.alpha_test_func) {
|
||||||
case GL_LESS:
|
case AlphaTestFunction::Less:
|
||||||
passed = src->w() < options.alpha_test_ref_value;
|
passed = src->w() < options.alpha_test_ref_value;
|
||||||
break;
|
break;
|
||||||
case GL_EQUAL:
|
case AlphaTestFunction::Equal:
|
||||||
passed = src->w() == options.alpha_test_ref_value;
|
passed = src->w() == options.alpha_test_ref_value;
|
||||||
break;
|
break;
|
||||||
case GL_LEQUAL:
|
case AlphaTestFunction::LessOrEqual:
|
||||||
passed = src->w() <= options.alpha_test_ref_value;
|
passed = src->w() <= options.alpha_test_ref_value;
|
||||||
break;
|
break;
|
||||||
case GL_GREATER:
|
case AlphaTestFunction::Greater:
|
||||||
passed = src->w() > options.alpha_test_ref_value;
|
passed = src->w() > options.alpha_test_ref_value;
|
||||||
break;
|
break;
|
||||||
case GL_NOTEQUAL:
|
case AlphaTestFunction::NotEqual:
|
||||||
passed = src->w() != options.alpha_test_ref_value;
|
passed = src->w() != options.alpha_test_ref_value;
|
||||||
break;
|
break;
|
||||||
case GL_GEQUAL:
|
case AlphaTestFunction::GreaterOrEqual:
|
||||||
passed = src->w() >= options.alpha_test_ref_value;
|
passed = src->w() >= options.alpha_test_ref_value;
|
||||||
break;
|
break;
|
||||||
|
case AlphaTestFunction::Never:
|
||||||
|
case AlphaTestFunction::Always:
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!passed)
|
if (!passed)
|
||||||
|
|
|
@ -26,12 +26,23 @@
|
||||||
|
|
||||||
namespace SoftGPU {
|
namespace SoftGPU {
|
||||||
|
|
||||||
|
enum class AlphaTestFunction {
|
||||||
|
Never,
|
||||||
|
Always,
|
||||||
|
Less,
|
||||||
|
LessOrEqual,
|
||||||
|
Equal,
|
||||||
|
NotEqual,
|
||||||
|
GreaterOrEqual,
|
||||||
|
Greater,
|
||||||
|
};
|
||||||
|
|
||||||
struct RasterizerOptions {
|
struct RasterizerOptions {
|
||||||
bool shade_smooth { true };
|
bool shade_smooth { true };
|
||||||
bool enable_depth_test { false };
|
bool enable_depth_test { false };
|
||||||
bool enable_depth_write { true };
|
bool enable_depth_write { true };
|
||||||
bool enable_alpha_test { false };
|
bool enable_alpha_test { false };
|
||||||
GLenum alpha_test_func { GL_ALWAYS };
|
AlphaTestFunction alpha_test_func { AlphaTestFunction::Always };
|
||||||
float alpha_test_ref_value { 0 };
|
float alpha_test_ref_value { 0 };
|
||||||
bool enable_blending { false };
|
bool enable_blending { false };
|
||||||
GLenum blend_source_factor { GL_ONE };
|
GLenum blend_source_factor { GL_ONE };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue