[PyQt] Subclass QQuickFramebufferObject::Renderer and QOpenGLFunctions?
Elvis Stansvik
elvstone at gmail.com
Sun Nov 11 12:50:05 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 see now that someone asked something similar previously on this
list, and posted an example at:
https://gist.github.com/rostikL/7876e4c47fc8dd8ce02f
However, that example only derives QQuickFramebufferObject.Renderer,
not QOpenGLFunctions, and it has a comment `# ... Issue OpenGL
commands.` in the render() function where the GL commands would go. So
I'm still not sure how that could be turned into a working example.
Thankful for any advice, since I'm a complete OpenGL noob, and only
trying to port a C++ example that uses the
QQuickFramebufferObject::Renderer + QOpenGLFunctions pattern to PyQt.
Elvis
>
> Cheers,
> Elvis
More information about the PyQt
mailing list