mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibGL: Implement glClearDepthf
and store as float
Our API still specifies it as a double, but internally we communicate a float to the rasterizer. Additionally, clamp the value to 0..1 as described in the spec.
This commit is contained in:
parent
36a732e98e
commit
44a3d5c101
4 changed files with 9 additions and 3 deletions
|
@ -474,6 +474,7 @@ GLAPI void glBegin(GLenum mode);
|
|||
GLAPI void glClear(GLbitfield mask);
|
||||
GLAPI void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
||||
GLAPI void glClearDepth(GLdouble depth);
|
||||
GLAPI void glClearDepthf(GLfloat depth);
|
||||
GLAPI void glClearStencil(GLint s);
|
||||
GLAPI void glColor3d(GLdouble r, GLdouble g, GLdouble b);
|
||||
GLAPI void glColor3dv(GLdouble const* v);
|
||||
|
|
|
@ -50,6 +50,11 @@ void glClearDepth(GLdouble depth)
|
|||
g_gl_context->gl_clear_depth(depth);
|
||||
}
|
||||
|
||||
void glClearDepthf(GLfloat depth)
|
||||
{
|
||||
g_gl_context->gl_clear_depth(static_cast<double>(depth));
|
||||
}
|
||||
|
||||
void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
|
||||
{
|
||||
g_gl_context->gl_color_mask(red, green, blue, alpha);
|
||||
|
|
|
@ -267,7 +267,7 @@ void SoftwareGLContext::gl_clear(GLbitfield mask)
|
|||
m_rasterizer.clear_color(m_clear_color);
|
||||
|
||||
if (mask & GL_DEPTH_BUFFER_BIT)
|
||||
m_rasterizer.clear_depth(static_cast<float>(m_clear_depth));
|
||||
m_rasterizer.clear_depth(m_clear_depth);
|
||||
|
||||
if (mask & GL_STENCIL_BUFFER_BIT)
|
||||
m_rasterizer.clear_stencil(m_clear_stencil);
|
||||
|
@ -288,7 +288,7 @@ void SoftwareGLContext::gl_clear_depth(GLdouble depth)
|
|||
|
||||
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
|
||||
|
||||
m_clear_depth = depth;
|
||||
m_clear_depth = clamp(static_cast<float>(depth), 0.f, 1.f);
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_clear_stencil(GLint s)
|
||||
|
|
|
@ -208,7 +208,7 @@ private:
|
|||
Gfx::IntRect m_viewport;
|
||||
|
||||
FloatVector4 m_clear_color { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
double m_clear_depth { 1.0 };
|
||||
float m_clear_depth { 1.f };
|
||||
u8 m_clear_stencil { 0 };
|
||||
|
||||
FloatVector4 m_current_vertex_color = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue