Move render target clear mapping to renderer gl

This commit is contained in:
2026-06-02 06:38:32 +02:00
parent e00eec30d4
commit 02f14f1bf5
6 changed files with 51 additions and 12 deletions

View File

@@ -263,7 +263,16 @@ bool RTT::create(int width, int height, int tex/* = -1*/, GLint internal_format,
glBindTexture(texture_2d_target(), texID);
if (tex == -1)
glTexImage2D(texture_2d_target(), 0, internal_format, width, height, 0, GL_RGBA, ifmt, 0);
glTexImage2D(
texture_2d_target(),
0,
internal_format,
width,
height,
0,
static_cast<GLenum>(pp::renderer::gl::rgba_pixel_format()),
ifmt,
0);
for (const auto parameter : pp::renderer::gl::default_render_target_texture_parameters())
{
glTexParameterf(
@@ -361,7 +370,9 @@ void RTT::clear(glm::vec4 color)
{
assert(App::I->is_render_thread());
glClearColor(color.r, color.g, color.b, color.a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(static_cast<GLbitfield>(
pp::renderer::gl::framebuffer_color_buffer_mask()
| pp::renderer::gl::framebuffer_depth_buffer_mask()));
}
void RTT::clear_mask(glm::bool4 mask, glm::vec4 color)
@@ -369,12 +380,12 @@ void RTT::clear_mask(glm::bool4 mask, glm::vec4 color)
assert(App::I->is_render_thread());
// save old state
std::array<GLboolean, 4> old_mask;
glGetBooleanv(GL_COLOR_WRITEMASK, old_mask.data());
glGetBooleanv(static_cast<GLenum>(pp::renderer::gl::color_write_mask_query()), old_mask.data());
// clear with mask
glColorMask(mask.r, mask.g, mask.b, mask.a);
glClearColor(color.r, color.g, color.b, color.a);
glClear(GL_COLOR_BUFFER_BIT);
glClear(static_cast<GLbitfield>(pp::renderer::gl::framebuffer_color_buffer_mask()));
// restore old state
glColorMask(old_mask[0], old_mask[1], old_mask[2], old_mask[3]);