Route RTT region readbacks through backend
This commit is contained in:
32
src/rtt.cpp
32
src/rtt.cpp
@@ -503,6 +503,38 @@ glm::ivec4 RTT::calc_bounds() const noexcept
|
||||
return { bbmin, bbmax };
|
||||
}
|
||||
|
||||
bool RTT::readPixelsRgba8(int x, int y, int width, int height, void* buffer) const noexcept
|
||||
{
|
||||
if (!valid() || buffer == nullptr)
|
||||
return false;
|
||||
|
||||
bool ret = true;
|
||||
App::I->render_task([&]
|
||||
{
|
||||
const auto readback = pp::renderer::gl::rgba8_readback_format();
|
||||
const auto status = pp::renderer::gl::readback_opengl_framebuffer(
|
||||
pp::renderer::gl::OpenGlFramebufferReadback {
|
||||
.framebuffer = static_cast<std::uint32_t>(fboID),
|
||||
.x = x,
|
||||
.y = y,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.format = readback,
|
||||
.pixels = buffer,
|
||||
},
|
||||
pp::renderer::gl::OpenGlFramebufferReadbackDispatch {
|
||||
.get_integer = query_opengl_integer,
|
||||
.bind_framebuffer = bind_opengl_framebuffer,
|
||||
.read_pixels = read_opengl_pixels,
|
||||
});
|
||||
if (!status.ok()) {
|
||||
LOG("RTT::readPixelsRgba8() failed because: %s", status.message);
|
||||
ret = false;
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t* RTT::readTextureData(uint8_t* buffer) const noexcept
|
||||
{
|
||||
if (!valid())
|
||||
|
||||
Reference in New Issue
Block a user