mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00:00
LibGL: Add supporting code for depth buffer
This adds glClearDepth() and new caps for enabling and disabling the depth buffer with glEnable() and glDisable()
This commit is contained in:
parent
d922c2f5f3
commit
a8fc4be47a
6 changed files with 57 additions and 4 deletions
|
@ -55,12 +55,18 @@ void SoftwareGLContext::gl_clear(GLbitfield mask)
|
|||
return;
|
||||
}
|
||||
|
||||
if (mask & GL_COLOR_BUFFER_BIT) {
|
||||
m_rasterizer.clear_color(m_clear_color);
|
||||
m_error = GL_NO_ERROR;
|
||||
} else {
|
||||
if (mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) {
|
||||
m_error = GL_INVALID_ENUM;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mask & GL_COLOR_BUFFER_BIT)
|
||||
m_rasterizer.clear_color(m_clear_color);
|
||||
|
||||
if (mask & GL_DEPTH_BUFFER_BIT)
|
||||
m_rasterizer.clear_depth(static_cast<float>(m_clear_depth));
|
||||
|
||||
m_error = GL_NO_ERROR;
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_clear_color(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
|
||||
|
@ -74,6 +80,17 @@ void SoftwareGLContext::gl_clear_color(GLclampf red, GLclampf green, GLclampf bl
|
|||
m_error = GL_NO_ERROR;
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_clear_depth(GLdouble depth)
|
||||
{
|
||||
if (m_in_draw_state) {
|
||||
m_error = GL_INVALID_OPERATION;
|
||||
return;
|
||||
}
|
||||
|
||||
m_clear_depth = depth;
|
||||
m_error = GL_NO_ERROR;
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_color(GLdouble r, GLdouble g, GLdouble b, GLdouble a)
|
||||
{
|
||||
m_current_vertex_color = { (float)r, (float)g, (float)b, (float)a };
|
||||
|
@ -601,14 +618,25 @@ void SoftwareGLContext::gl_enable(GLenum capability)
|
|||
return;
|
||||
}
|
||||
|
||||
auto rasterizer_options = m_rasterizer.options();
|
||||
bool update_rasterizer_options = false;
|
||||
|
||||
switch (capability) {
|
||||
case GL_CULL_FACE:
|
||||
m_cull_faces = true;
|
||||
break;
|
||||
case GL_DEPTH_TEST:
|
||||
m_depth_test_enabled = true;
|
||||
rasterizer_options.enable_depth_test = true;
|
||||
update_rasterizer_options = true;
|
||||
break;
|
||||
default:
|
||||
m_error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
|
||||
if (update_rasterizer_options)
|
||||
m_rasterizer.set_options(rasterizer_options);
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_disable(GLenum capability)
|
||||
|
@ -618,14 +646,25 @@ void SoftwareGLContext::gl_disable(GLenum capability)
|
|||
return;
|
||||
}
|
||||
|
||||
auto rasterizer_options = m_rasterizer.options();
|
||||
bool update_rasterizer_options = false;
|
||||
|
||||
switch (capability) {
|
||||
case GL_CULL_FACE:
|
||||
m_cull_faces = false;
|
||||
break;
|
||||
case GL_DEPTH_TEST:
|
||||
m_depth_test_enabled = false;
|
||||
rasterizer_options.enable_depth_test = false;
|
||||
update_rasterizer_options = true;
|
||||
break;
|
||||
default:
|
||||
m_error = GL_INVALID_ENUM;
|
||||
break;
|
||||
}
|
||||
|
||||
if (update_rasterizer_options)
|
||||
m_rasterizer.set_options(rasterizer_options);
|
||||
}
|
||||
|
||||
void SoftwareGLContext::gl_front_face(GLenum face)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue