diff --git a/examples/opengl/2dpainting/2dpainting.pro b/examples/opengl/2dpainting/2dpainting.pro index 08383a4..ef4467c 100644 --- a/examples/opengl/2dpainting/2dpainting.pro +++ b/examples/opengl/2dpainting/2dpainting.pro @@ -1,4 +1,4 @@ -QT += opengl widgets +QT += opengl widgets gui-private core-private HEADERS = glwidget.h \ helper.h \ @@ -9,7 +9,7 @@ SOURCES = glwidget.cpp \ main.cpp \ widget.cpp \ window.cpp - +CONFIG+=console # install target.path = $$[QT_INSTALL_EXAMPLES]/opengl/2dpainting INSTALLS += target diff --git a/examples/opengl/2dpainting/glwidget.cpp b/examples/opengl/2dpainting/glwidget.cpp index 0443d5b..0aad799 100644 --- a/examples/opengl/2dpainting/glwidget.cpp +++ b/examples/opengl/2dpainting/glwidget.cpp @@ -42,10 +42,25 @@ #include "helper.h" #include +#include +#include +#include + +static inline QGLFormat glFormat() +{ + QGLFormat result(QGL::SampleBuffers); + if (QCoreApplication::arguments().contains("-a")) { + result.setAlphaBufferSize(8); + } + qDebug() << result; + return result; +} //! [0] +//! +//! GLWidget::GLWidget(Helper *helper, QWidget *parent) - : QGLWidget(QGLFormat(QGL::SampleBuffers), parent), helper(helper) + : QGLWidget(glFormat(), parent), helper(helper) { elapsed = 0; setFixedSize(200, 200); diff --git a/examples/opengl/2dpainting/main.cpp b/examples/opengl/2dpainting/main.cpp index 5daff5c..babb38c 100644 --- a/examples/opengl/2dpainting/main.cpp +++ b/examples/opengl/2dpainting/main.cpp @@ -41,11 +41,65 @@ #include "window.h" #include +#include +#include +#include + + +# include +# include +# include + +static void dumpWindowRecursion(QTextStream &str, const QWindow *w, const QWindowList &allWins, int depth = 0) +{ + if (depth) + str << QString(depth * 2, QLatin1Char(' ')); + const QRect geom = w->geometry(); + const QPoint globalPos = w->isTopLevel() ? geom.topLeft() : w->mapToGlobal(geom.topLeft()); + str << '"' << w->metaObject()->className() << "\"/\"" << w->objectName() << "\" "; + if (w->isTopLevel()) + str << "[top] "; + if (w->surfaceType() == QSurface::OpenGLSurface) + str << "[gl] "; + const QSurfaceFormat format = w->requestedFormat(); + if (format.hasAlpha()) + str << "[alpha] "; + str << "f=0x" << hex << unsigned(w->flags()) << dec + << "\" " << geom.width() << 'x' << geom.height() + << forcesign << geom.x() << geom.y() + << " Global: " << globalPos.x() << globalPos.y() << noforcesign << '\n'; + foreach (const QWindow *cw, allWins) + if (cw->type() != Qt::Desktop && cw->parent() == w) + dumpWindowRecursion(str, cw, allWins, depth + 1); +} +static void dumpAllWindows() +{ + QString d; + QWindowList wins = QGuiApplication::allWindows(); + QTextStream str(&d); + foreach (const QWindow *w, wins) + if (w->type() != Qt::Desktop && w->isTopLevel()) + dumpWindowRecursion(str, w, wins, 0); + qDebug().nospace() << d; +} int main(int argc, char *argv[]) { QApplication app(argc, argv); Window window; + QStringList args = QCoreApplication::arguments(); + + qDebug() << QT_VERSION_STR << "threaded GL"<< QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL); + + if (!args.contains("-f")) { + qDebug() << "Qt::FramelessWindowHint"; + window.setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog); + } + if (!args.contains("-t")) { + qDebug() << "Qt::WA_TranslucentBackground"; + window.setAttribute(Qt::WA_TranslucentBackground); + } window.show(); + dumpAllWindows(); return app.exec(); }