[Feature Request] Exposing QNativeInterface::QSGOpenGLTexture functionality in PyQt6
pike
pikestaff at gmail.com
Thu Jul 9 14:11:51 BST 2026
Hi Phil and list,
I am working on a PyQt6 project that integrates an external OpenGL
rendering engine (projectM) with a Qt Quick scene graph via custom
QQuickItems.
To display our raw GL texture IDs inside the scene graph, the standard
Qt 6 approach is to use the public API found in
<QtQuick/qsgtexture_platform.h>:
C++
QNativeInterface::QSGOpenGLTexture::fromNative(
GLuint textureId,
QQuickWindow *window,
const QSize &size,
QQuickWindow::CreateTextureOptions options = {}
);
Currently, this functionality is inaccessible in PyQt6. I understand
that QNativeInterface relies heavily on macros
(QT_DECLARE_NATIVE_INTERFACE) that don't map cleanly to standard SIP
class generation, and that The Qt Company explicitly tags the native
interfaces as lacking strict source/binary compatibility guarantees
across point releases.
To work around this, we are currently forced to compile a small C++
shim that flattens the invocation into a plain free function:
C++
QSGTexture *wrap_gl_texture(unsigned int texture_id, QQuickWindow
*window, int width, int height, int options);
While exposing the volatile QNativeInterface namespace directly to
Python might not be desirable, would it be possible to provide a
stable, Pythonic static helper method on an existing class to bridge
this gap?
For example, adding something like
QSGTexture.fromOpenGLTextureId(texture_id: int, window: QQuickWindow,
size: QSize, options: QQuickWindow.CreateTextureOptions) would
completely eliminate the need for Python developers to maintain custom
C++ build toolchains just to pass hardware texture handles to a QML
scene graph.
Thank you for your time and consideration.
Best regards,
Kent
More information about the PyQt
mailing list