Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
6.4.0
-
None
-
Kubuntu 22.04
Firefox 107.0
Chrome 107.0.5304.110
Description
QPainter on a QOpenGLPaintDevice doesn't paint when compiling to webassembly.
I've based the following minimal example on the hellogles3 demo (should work, when copy pasting over the main.cpp):
#include <memory> #include <QGuiApplication> #include <QSurfaceFormat> #include <QOpenGLContext> #include <QOpenGLWindow> #include <QOpenGLPaintDevice> #include <QPainter> class GLWindow : public QOpenGLWindow { std::unique_ptr<QOpenGLPaintDevice> m_gl_paint_device; public: void initializeGL() { m_gl_paint_device = std::make_unique<QOpenGLPaintDevice>(); } void resizeGL(int w, int h) { m_gl_paint_device->setSize({ w, h }); } void paintGL() { QPainter painter(m_gl_paint_device.get()); // QPainter painter(this); // also does not work and gives the same java script console errors painter.setBrush(QBrush(QColor(0xFF0088))); painter.drawRect(5, 8, 120, 120); } }; int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QSurfaceFormat fmt; fmt.setDepthBufferSize(24); bool webassembly = false; if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { fmt.setVersion(3, 3); fmt.setProfile(QSurfaceFormat::CoreProfile); } else { fmt.setVersion(3, 0); webassembly = true; } QSurfaceFormat::setDefaultFormat(fmt); GLWindow glWindow; if (webassembly) glWindow.showFullScreen(); else glWindow.showMaximized(); return app.exec(); }
On desktop (Kubuntu 22.04) the code compiles and paints a pink rectangle. On webassembly it only compiles, both FF and Chrome show a black screen. The javascript console of FF shows:
WebGL warning: vertexAttribI?Pointer: If ARRAY_BUFFER is null, byteOffset must be zero.
WebGL warning: drawArraysInstanced: Vertex attrib array 0 is enabled but has no buffer bound.
My own OpenGL code and the original hellogles3 work (originally I wanted to mix them).
Attachments
Issue Links
- duplicates
-
QTBUG-107539 wasm: 2dpainting sample not working with webassembly/webgl
- Closed