mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
LibSoftGPU: Remove OpenGL type for fog mode
Replaces the GLenum used to set up the fog mode in RasterizerOptions with out own enum.
This commit is contained in:
parent
74ed7713fa
commit
f4d29bf665
3 changed files with 21 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue