1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:17:36 +00:00

LibGL: Implement glStencil* functions

This implements the context state for stencil testing functions and
operations. No rasterization is implemented.
This commit is contained in:
Jelle Raaijmakers 2021-12-01 15:21:00 +01:00 committed by Andreas Kling
parent 729349ce78
commit ea6bcda79c
7 changed files with 135 additions and 1 deletions

View file

@ -102,6 +102,8 @@ public:
virtual void gl_fogi(GLenum pname, GLint param) override;
virtual void gl_pixel_storei(GLenum pname, GLint param) override;
virtual void gl_scissor(GLint x, GLint y, GLsizei width, GLsizei height) override;
virtual void gl_stencil_func_separate(GLenum face, GLenum func, GLint ref, GLuint mask) override;
virtual void gl_stencil_op_separate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) override;
virtual void present() override;
private:
@ -164,8 +166,25 @@ private:
GLenum m_alpha_test_func = GL_ALWAYS;
GLclampf m_alpha_test_ref_value = 0;
// Stencil configuration
bool m_stencil_test_enabled { false };
struct StencilFunctionOptions {
GLenum func { GL_ALWAYS };
GLint reference_value { 0 };
GLuint mask { NumericLimits<GLuint>::max() };
};
StencilFunctionOptions m_stencil_backfacing_func;
StencilFunctionOptions m_stencil_frontfacing_func;
struct StencilOperationOptions {
GLenum op_fail { GL_KEEP };
GLenum op_depth_fail { GL_KEEP };
GLenum op_pass { GL_KEEP };
};
StencilOperationOptions m_stencil_backfacing_op;
StencilOperationOptions m_stencil_frontfacing_op;
GLenum m_current_read_buffer = GL_BACK;
GLenum m_current_draw_buffer = GL_BACK;
@ -245,7 +264,9 @@ private:
decltype(&SoftwareGLContext::gl_draw_elements),
decltype(&SoftwareGLContext::gl_depth_range),
decltype(&SoftwareGLContext::gl_polygon_offset),
decltype(&SoftwareGLContext::gl_scissor)>;
decltype(&SoftwareGLContext::gl_scissor),
decltype(&SoftwareGLContext::gl_stencil_func_separate),
decltype(&SoftwareGLContext::gl_stencil_op_separate)>;
using ExtraSavedArguments = Variant<
FloatMatrix4x4>;