diff options
author | Jesse Buhagiar <jooster669@gmail.com> | 2021-08-25 01:21:54 +1000 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-08-25 23:50:54 +0430 |
commit | d73cc3d0ebf2421c80b524dc27d01fd7f1802d69 (patch) | |
tree | 950b891c5c0e20581225a844752f3a3813e61293 | |
parent | f55d2a22af99e102039fa8a55d944ae1a7554ee3 (diff) | |
download | serenity-d73cc3d0ebf2421c80b524dc27d01fd7f1802d69.zip |
LibGL: Implement `glFogi`
-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 4dd39ff8ac..ac97e8b381 100644 --- a/Userland/Libraries/LibGL/GL/gl.h +++ b/Userland/Libraries/LibGL/GL/gl.h @@ -376,6 +376,7 @@ 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); +GLAPI void glFogi(GLenum pname, GLint param); #ifdef __cplusplus } diff --git a/Userland/Libraries/LibGL/GLContext.h b/Userland/Libraries/LibGL/GLContext.h index 131d4568f5..51793a9975 100644 --- a/Userland/Libraries/LibGL/GLContext.h +++ b/Userland/Libraries/LibGL/GLContext.h @@ -79,6 +79,7 @@ public: 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 gl_fogi(GLenum pname, GLint param) = 0; virtual void present() = 0; }; diff --git a/Userland/Libraries/LibGL/GLFog.cpp b/Userland/Libraries/LibGL/GLFog.cpp index 37fc2253e5..7f427f43dc 100644 --- a/Userland/Libraries/LibGL/GLFog.cpp +++ b/Userland/Libraries/LibGL/GLFog.cpp @@ -18,3 +18,8 @@ void glFogf(GLenum pname, GLfloat param) { g_gl_context->gl_fogf(pname, param); } + +void glFogi(GLenum pname, GLint param) +{ + g_gl_context->gl_fogi(pname, param); +} diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index 9ffc09de24..c7cd5b5922 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -1783,6 +1783,24 @@ void SoftwareGLContext::gl_fogf(GLenum pname, GLfloat param) m_rasterizer.set_options(options); } +void SoftwareGLContext::gl_fogi(GLenum pname, GLint 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); + + auto options = m_rasterizer.options(); + + switch (pname) { + case GL_FOG_MODE: + options.fog_mode = 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 48875f0eab..3239c13afb 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.h +++ b/Userland/Libraries/LibGL/SoftwareGLContext.h @@ -89,6 +89,7 @@ public: 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 gl_fogi(GLenum pname, GLint param) override; virtual void present() override; private: diff --git a/Userland/Libraries/LibGL/SoftwareRasterizer.h b/Userland/Libraries/LibGL/SoftwareRasterizer.h index 27c421032a..cfdd4b20c9 100644 --- a/Userland/Libraries/LibGL/SoftwareRasterizer.h +++ b/Userland/Libraries/LibGL/SoftwareRasterizer.h @@ -40,6 +40,7 @@ struct RasterizerOptions { 0.0f, }; GLfloat fog_density { 1.0f }; + GLenum fog_mode { GL_EXP }; }; class SoftwareRasterizer final { |