diff options
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.cpp | 31 | ||||
-rw-r--r-- | Userland/Libraries/LibSoftGPU/Device.cpp | 16 | ||||
-rw-r--r-- | Userland/Libraries/LibSoftGPU/Device.h | 13 |
3 files changed, 50 insertions, 10 deletions
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index e17f0661e1..dcf8225779 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -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); } diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp index d5ddcd36b7..71b00eb70d 100644 --- a/Userland/Libraries/LibSoftGPU/Device.cpp +++ b/Userland/Libraries/LibSoftGPU/Device.cpp @@ -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; } diff --git a/Userland/Libraries/LibSoftGPU/Device.h b/Userland/Libraries/LibSoftGPU/Device.h index 01f90a0f33..281600439e 100644 --- a/Userland/Libraries/LibSoftGPU/Device.h +++ b/Userland/Libraries/LibSoftGPU/Device.h @@ -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 }; |