OpenGLRenderer: Fix clear values

This commit is contained in:
Jérôme Leclercq
2021-02-15 18:17:10 +01:00
parent 08c2f711b0
commit a6b5246633
7 changed files with 33 additions and 1 deletions

View File

@@ -93,7 +93,24 @@ namespace Nz
command.framebuffer->Activate();
context = GL::Context::GetCurrentContext();
context->glClearColor(0.5, 0.5, 0.5, 1.0);
if (command.framebuffer->GetType() == OpenGLFramebuffer::Type::FBO)
{
std::size_t colorBufferCount = command.framebuffer->GetColorBufferCount();
for (std::size_t i = 0; i < colorBufferCount; ++i)
{
Nz::Color color = command.clearValues[i].color;
std::array<GLuint, 4> clearColor = { color.r, color.g, color.b, color.a };
context->glClearBufferuiv(GL_COLOR, GLint(i), clearColor.data());
}
}
else
{
Nz::Color color = command.clearValues[0].color;
context->glClearColor(color.r, color.g, color.b, color.a);
}
context->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
else

View File

@@ -17,4 +17,9 @@ namespace Nz
context.BindFramebuffer(GL::FramebufferTarget::Draw, 0);
}
std::size_t OpenGLWindowFramebuffer::GetColorBufferCount() const
{
return 1;
}
}