diff options
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/qopenglwidget/openglwidget/main.cpp | 17 | ||||
-rw-r--r-- | tests/manual/qopenglwidget/openglwidget/openglwidget.cpp | 7 | ||||
-rw-r--r-- | tests/manual/qopenglwidget/openglwidget/openglwidget.h | 2 |
3 files changed, 21 insertions, 5 deletions
diff --git a/tests/manual/qopenglwidget/openglwidget/main.cpp b/tests/manual/qopenglwidget/openglwidget/main.cpp index 68f9be7199..0268d47767 100644 --- a/tests/manual/qopenglwidget/openglwidget/main.cpp +++ b/tests/manual/qopenglwidget/openglwidget/main.cpp @@ -45,20 +45,32 @@ #include <QMdiArea> #include <QLCDNumber> #include <QTimer> - +#include <QSurfaceFormat> +#include <QDebug> int main(int argc, char *argv[]) { QApplication a(argc, argv); + QSurfaceFormat format; + if (QCoreApplication::arguments().contains(QLatin1String("--multisample"))) + format.setSamples(4); + if (QCoreApplication::arguments().contains(QLatin1String("--coreprofile"))) { + format.setVersion(3, 2); + format.setProfile(QSurfaceFormat::CoreProfile); + } + qDebug() << "Requesting" << format; + QMdiArea w; w.resize(400,400); OpenGLWidget *glw = new OpenGLWidget; + glw->setFormat(format); w.addSubWindow(glw); glw->setMinimumSize(100,100); OpenGLWidget *glw2 = new OpenGLWidget; + glw2->setFormat(format); glw2->setMinimumSize(100,100); w.addSubWindow(glw2); @@ -69,5 +81,8 @@ int main(int argc, char *argv[]) w.show(); + if (glw->isValid()) + qDebug() << "Got" << glw->format(); + return a.exec(); } diff --git a/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp b/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp index bec89b6b41..516de35ff8 100644 --- a/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp +++ b/tests/manual/qopenglwidget/openglwidget/openglwidget.cpp @@ -58,7 +58,7 @@ #include <QtCore/qmath.h> #include <qopengl.h> -class OpenGLWidgetPrivate +class OpenGLWidgetPrivate : protected QOpenGLFunctions { public: OpenGLWidgetPrivate(QWidget *q) @@ -91,7 +91,7 @@ OpenGLWidget::OpenGLWidget(QWidget *parent) { d = new OpenGLWidgetPrivate(this); QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(updateGL())); + connect(timer, SIGNAL(timeout()), this, SLOT(update())); timer->start(30); } @@ -137,6 +137,7 @@ static const char *fragmentShaderSource = void OpenGLWidgetPrivate::initialize() { + initializeOpenGLFunctions(); m_program = new QOpenGLShaderProgram; m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource); m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource); @@ -157,7 +158,7 @@ void OpenGLWidgetPrivate::render() m_program->bind(); QMatrix4x4 matrix; - matrix.perspective(60, 4.0/3.0, 0.1, 100.0); + matrix.perspective(60.0f, 4.0f/3.0f, 0.1f, 100.0f); matrix.translate(0, 0, -2); matrix.rotate(100.0f * m_frame / 30/*screen()->refreshRate()*/, 0, 1, 0); diff --git a/tests/manual/qopenglwidget/openglwidget/openglwidget.h b/tests/manual/qopenglwidget/openglwidget/openglwidget.h index eaba27df26..ada01d4cc1 100644 --- a/tests/manual/qopenglwidget/openglwidget/openglwidget.h +++ b/tests/manual/qopenglwidget/openglwidget/openglwidget.h @@ -42,7 +42,7 @@ #ifndef OPENGLWIDGET_H #define OPENGLWIDGET_H -#include <QtWidgets/private/qopenglwidget_p.h> +#include <QtWidgets/QOpenGLWidget> class OpenGLWidgetPrivate; class OpenGLWidget : public QOpenGLWidget |