From 24c76741e85801f720d39468672e8a9f64c42977 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Wed, 22 Dec 2021 23:16:58 +0100 Subject: [PATCH] LibSoftGPU: Remove OpenGL type for front face selection Replaces the GLenum used for selecting the frontface in the rasterizer config with out own enum. --- Userland/Libraries/LibGL/SoftwareGLContext.cpp | 2 +- Userland/Libraries/LibSoftGPU/Device.cpp | 2 +- Userland/Libraries/LibSoftGPU/Device.h | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index b75de83362..3707b43fc4 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -904,7 +904,7 @@ void SoftwareGLContext::gl_front_face(GLenum face) m_front_face = face; auto rasterizer_options = m_rasterizer.options(); - rasterizer_options.front_face = face; + rasterizer_options.front_face = (face == GL_CW) ? SoftGPU::WindingOrder::Clockwise : SoftGPU::WindingOrder::CounterClockwise; m_rasterizer.set_options(rasterizer_options); } diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp index a12f344fe7..8da6745345 100644 --- a/Userland/Libraries/LibSoftGPU/Device.cpp +++ b/Userland/Libraries/LibSoftGPU/Device.cpp @@ -634,7 +634,7 @@ void Device::draw_primitives(GLenum primitive_type, FloatMatrix4x4 const& transf continue; if (m_options.enable_culling) { - bool is_front = (m_options.front_face == GL_CCW ? area < 0 : area > 0); + bool is_front = (m_options.front_face == WindingOrder::CounterClockwise ? area < 0 : area > 0); if (is_front && (m_options.culled_sides == GL_FRONT || m_options.culled_sides == GL_FRONT_AND_BACK)) continue; diff --git a/Userland/Libraries/LibSoftGPU/Device.h b/Userland/Libraries/LibSoftGPU/Device.h index 9448eb741b..64d3dfa504 100644 --- a/Userland/Libraries/LibSoftGPU/Device.h +++ b/Userland/Libraries/LibSoftGPU/Device.h @@ -51,6 +51,11 @@ enum class BlendFactor { SrcAlphaSaturate, }; +enum class WindingOrder { + Clockwise, + CounterClockwise, +}; + struct RasterizerOptions { bool shade_smooth { true }; bool enable_depth_test { false }; @@ -78,7 +83,7 @@ struct RasterizerOptions { float depth_offset_factor { 0 }; float depth_offset_constant { 0 }; bool enable_culling { false }; - GLenum front_face { GL_CCW }; + WindingOrder front_face { WindingOrder::CounterClockwise }; GLenum culled_sides { GL_BACK }; };