mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00:00
LibSoftGPU: Remove OpenGL type for depth test func
Replaces the GLenum used in the RasterizerConfig for selecting the depth test function with out own enum.
This commit is contained in:
parent
33e601800c
commit
74ed7713fa
3 changed files with 50 additions and 10 deletions
|
@ -2130,7 +2130,36 @@ void SoftwareGLContext::gl_depth_func(GLenum func)
|
|||
GL_INVALID_ENUM);
|
||||
|
||||
auto options = m_rasterizer.options();
|
||||
options.depth_func = func;
|
||||
|
||||
switch (func) {
|
||||
case GL_NEVER:
|
||||
options.depth_func = SoftGPU::DepthTestFunction::Never;
|
||||
break;
|
||||
case GL_ALWAYS:
|
||||
options.depth_func = SoftGPU::DepthTestFunction::Always;
|
||||
break;
|
||||
case GL_LESS:
|
||||
options.depth_func = SoftGPU::DepthTestFunction::Less;
|
||||
break;
|
||||
case GL_LEQUAL:
|
||||
options.depth_func = SoftGPU::DepthTestFunction::LessOrEqual;
|
||||
break;
|
||||
case GL_EQUAL:
|
||||
options.depth_func = SoftGPU::DepthTestFunction::Equal;
|
||||
break;
|
||||
case GL_NOTEQUAL:
|
||||
options.depth_func = SoftGPU::DepthTestFunction::NotEqual;
|
||||
break;
|
||||
case GL_GEQUAL:
|
||||
options.depth_func = SoftGPU::DepthTestFunction::GreaterOrEqual;
|
||||
break;
|
||||
case GL_GREATER:
|
||||
options.depth_func = SoftGPU::DepthTestFunction::Greater;
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
m_rasterizer.set_options(options);
|
||||
}
|
||||
|
||||
|
|
|
@ -285,26 +285,26 @@ static void rasterize_triangle(const RasterizerOptions& options, Gfx::Bitmap& re
|
|||
|
||||
bool pass = false;
|
||||
switch (options.depth_func) {
|
||||
case GL_ALWAYS:
|
||||
case DepthTestFunction::Always:
|
||||
pass = true;
|
||||
break;
|
||||
case GL_NEVER:
|
||||
case DepthTestFunction::Never:
|
||||
pass = false;
|
||||
break;
|
||||
case GL_GREATER:
|
||||
case DepthTestFunction::Greater:
|
||||
pass = z > *depth;
|
||||
break;
|
||||
case GL_GEQUAL:
|
||||
case DepthTestFunction::GreaterOrEqual:
|
||||
pass = z >= *depth;
|
||||
break;
|
||||
case GL_NOTEQUAL:
|
||||
case DepthTestFunction::NotEqual:
|
||||
#ifdef __SSE__
|
||||
pass = z != *depth;
|
||||
#else
|
||||
pass = bit_cast<u32>(z) != bit_cast<u32>(*depth);
|
||||
#endif
|
||||
break;
|
||||
case GL_EQUAL:
|
||||
case DepthTestFunction::Equal:
|
||||
#ifdef __SSE__
|
||||
pass = z == *depth;
|
||||
#else
|
||||
|
@ -322,10 +322,10 @@ static void rasterize_triangle(const RasterizerOptions& options, Gfx::Bitmap& re
|
|||
pass = bit_cast<u32>(z) == bit_cast<u32>(*depth);
|
||||
#endif
|
||||
break;
|
||||
case GL_LEQUAL:
|
||||
case DepthTestFunction::LessOrEqual:
|
||||
pass = z <= *depth;
|
||||
break;
|
||||
case GL_LESS:
|
||||
case DepthTestFunction::Less:
|
||||
pass = z < *depth;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,17 @@ enum class BlendFactor {
|
|||
SrcAlphaSaturate,
|
||||
};
|
||||
|
||||
enum class DepthTestFunction {
|
||||
Never,
|
||||
Always,
|
||||
Less,
|
||||
LessOrEqual,
|
||||
Equal,
|
||||
NotEqual,
|
||||
GreaterOrEqual,
|
||||
Greater,
|
||||
};
|
||||
|
||||
enum class WindingOrder {
|
||||
Clockwise,
|
||||
CounterClockwise,
|
||||
|
@ -69,7 +80,7 @@ struct RasterizerOptions {
|
|||
u32 color_mask { 0xffffffff };
|
||||
float depth_min { 0 };
|
||||
float depth_max { 1 };
|
||||
GLenum depth_func { GL_LESS };
|
||||
DepthTestFunction depth_func { DepthTestFunction::Less };
|
||||
GLenum polygon_mode { GL_FILL };
|
||||
FloatVector4 fog_color { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
float fog_density { 1.0f };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue