mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:17:35 +00:00
LibGL: Implement glDepthMask
This commit is contained in:
parent
010e344a8e
commit
5f863016ca
7 changed files with 26 additions and 2 deletions
|
@ -263,6 +263,7 @@ typedef char GLchar;
|
||||||
typedef char GLbyte;
|
typedef char GLbyte;
|
||||||
typedef unsigned char GLuchar;
|
typedef unsigned char GLuchar;
|
||||||
typedef unsigned char GLubyte;
|
typedef unsigned char GLubyte;
|
||||||
|
typedef unsigned char GLboolean;
|
||||||
typedef short GLshort;
|
typedef short GLshort;
|
||||||
typedef unsigned short GLushort;
|
typedef unsigned short GLushort;
|
||||||
typedef int GLint;
|
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 glBindTexture(GLenum target, GLuint texture);
|
||||||
GLAPI void glActiveTexture(GLenum texture);
|
GLAPI void glActiveTexture(GLenum texture);
|
||||||
GLAPI void glGetFloatv(GLenum pname, GLfloat* params);
|
GLAPI void glGetFloatv(GLenum pname, GLfloat* params);
|
||||||
|
GLAPI void glDepthMask(GLboolean flag);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
virtual void gl_bind_texture(GLenum target, GLuint texture) = 0;
|
virtual void gl_bind_texture(GLenum target, GLuint texture) = 0;
|
||||||
virtual void gl_active_texture(GLenum texture) = 0;
|
virtual void gl_active_texture(GLenum texture) = 0;
|
||||||
virtual void gl_get_floatv(GLenum pname, GLfloat* params) = 0;
|
virtual void gl_get_floatv(GLenum pname, GLfloat* params) = 0;
|
||||||
|
virtual void gl_depth_mask(GLboolean flag) = 0;
|
||||||
|
|
||||||
virtual void present() = 0;
|
virtual void present() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,3 +89,8 @@ void glGetFloatv(GLenum pname, GLfloat* params)
|
||||||
{
|
{
|
||||||
g_gl_context->gl_get_floatv(pname, 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()
|
void SoftwareGLContext::present()
|
||||||
{
|
{
|
||||||
m_rasterizer.blit_to(*m_frontbuffer);
|
m_rasterizer.blit_to(*m_frontbuffer);
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
virtual void gl_bind_texture(GLenum target, GLuint texture) override;
|
virtual void gl_bind_texture(GLenum target, GLuint texture) override;
|
||||||
virtual void gl_active_texture(GLenum texture) override;
|
virtual void gl_active_texture(GLenum texture) override;
|
||||||
virtual void gl_get_floatv(GLenum pname, GLfloat* params) override;
|
virtual void gl_get_floatv(GLenum pname, GLfloat* params) override;
|
||||||
|
virtual void gl_depth_mask(GLboolean flag) override;
|
||||||
|
|
||||||
virtual void present() override;
|
virtual void present() override;
|
||||||
|
|
||||||
|
@ -196,7 +197,8 @@ private:
|
||||||
decltype(&SoftwareGLContext::gl_alpha_func),
|
decltype(&SoftwareGLContext::gl_alpha_func),
|
||||||
decltype(&SoftwareGLContext::gl_hint),
|
decltype(&SoftwareGLContext::gl_hint),
|
||||||
decltype(&SoftwareGLContext::gl_read_buffer),
|
decltype(&SoftwareGLContext::gl_read_buffer),
|
||||||
decltype(&SoftwareGLContext::gl_tex_parameter)>;
|
decltype(&SoftwareGLContext::gl_tex_parameter),
|
||||||
|
decltype(&SoftwareGLContext::gl_depth_mask)>;
|
||||||
|
|
||||||
using ExtraSavedArguments = Variant<
|
using ExtraSavedArguments = Variant<
|
||||||
FloatMatrix4x4>;
|
FloatMatrix4x4>;
|
||||||
|
|
|
@ -265,7 +265,9 @@ static void rasterize_triangle(const RasterizerOptions& options, Gfx::Bitmap& re
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
*depth = z;
|
if (options.enable_depth_write)
|
||||||
|
*depth = z;
|
||||||
|
|
||||||
z_pass_count++;
|
z_pass_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace GL {
|
||||||
struct RasterizerOptions {
|
struct RasterizerOptions {
|
||||||
bool shade_smooth { true };
|
bool shade_smooth { true };
|
||||||
bool enable_depth_test { false };
|
bool enable_depth_test { false };
|
||||||
|
bool enable_depth_write { true };
|
||||||
bool enable_alpha_test { false };
|
bool enable_alpha_test { false };
|
||||||
GLenum alpha_test_func { GL_ALWAYS };
|
GLenum alpha_test_func { GL_ALWAYS };
|
||||||
float alpha_test_ref_value { 0 };
|
float alpha_test_ref_value { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue