Important: Please read the Qt Code of Conduct -

Render OpenGL texture inside Qt's interface

  • I have a 3D graphics-heavy application written in C++ with QtWidgets and I am currently working on optimizing its VRAM usage. The issue is that there is a texture browser (shown on the picture below) which displays textures to the user with QPixmap as QLIstView's model's item decoration role. At the same time the same textures are also loaded into OpenGL to be displayed inside the viewport (QOpenGLWidget). This results into the same data potentially duplicated in video memory.

    Is there a way to render a texture as a decoration role inside the Qt's UI using a texture handle from OpenGL without the need of constructing a pixmap with duplicated data?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    AFAIK, not directly no.

    The two are using two different rendering mechanisms.

    One is using the raster engine and the other OpenGL.

  • @SGaist said in Render OpenGL texture inside Qt's interface:

    raster engine

    Thanks for the answer! Does it maybe allow to store images compressed then? For example, using DXT compression.

  • Lifetime Qt Champion

    What kind of storage do you have in mind ?

  • So, afaik QImage/QPixmap store image pixels raw, which would mean that there is no compression applied to them. There are about 670 512x512 textures, and about a thousand 1024x1024 textures which results in a lot of RAM and VRAM space wasted just for texture previews in the UI. So, it'd be good to at least store them compressed.

  • Lifetime Qt Champion

    That's the kind of case where you would use moving window and a pixmap cache to limit the amount of image loaded at a time.

Log in to reply