Route RTT texture updates through GL backend

This commit is contained in:
2026-06-04 23:44:25 +02:00
parent c9fb91ab48
commit 111cc8c892
11 changed files with 115 additions and 44 deletions

View File

@@ -92,6 +92,29 @@ void set_opengl_texture_2d_image(
data);
}
void set_opengl_texture_2d_sub_image(
std::uint32_t target,
std::int32_t level,
std::int32_t x,
std::int32_t y,
std::int32_t width,
std::int32_t height,
std::uint32_t pixel_format,
std::uint32_t component_type,
const void* data) noexcept
{
glTexSubImage2D(
static_cast<GLenum>(target),
static_cast<GLint>(level),
static_cast<GLint>(x),
static_cast<GLint>(y),
static_cast<GLsizei>(width),
static_cast<GLsizei>(height),
static_cast<GLenum>(pixel_format),
static_cast<GLenum>(component_type),
data);
}
void set_opengl_texture_parameter_f(std::uint32_t target, std::uint32_t parameter, float value) noexcept
{
glTexParameterf(static_cast<GLenum>(target), static_cast<GLenum>(parameter), static_cast<GLfloat>(value));
@@ -760,6 +783,34 @@ bool RTT::readPixelsRgba8(int x, int y, int width, int height, void* buffer) con
return ret;
}
bool RTT::updateRgba8(int x, int y, int width, int height, const void* data) noexcept
{
if (!valid() || data == nullptr)
return false;
const auto status = pp::renderer::gl::update_opengl_texture_2d(
pp::renderer::gl::OpenGlTexture2DUpdate {
.texture_id = texID,
.x = x,
.y = y,
.width = width,
.height = height,
.pixel_format = pp::renderer::gl::rgba_pixel_format(),
.component_type = pp::renderer::gl::unsigned_byte_component_type(),
.data = data,
},
pp::renderer::gl::OpenGlTexture2DUpdateDispatch {
.bind_texture = bind_opengl_texture,
.tex_sub_image_2d = set_opengl_texture_2d_sub_image,
});
if (!status.ok()) {
LOG("RTT::updateRgba8() failed because: %s", status.message);
return false;
}
unbindTexture();
return true;
}
uint8_t* RTT::readTextureData(uint8_t* buffer) const noexcept
{
if (!valid())