mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibGL: Implement glDepthMask
This commit is contained in:
parent
010e344a8e
commit
5f863016ca
Notes:
sideshowbarker
2024-07-18 06:58:03 +09:00
Author: https://github.com/sunverwerth Commit: https://github.com/SerenityOS/serenity/commit/5f863016ca8 Pull-request: https://github.com/SerenityOS/serenity/pull/9382 Reviewed-by: https://github.com/alimpfard
@ -263,6 +263,7 @@ typedef char GLchar;
|
||||
typedef char GLbyte;
|
||||
typedef unsigned char GLuchar;
|
||||
typedef unsigned char GLubyte;
|
||||
typedef unsigned char GLboolean;
|
||||
typedef short GLshort;
|
||||
typedef unsigned short GLushort;
|
||||
typedef int GLint;
|
||||
@ -352,6 +353,7 @@ GLAPI void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
|
||||
GLAPI void glBindTexture(GLenum target, GLuint texture);
|
||||
GLAPI void glActiveTexture(GLenum texture);
|
||||
GLAPI void glGetFloatv(GLenum pname, GLfloat* params);
|
||||
GLAPI void glDepthMask(GLboolean flag);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
virtual void gl_bind_texture(GLenum target, GLuint texture) = 0;
|
||||
virtual void gl_active_texture(GLenum texture) = 0;
|
||||
virtual void gl_get_floatv(GLenum pname, GLfloat* params) = 0;
|
||||
virtual void gl_depth_mask(GLboolean flag) = 0;
|
||||
|
||||
virtual void present() = 0;
|
||||
};
|
||||
|
@ -89,3 +89,8 @@ void glGetFloatv(GLenum pname, GLfloat* params)
|
||||
{
|
||||
g_gl_context->gl_get_floatv(pname, params);
|
||||
}
|
||||
|
||||
void glDepthMask(GLboolean flag)
|
||||
{
|
||||
g_gl_context->gl_depth_mask(flag);
|
||||
}
|
||||
|
@ -1392,6 +1392,17 @@ void SoftwareGLContext::gl_get_floatv(GLenum pname, GLfloat* params)
|
||||
}
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_depth_mask(GLboolean flag)
|
||||
{
|
||||
APPEND_TO_CALL_LIST_AND_RETURN_IF_NEEDED(gl_depth_mask, flag);
|
||||
|
||||
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
|
||||
|
||||
auto options = m_rasterizer.options();
|
||||
options.enable_depth_write = (flag != GL_FALSE);
|
||||
m_rasterizer.set_options(options);
|
||||
}
|
||||
|
||||
void SoftwareGLContext::present()
|
||||
{
|
||||
m_rasterizer.blit_to(*m_frontbuffer);
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
virtual void gl_bind_texture(GLenum target, GLuint texture) override;
|
||||
virtual void gl_active_texture(GLenum texture) override;
|
||||
virtual void gl_get_floatv(GLenum pname, GLfloat* params) override;
|
||||
virtual void gl_depth_mask(GLboolean flag) override;
|
||||
|
||||
virtual void present() override;
|
||||
|
||||
@ -196,7 +197,8 @@ private:
|
||||
decltype(&SoftwareGLContext::gl_alpha_func),
|
||||
decltype(&SoftwareGLContext::gl_hint),
|
||||
decltype(&SoftwareGLContext::gl_read_buffer),
|
||||
decltype(&SoftwareGLContext::gl_tex_parameter)>;
|
||||
decltype(&SoftwareGLContext::gl_tex_parameter),
|
||||
decltype(&SoftwareGLContext::gl_depth_mask)>;
|
||||
|
||||
using ExtraSavedArguments = Variant<
|
||||
FloatMatrix4x4>;
|
||||
|
@ -265,7 +265,9 @@ static void rasterize_triangle(const RasterizerOptions& options, Gfx::Bitmap& re
|
||||
continue;
|
||||
}
|
||||
|
||||
*depth = z;
|
||||
if (options.enable_depth_write)
|
||||
*depth = z;
|
||||
|
||||
z_pass_count++;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ namespace GL {
|
||||
struct RasterizerOptions {
|
||||
bool shade_smooth { true };
|
||||
bool enable_depth_test { false };
|
||||
bool enable_depth_write { true };
|
||||
bool enable_alpha_test { false };
|
||||
GLenum alpha_test_func { GL_ALWAYS };
|
||||
float alpha_test_ref_value { 0 };
|
||||
|
Loading…
Reference in New Issue
Block a user