diff options
-rw-r--r-- | examples/opengl/hellogl2/glwidget.cpp | 3 | ||||
-rw-r--r-- | examples/opengl/hellogl2/main.cpp | 1 | ||||
-rw-r--r-- | examples/opengl/hellogl2/mainwindow.cpp | 3 | ||||
-rw-r--r-- | examples/opengl/hellogl2/window.cpp | 5 |
4 files changed, 10 insertions, 2 deletions
diff --git a/examples/opengl/hellogl2/glwidget.cpp b/examples/opengl/hellogl2/glwidget.cpp index 6d2ffb3b581..aad83cc2af5 100644 --- a/examples/opengl/hellogl2/glwidget.cpp +++ b/examples/opengl/hellogl2/glwidget.cpp @@ -7,6 +7,7 @@ #include <QCoreApplication> #include <math.h> +// Set from main bool GLWidget::m_transparent = false; GLWidget::GLWidget(QWidget *parent) @@ -209,9 +210,11 @@ void GLWidget::setupVertexAttribs() void GLWidget::paintGL() { + glClearColor(0, 0, 0, m_transparent ? 0 : 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); + setupVertexAttribs(); m_world.setToIdentity(); m_world.rotate(180.0f - (m_xRot / 16.0f), 1, 0, 0); diff --git a/examples/opengl/hellogl2/main.cpp b/examples/opengl/hellogl2/main.cpp index 6ecd4cfe1a0..a355d992840 100644 --- a/examples/opengl/hellogl2/main.cpp +++ b/examples/opengl/hellogl2/main.cpp @@ -42,6 +42,7 @@ int main(int argc, char *argv[]) MainWindow mainWindow; + // Note: Transparency does not work for wasm GLWidget::setTransparent(parser.isSet(transparentOption)); if (GLWidget::isTransparent()) { mainWindow.setAttribute(Qt::WA_TranslucentBackground); diff --git a/examples/opengl/hellogl2/mainwindow.cpp b/examples/opengl/hellogl2/mainwindow.cpp index 5ee2b738c2f..3f57b4fe30c 100644 --- a/examples/opengl/hellogl2/mainwindow.cpp +++ b/examples/opengl/hellogl2/mainwindow.cpp @@ -11,12 +11,13 @@ MainWindow::MainWindow() { +#ifndef Q_OS_WASM QMenu *menuWindow = menuBar()->addMenu(tr("&Window")); menuWindow->addAction(tr("Add new"), QKeySequence(Qt::CTRL | Qt::Key_N), this, &MainWindow::onAddNew); menuWindow->addAction(tr("Quit"), QKeySequence(Qt::CTRL | Qt::Key_Q), qApp, QApplication::closeAllWindows); - +#endif onAddNew(); } diff --git a/examples/opengl/hellogl2/window.cpp b/examples/opengl/hellogl2/window.cpp index 5a7ddf826fd..c129142a893 100644 --- a/examples/opengl/hellogl2/window.cpp +++ b/examples/opengl/hellogl2/window.cpp @@ -45,10 +45,13 @@ Window::Window() container->addWidget(zSlider); mainLayout->addWidget(w); + dockBtn = nullptr; + +#ifndef Q_OS_WASM dockBtn = new QPushButton(tr("Undock"), this); connect(dockBtn, &QPushButton::clicked, this, &Window::dockUndock); mainLayout->addWidget(dockBtn); - +#endif xSlider->setValue(15 * 16); ySlider->setValue(345 * 16); zSlider->setValue(0 * 16); |