diff options
author | Jesse Buhagiar <jooster669@gmail.com> | 2021-08-25 01:17:28 +1000 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-08-25 23:50:54 +0430 |
commit | f55d2a22af99e102039fa8a55d944ae1a7554ee3 (patch) | |
tree | 403a5e9832504272b09386d9813f24d6b2c6bf67 /Userland | |
parent | 7f1cd54b8083c55aef569ae1251043c24f64516a (diff) | |
download | serenity-f55d2a22af99e102039fa8a55d944ae1a7554ee3.zip |
LibGL: Implement `glFogf`
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGL/GL/gl.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLContext.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/GLFog.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.cpp | 18 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareRasterizer.h | 1 |
6 files changed, 27 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/GL/gl.h b/Userland/Libraries/LibGL/GL/gl.h index d165f8124a..4dd39ff8ac 100644 --- a/Userland/Libraries/LibGL/GL/gl.h +++ b/Userland/Libraries/LibGL/GL/gl.h @@ -375,6 +375,7 @@ GLAPI void glDepthRange(GLdouble nearVal, GLdouble farVal); GLAPI void glDepthFunc(GLenum func); GLAPI void glPolygonMode(GLenum face, GLenum mode); GLAPI void glFogfv(GLenum mode, GLfloat* params); +GLAPI void glFogf(GLenum pname, GLfloat param); #ifdef __cplusplus } diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index 30bb6342d1..131d4568f5 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -78,6 +78,7 @@ public: virtual void gl_depth_func(GLenum func) = 0; virtual void gl_polygon_mode(GLenum face, GLenum mode) = 0; virtual void gl_fogfv(GLenum pname, GLfloat* params) = 0; + virtual void gl_fogf(GLenum pname, GLfloat params) = 0; virtual void present() = 0; }; diff --git a/Userland/Libraries/LibGL/GLFog.cpp b/Userland/Libraries/LibGL/GLFog.cpp index 381119c3de..37fc2253e5 100644 --- a/Userland/Libraries/LibGL/GLFog.cpp +++ b/Userland/Libraries/LibGL/GLFog.cpp @@ -13,3 +13,8 @@ void glFogfv(GLenum pname, GLfloat* params) { g_gl_context->gl_fogfv(pname, params); } + +void glFogf(GLenum pname, GLfloat param) +{ + g_gl_context->gl_fogf(pname, param); +} diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index ca73b70c20..9ffc09de24 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -1765,6 +1765,24 @@ void SoftwareGLContext::gl_fogfv(GLenum pname, GLfloat* params) m_rasterizer.set_options(options); } +void SoftwareGLContext::gl_fogf(GLenum pname, GLfloat param) +{ + RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); + RETURN_WITH_ERROR_IF(param < 0.0f, GL_INVALID_VALUE); + + auto options = m_rasterizer.options(); + + switch (pname) { + case GL_FOG_DENSITY: + options.fog_density = param; + break; + default: + RETURN_WITH_ERROR_IF(true, GL_INVALID_ENUM); + } + + m_rasterizer.set_options(options); +} + void SoftwareGLContext::present() { m_rasterizer.blit_to(*m_frontbuffer); diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h index 5b84ceafd0..48875f0eab 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.h +++ b/Userland/Libraries/LibGL/SoftwareGLContext.h @@ -88,6 +88,7 @@ public: virtual void gl_depth_func(GLenum func) override; virtual void gl_polygon_mode(GLenum face, GLenum mode) override; virtual void gl_fogfv(GLenum pname, GLfloat* params) override; + virtual void gl_fogf(GLenum pname, GLfloat param) override; virtual void present() override; private: diff --git a/Userland/Libraries/LibGL/SoftwareRasterizer.h b/Userland/Libraries/LibGL/SoftwareRasterizer.h index c110f794e9..27c421032a 100644 --- a/Userland/Libraries/LibGL/SoftwareRasterizer.h +++ b/Userland/Libraries/LibGL/SoftwareRasterizer.h @@ -39,6 +39,7 @@ struct RasterizerOptions { 0.0f, 0.0f, }; + GLfloat fog_density { 1.0f }; }; class SoftwareRasterizer final { |