fixing d3d11 depth buffers, adding depth buffer clear support

This commit is contained in:
Noel Berry
2021-02-21 23:00:37 -08:00
parent a72cd5cab6
commit 2de541fb18
10 changed files with 198 additions and 27 deletions

View File

@ -749,13 +749,24 @@ namespace Blah
return m_height;
}
virtual void clear(Color color) override
virtual void clear(Color color, float depth, uint8_t stencil, ClearMask mask) override
{
int clear = 0;
if (((int)mask & (int)ClearMask::Color) == (int)ClearMask::Color)
clear |= GL_COLOR_BUFFER_BIT;
if (((int)mask & (int)ClearMask::Depth) == (int)ClearMask::Depth)
clear |= GL_DEPTH_BUFFER_BIT;
if (((int)mask & (int)ClearMask::Stencil) == (int)ClearMask::Stencil)
clear |= GL_STENCIL_BUFFER_BIT;
gl.BindFramebuffer(GL_FRAMEBUFFER, m_id);
gl.Disable(GL_SCISSOR_TEST);
gl.ColorMask(true, true, true, true);
gl.ClearColor(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f);
gl.Clear(GL_COLOR_BUFFER_BIT);
gl.ClearDepth(depth);
gl.ClearStencil(stencil);
gl.Clear(clear);
}
};
@ -1485,13 +1496,24 @@ namespace Blah
}
}
void GraphicsBackend::clear_backbuffer(Color color)
void GraphicsBackend::clear_backbuffer(Color color, float depth, uint8_t stencil, ClearMask mask)
{
int clear = 0;
if (((int)mask & (int)ClearMask::Color) == (int)ClearMask::Color)
clear |= GL_COLOR_BUFFER_BIT;
if (((int)mask & (int)ClearMask::Depth) == (int)ClearMask::Depth)
clear |= GL_DEPTH_BUFFER_BIT;
if (((int)mask & (int)ClearMask::Stencil) == (int)ClearMask::Stencil)
clear |= GL_STENCIL_BUFFER_BIT;
gl.BindFramebuffer(GL_FRAMEBUFFER, 0);
gl.Disable(GL_SCISSOR_TEST);
gl.ColorMask(true, true, true, true);
gl.ClearColor(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f);
gl.Clear(GL_COLOR_BUFFER_BIT);
gl.ClearDepth(depth);
gl.ClearStencil(stencil);
gl.Clear(clear);
}
}