[Interest] QImage from ShaderEffectSource

Gunnar Sletta gunnar at sletta.org
Mon Sep 15 08:19:19 CEST 2014


On 13 Sep 2014, at 16:28, manish sharma <83.manish at gmail.com> wrote:
>     void getImage()
>     {
>         qDebug() << "taking snapshot..!";
>         disconnect(this, SIGNAL(afterRendering()), this, SLOT(getImage()));
>         QSGTexture *texture = m_snapshotItem->textureProvider()->texture();
>         texture->bind();
>         GLint internalFormat;
>         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPONENTS, &internalFormat); // get internal format type of GL texture
>         QImage img(texture->textureSize(),  QImage::Format_RGBX8888);
>         glGetTexImage(GL_TEXTURE_2D, 0, internalFormat, GL_UNSIGNED_BYTE, img.bits());

Actually, this bit down here, won't work on OpenGL ES as glGetTexImage doesn't exist there. You would need to bind the texture into a framebuffer object and glReadPixels it. If you're only deploying to desktop GL, this will not be a problem, but if you are targeting ES, including Windows/ANGLE, this code needs to be updated. 

cheers,
Gunnar

www.sletta.org




More information about the Interest mailing list