summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2021-12-29 23:57:29 +0100
committerAndreas Kling <kling@serenityos.org>2021-12-30 14:24:29 +0100
commit9bc8587c0d992699ad2360ef12c71a4175b79f47 (patch)
treecbe643c43e8c55e32a931fa4bb3fb446713a23e1 /Userland/Libraries
parent5e01ca29c5430fdc64ed5ba1d087ea8fd83b5cf7 (diff)
downloadserenity-9bc8587c0d992699ad2360ef12c71a4175b79f47.zip
LibGL: Implement fog in `GL_LINEAR` mode
The `GL_LINEAR` param was erroneously not picked up on. Also implement support for `GL_FOG_START` and `GL_FOG_END`, and make sure that the `gl_fog*` family of functions are optionally registered with the active list.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.cpp16
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h5
2 files changed, 15 insertions, 6 deletions
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
index d5a87f75b3..b8eeadc0a5 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -2374,16 +2374,14 @@ void SoftwareGLContext::gl_polygon_offset(GLfloat factor, GLfloat units)
void SoftwareGLContext::gl_fogfv(GLenum pname, GLfloat* params)
{
+ APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_fogfv, pname, params);
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
auto options = m_rasterizer.options();
switch (pname) {
case GL_FOG_COLOR:
- // Set rasterizer options fog color
- // NOTE: We purposefully don't check for `nullptr` here (as with other calls). The spec states nothing
- // about us checking for such things. If the programmer does so and hits SIGSEGV, that's on them.
- options.fog_color = FloatVector4 { params[0], params[1], params[2], params[3] };
+ options.fog_color = { params[0], params[1], params[2], params[3] };
break;
default:
RETURN_WITH_ERROR_IF(true, GL_INVALID_ENUM);
@@ -2394,6 +2392,7 @@ void SoftwareGLContext::gl_fogfv(GLenum pname, GLfloat* params)
void SoftwareGLContext::gl_fogf(GLenum pname, GLfloat param)
{
+ APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_fogf, pname, param);
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
RETURN_WITH_ERROR_IF(param < 0.0f, GL_INVALID_VALUE);
@@ -2403,6 +2402,12 @@ void SoftwareGLContext::gl_fogf(GLenum pname, GLfloat param)
case GL_FOG_DENSITY:
options.fog_density = param;
break;
+ case GL_FOG_END:
+ options.fog_end = param;
+ break;
+ case GL_FOG_START:
+ options.fog_start = param;
+ break;
default:
RETURN_WITH_ERROR_IF(true, GL_INVALID_ENUM);
}
@@ -2412,8 +2417,9 @@ void SoftwareGLContext::gl_fogf(GLenum pname, GLfloat param)
void SoftwareGLContext::gl_fogi(GLenum pname, GLint param)
{
+ APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_fogi, pname, param);
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
- RETURN_WITH_ERROR_IF(!(param == GL_EXP || param == GL_EXP2 || param != GL_LINEAR), GL_INVALID_ENUM);
+ RETURN_WITH_ERROR_IF(param != GL_LINEAR && param != GL_EXP && param != GL_EXP2, GL_INVALID_ENUM);
auto options = m_rasterizer.options();
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h
index 025936c4d8..8ef1452fce 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -321,7 +321,10 @@ private:
decltype(&SoftwareGLContext::gl_copy_tex_image_2d),
decltype(&SoftwareGLContext::gl_rect),
decltype(&SoftwareGLContext::gl_tex_gen),
- decltype(&SoftwareGLContext::gl_tex_gen_floatv)>;
+ decltype(&SoftwareGLContext::gl_tex_gen_floatv),
+ decltype(&SoftwareGLContext::gl_fogf),
+ decltype(&SoftwareGLContext::gl_fogfv),
+ decltype(&SoftwareGLContext::gl_fogi)>;
using ExtraSavedArguments = Variant<
FloatMatrix4x4>;