mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
LibGL: Implement glFogfv
This currently just sets the fog colour in the rasterizer.
This commit is contained in:
parent
ffa7da0ca5
commit
7f1cd54b80
Notes:
sideshowbarker
2024-07-18 05:18:04 +09:00
Author: https://github.com/Quaker762 Commit: https://github.com/SerenityOS/serenity/commit/7f1cd54b808 Pull-request: https://github.com/SerenityOS/serenity/pull/9603 Reviewed-by: https://github.com/alimpfard ✅
@ -7,6 +7,7 @@ set(SOURCES
|
||||
GLBlend.cpp
|
||||
GLColor.cpp
|
||||
GLContext.cpp
|
||||
GLFog.cpp
|
||||
GLLights.cpp
|
||||
GLLists.cpp
|
||||
GLMat.cpp
|
||||
|
@ -374,6 +374,7 @@ GLAPI void glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* i
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
virtual void gl_depth_range(GLdouble min, GLdouble max) = 0;
|
||||
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 present() = 0;
|
||||
};
|
||||
|
15
Userland/Libraries/LibGL/GLFog.cpp
Normal file
15
Userland/Libraries/LibGL/GLFog.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "GL/gl.h"
|
||||
#include "GLContext.h"
|
||||
|
||||
extern GL::GLContext* g_gl_context;
|
||||
|
||||
void glFogfv(GLenum pname, GLfloat* params)
|
||||
{
|
||||
g_gl_context->gl_fogfv(pname, params);
|
||||
}
|
@ -1745,6 +1745,26 @@ void SoftwareGLContext::gl_polygon_mode(GLenum face, GLenum mode)
|
||||
m_rasterizer.set_options(options);
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_fogfv(GLenum pname, GLfloat* 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] };
|
||||
break;
|
||||
default:
|
||||
RETURN_WITH_ERROR_IF(true, GL_INVALID_ENUM);
|
||||
}
|
||||
|
||||
m_rasterizer.set_options(options);
|
||||
}
|
||||
|
||||
void SoftwareGLContext::present()
|
||||
{
|
||||
m_rasterizer.blit_to(*m_frontbuffer);
|
||||
|
@ -87,6 +87,7 @@ public:
|
||||
virtual void gl_depth_range(GLdouble min, GLdouble max) override;
|
||||
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 present() override;
|
||||
|
||||
private:
|
||||
|
@ -33,6 +33,12 @@ struct RasterizerOptions {
|
||||
float depth_max { 1 };
|
||||
GLenum depth_func { GL_LESS };
|
||||
GLenum polygon_mode { GL_FILL };
|
||||
FloatVector4 fog_color {
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
};
|
||||
};
|
||||
|
||||
class SoftwareRasterizer final {
|
||||
|
Loading…
Reference in New Issue
Block a user