[PyQt] Subclass QQuickFramebufferObject::Renderer and QOpenGLFunctions?

Elvis Stansvik elvstone at gmail.com
Sun Nov 11 14:45:24 GMT 2018


Den sön 11 nov. 2018 kl 13:40 skrev Elvis Stansvik <elvstone at gmail.com>:
>
> Hi all,
>
> How can I subclass both QQuickFramebufferObject::Renderer and
> QOpenGLFunctions, as done by the ColorRenderer in the
> tst_qquickframebufferobject.cpp autotest in Qt:
>
>     https://code.woboq.org/qt5/qtdeclarative/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp.html
>
> Snipped from above:
>
> class ColorRenderer : public QQuickFramebufferObject::Renderer,
> protected QOpenGLFunctions
> {
> public:
>     void render();
>     void synchronize(QQuickFramebufferObject *item);
>     QOpenGLFramebufferObject *createFramebufferObject(const QSize &size);
>
>     QSize textureSize;
>     QColor color;
>     bool msaa;
> };
>
> I tried to do something like this using the _QOpenGLFunctions_4_1_Core
> class from PyQt, but ran into problems since the metaclass of
> _QOpenGLFunctions_4_1_Core is module, and the meta class of
> QQuickFramebufferObject::Renderer is sip.wrappertype, and there's no
> way to declare a metatype inheriting them both that could be used,
> since they are incompatible at the C level.
>
> Is it simply not possible to create a
> QQuickFramebufferObject::Renderer like this using PyQt?
>
> Anyone know of another way to create a custom QQuickFramebufferObject from PyQt?

I think I found the example I needed now:

    https://github.com/Upcios/PyQtSamples/tree/master/PyQt5/opengl/opengl_under_qml_fbo

Looks like

    self.gl = self.window.openglContext().versionFunctions( self.profile )

is one way of getting an QAbstractOpenGLFunctions for a given
QOpenGLVersionProfile (where self.window is the QQuickWindow).

Have not tried it yet, but this should get me started I think.

Elvis

>
> Cheers,
> Elvis


More information about the PyQt mailing list