mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 18:16:45 +02:00
strenghening the checks in GLBackend::downloadFramebuffer before actually calling the true glReadPixels
This commit is contained in:
parent
be9d99264f
commit
d56b5f39fb
2 changed files with 20 additions and 4 deletions
|
@ -3436,7 +3436,6 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi
|
||||||
gpu::Vec4i viewport;
|
gpu::Vec4i viewport;
|
||||||
if (billboard) {
|
if (billboard) {
|
||||||
QSize size = DependencyManager::get<FramebufferCache>()->getFrameBufferSize();
|
QSize size = DependencyManager::get<FramebufferCache>()->getFrameBufferSize();
|
||||||
// viewport = gpu::Vec4i(region.x(), size.height() - region.y() - region.height(), region.width(), region.height());
|
|
||||||
viewport = gpu::Vec4i(0, 0, region.width(), region.height());
|
viewport = gpu::Vec4i(0, 0, region.width(), region.height());
|
||||||
} else {
|
} else {
|
||||||
// if not rendering the billboard, the region is in device independent coordinates; must convert to device
|
// if not rendering the billboard, the region is in device independent coordinates; must convert to device
|
||||||
|
@ -3446,7 +3445,6 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi
|
||||||
int y = region.y() * ratio;
|
int y = region.y() * ratio;
|
||||||
int width = region.width() * ratio;
|
int width = region.width() * ratio;
|
||||||
int height = region.height() * ratio;
|
int height = region.height() * ratio;
|
||||||
// viewport = gpu::Vec4i(x, size.height() - y - height, width, height);
|
|
||||||
viewport = gpu::Vec4i(0, 0, width, height);
|
viewport = gpu::Vec4i(0, 0, width, height);
|
||||||
}
|
}
|
||||||
renderArgs->_viewport = viewport;
|
renderArgs->_viewport = viewport;
|
||||||
|
|
|
@ -196,9 +196,27 @@ void GLBackend::do_blit(Batch& batch, uint32 paramOffset) {
|
||||||
|
|
||||||
|
|
||||||
void GLBackend::downloadFramebuffer(const FramebufferPointer& srcFramebuffer, const Vec4i& region, QImage& destImage) {
|
void GLBackend::downloadFramebuffer(const FramebufferPointer& srcFramebuffer, const Vec4i& region, QImage& destImage) {
|
||||||
|
auto readFBO = gpu::GLBackend::getFramebufferID(srcFramebuffer);
|
||||||
|
if (srcFramebuffer && readFBO) {
|
||||||
|
if ((srcFramebuffer->getWidth() < (region.x + region.z)) || (srcFramebuffer->getHeight() < (region.y + region.w))) {
|
||||||
|
qCDebug(gpulogging) << "GLBackend::downloadFramebuffer : srcFramebuffer is too small to provide the region queried";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((destImage.width() < region.z) || (destImage.height() < region.w)) {
|
||||||
|
qCDebug(gpulogging) << "GLBackend::downloadFramebuffer : destImage is too small to receive the region of the framebuffer";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLenum format = GL_BGRA;
|
||||||
|
if (destImage.format() != QImage::Format_ARGB32) {
|
||||||
|
qCDebug(gpulogging) << "GLBackend::downloadFramebuffer : destImage format must be FORMAT_ARGB32 to receive the region of the framebuffer";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(srcFramebuffer));
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(srcFramebuffer));
|
||||||
glReadPixels(region.x, region.y, region.z, region.w, GL_BGRA, GL_UNSIGNED_BYTE, destImage.bits());
|
glReadPixels(region.x, region.y, region.z, region.w, format, GL_UNSIGNED_BYTE, destImage.bits());
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||||
|
|
||||||
(void) CHECK_GL_ERROR();
|
(void) CHECK_GL_ERROR();
|
||||||
|
|
Loading…
Reference in a new issue