Commit 702404fe authored by Laszlo Agocs's avatar Laszlo Agocs

Improve the readback docs

parent 580408d2
......@@ -3637,8 +3637,7 @@ void QRhiResourceUpdateBatch::copyTexture(QRhiTexture *dst, QRhiTexture *src, co
QRhiReadbackResult *rbResult = new QRhiReadbackResult;
rbResult->completed = [rbResult] {
QImage::Format fmt = rbResult->format == QRhiTexture::BGRA8 ? QImage::Format_ARGB32_Premultiplied
: QImage::Format_RGBA8888_Premultiplied;
const QImage::Format fmt = QImage::Format_RGBA8888_Premultiplied; // fits QRhiTexture::RGBA8
const uchar *p = reinterpret_cast<const uchar *>(rbResult->data.constData());
QImage image(p, rbResult->pixelSize.width(), rbResult->pixelSize.height(), fmt);"result.png");
......@@ -3655,6 +3654,16 @@ void QRhiResourceUpdateBatch::copyTexture(QRhiTexture *dst, QRhiTexture *src, co
\note The texture must be created with QRhiTexture::UsedAsTransferSource.
\note Multisample textures cannot be read back.
\note The readback returns raw byte data, in order to allow the applications
to interpret it in any way they see fit. Be aware of the blending settings
of rendering code: if the blending is set up to rely on premultiplied alpha,
the results of the readback must also be interpreted as Premultiplied.
\note When interpreting the resulting raw data, be aware that the readback
happens with a byte ordered format. A \l{QRhiTexture::RGBA8}{RGBA8} texture
maps therefore to byte ordered QImage formats, such as,
void QRhiResourceUpdateBatch::readBackTexture(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
......@@ -1579,6 +1579,7 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
// readPixels handles multisample resolving implicitly
result->data.resize(result->pixelSize.width() * result->pixelSize.height() * 4);
// With GLES (2.0?) GL_RGBA is the only mandated readback format, so stick with it.
f->glReadPixels(0, 0, result->pixelSize.width(), result->pixelSize.height(),
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment