diff options
author | Stephan Unverwerth <s.unverwerth@serenityos.org> | 2021-12-22 23:44:29 +0100 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-12-24 05:10:28 -0800 |
commit | f4d29bf665ee98b430c4eb7b80c86824eb147db2 (patch) | |
tree | e1cc7732f4548ed2fbecaa1fe1254e76ac2e11d4 /Userland/Libraries | |
parent | 74ed7713faaf5f7ebf378445ab5096f242a4ef22 (diff) | |
download | serenity-f4d29bf665ee98b430c4eb7b80c86824eb147db2.zip |
LibSoftGPU: Remove OpenGL type for fog mode
Replaces the GLenum used to set up the fog mode in RasterizerOptions
with out own enum.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.cpp | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibSoftGPU/Device.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibSoftGPU/Device.h | 8 |
3 files changed, 21 insertions, 5 deletions
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index dcf8225779..d73344159d 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -2356,7 +2356,17 @@ void SoftwareGLContext::gl_fogi(GLenum pname, GLint param) switch (pname) { case GL_FOG_MODE: - options.fog_mode = param; + switch (param) { + case GL_LINEAR: + options.fog_mode = SoftGPU::FogMode::Linear; + break; + case GL_EXP: + options.fog_mode = SoftGPU::FogMode::Exp; + break; + case GL_EXP2: + options.fog_mode = SoftGPU::FogMode::Exp2; + break; + } break; default: RETURN_WITH_ERROR_IF(true, GL_INVALID_ENUM); diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp index 71b00eb70d..0d7a6c6149 100644 --- a/Userland/Libraries/LibSoftGPU/Device.cpp +++ b/Userland/Libraries/LibSoftGPU/Device.cpp @@ -687,13 +687,13 @@ void Device::submit_triangle(const Triangle& triangle, Vector<size_t> const& ena if (m_options.fog_enabled) { float factor = 0.0f; switch (m_options.fog_mode) { - case GL_LINEAR: + case FogMode::Linear: factor = (m_options.fog_end - z) / (m_options.fog_end - m_options.fog_start); break; - case GL_EXP: + case FogMode::Exp: factor = exp(-((m_options.fog_density * z))); break; - case GL_EXP2: + case FogMode::Exp2: factor = exp(-((m_options.fog_density * z) * (m_options.fog_density * z))); break; default: diff --git a/Userland/Libraries/LibSoftGPU/Device.h b/Userland/Libraries/LibSoftGPU/Device.h index 281600439e..0f04b05ce4 100644 --- a/Userland/Libraries/LibSoftGPU/Device.h +++ b/Userland/Libraries/LibSoftGPU/Device.h @@ -62,6 +62,12 @@ enum class DepthTestFunction { Greater, }; +enum FogMode { + Linear, + Exp, + Exp2 +}; + enum class WindingOrder { Clockwise, CounterClockwise, @@ -84,7 +90,7 @@ struct RasterizerOptions { GLenum polygon_mode { GL_FILL }; FloatVector4 fog_color { 0.0f, 0.0f, 0.0f, 0.0f }; float fog_density { 1.0f }; - GLenum fog_mode { GL_EXP }; + FogMode fog_mode { FogMode::Exp }; bool fog_enabled { false }; float fog_start { 0.0f }; float fog_end { 1.0f }; |