diff options
Diffstat (limited to 'examples/opengl')
51 files changed, 571 insertions, 1058 deletions
diff --git a/examples/opengl/2dpainting/2dpainting.pro b/examples/opengl/2dpainting/2dpainting.pro index ac88b9940a..5d361bc1bf 100644 --- a/examples/opengl/2dpainting/2dpainting.pro +++ b/examples/opengl/2dpainting/2dpainting.pro @@ -1,4 +1,4 @@ -QT += opengl +QT += opengl widgets HEADERS = glwidget.h \ helper.h \ diff --git a/examples/opengl/2dpainting/glwidget.cpp b/examples/opengl/2dpainting/glwidget.cpp index 8b28a6e6a3..800e947385 100644 --- a/examples/opengl/2dpainting/glwidget.cpp +++ b/examples/opengl/2dpainting/glwidget.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include "glwidget.h" #include "helper.h" diff --git a/examples/opengl/2dpainting/helper.cpp b/examples/opengl/2dpainting/helper.cpp index 662a4264a7..dc18c60a4b 100644 --- a/examples/opengl/2dpainting/helper.cpp +++ b/examples/opengl/2dpainting/helper.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include "helper.h" //! [0] diff --git a/examples/opengl/2dpainting/widget.cpp b/examples/opengl/2dpainting/widget.cpp index 16398147c7..35eedae240 100644 --- a/examples/opengl/2dpainting/widget.cpp +++ b/examples/opengl/2dpainting/widget.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include "widget.h" #include "helper.h" diff --git a/examples/opengl/2dpainting/window.cpp b/examples/opengl/2dpainting/window.cpp index d2c8ef706c..0186670f38 100644 --- a/examples/opengl/2dpainting/window.cpp +++ b/examples/opengl/2dpainting/window.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include "glwidget.h" #include "widget.h" #include "window.h" diff --git a/examples/opengl/cube/cube.pro b/examples/opengl/cube/cube.pro index a11aaf6bc7..652812b718 100644 --- a/examples/opengl/cube/cube.pro +++ b/examples/opengl/cube/cube.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui +QT += core gui widgets TARGET = cube TEMPLATE = app diff --git a/examples/opengl/cube/main.cpp b/examples/opengl/cube/main.cpp index c75fd0826a..ef6efdc4dc 100644 --- a/examples/opengl/cube/main.cpp +++ b/examples/opengl/cube/main.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui/QApplication> +#include <QApplication> #include <QLabel> #ifndef QT_NO_OPENGL diff --git a/examples/opengl/cube/mainwidget.cpp b/examples/opengl/cube/mainwidget.cpp index 1116526922..3f4e9214ac 100644 --- a/examples/opengl/cube/mainwidget.cpp +++ b/examples/opengl/cube/mainwidget.cpp @@ -72,13 +72,13 @@ MainWidget::~MainWidget() void MainWidget::mousePressEvent(QMouseEvent *e) { // Saving mouse press position - mousePressPosition = QVector2D(e->posF()); + mousePressPosition = QVector2D(e->localPos()); } void MainWidget::mouseReleaseEvent(QMouseEvent *e) { // Mouse release position - mouse press position - QVector2D diff = QVector2D(e->posF()) - mousePressPosition; + QVector2D diff = QVector2D(e->localPos()) - mousePressPosition; // Rotation axis is perpendicular to the mouse position difference // vector diff --git a/examples/opengl/framebufferobject2/framebufferobject2.pro b/examples/opengl/framebufferobject2/framebufferobject2.pro index d2787853e0..d3fce133fa 100644 --- a/examples/opengl/framebufferobject2/framebufferobject2.pro +++ b/examples/opengl/framebufferobject2/framebufferobject2.pro @@ -2,7 +2,7 @@ HEADERS += glwidget.h SOURCES += glwidget.cpp main.cpp RESOURCES += framebufferobject2.qrc -QT += opengl +QT += opengl widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/framebufferobject2 diff --git a/examples/opengl/framebufferobject2/main.cpp b/examples/opengl/framebufferobject2/main.cpp index 12e5a62cdd..313e683da5 100644 --- a/examples/opengl/framebufferobject2/main.cpp +++ b/examples/opengl/framebufferobject2/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ -#include <QtGui/QApplication> -#include <QtGui/QMessageBox> +#include <QtWidgets/QApplication> +#include <QtWidgets/QMessageBox> #include "glwidget.h" int main(int argc, char **argv) diff --git a/examples/opengl/grabber/glwidget.cpp b/examples/opengl/grabber/glwidget.cpp index 72039a7b66..52d0b2662a 100644 --- a/examples/opengl/grabber/glwidget.cpp +++ b/examples/opengl/grabber/glwidget.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include <QtOpenGL> #include <math.h> diff --git a/examples/opengl/grabber/grabber.pro b/examples/opengl/grabber/grabber.pro index e9f371b6ad..6a73201cd2 100644 --- a/examples/opengl/grabber/grabber.pro +++ b/examples/opengl/grabber/grabber.pro @@ -3,7 +3,7 @@ HEADERS = glwidget.h \ SOURCES = glwidget.cpp \ main.cpp \ mainwindow.cpp -QT += opengl +QT += opengl widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/grabber diff --git a/examples/opengl/grabber/mainwindow.cpp b/examples/opengl/grabber/mainwindow.cpp index d2f3a98dce..965c49ab1a 100644 --- a/examples/opengl/grabber/mainwindow.cpp +++ b/examples/opengl/grabber/mainwindow.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include <QtOpenGL> #include "glwidget.h" diff --git a/examples/opengl/hellogl/glwidget.cpp b/examples/opengl/hellogl/glwidget.cpp index 59efb12368..38333d8560 100644 --- a/examples/opengl/hellogl/glwidget.cpp +++ b/examples/opengl/hellogl/glwidget.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include <QtOpenGL> #include <math.h> diff --git a/examples/opengl/hellogl/hellogl.pro b/examples/opengl/hellogl/hellogl.pro index 0c81aae5c1..82372c5d98 100644 --- a/examples/opengl/hellogl/hellogl.pro +++ b/examples/opengl/hellogl/hellogl.pro @@ -8,7 +8,7 @@ SOURCES = glwidget.cpp \ main.cpp \ window.cpp \ qtlogo.cpp -QT += opengl +QT += opengl widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl diff --git a/examples/opengl/hellogl/window.cpp b/examples/opengl/hellogl/window.cpp index ef7cc2ad09..9f7d6be68b 100644 --- a/examples/opengl/hellogl/window.cpp +++ b/examples/opengl/hellogl/window.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include "glwidget.h" #include "window.h" diff --git a/examples/opengl/hellogl_es/bubble.cpp b/examples/opengl/hellogl_es/bubble.cpp deleted file mode 100644 index 167d9abd92..0000000000 --- a/examples/opengl/hellogl_es/bubble.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui> - -#include "bubble.h" - -Bubble::Bubble(const QPointF &position, qreal radius, const QPointF &velocity) - : position(position), vel(velocity), radius(radius) -{ - innerColor = randomColor(); - outerColor = randomColor(); - cache = 0; - updateBrush(); -} - -//! [0] -void Bubble::updateCache() -{ - if (cache) - delete cache; - cache = new QImage(qRound(radius * 2 + 2), qRound(radius * 2 + 2), QImage::Format_ARGB32); - cache->fill(0x00000000); - QPainter p(cache); - p.setRenderHint(QPainter::HighQualityAntialiasing); - QPen pen(Qt::white); - pen.setWidth(2); - p.setPen(pen); - p.setBrush(brush); - p.drawEllipse(0, 0, int(2*radius), int(2*radius)); -} -//! [0] - -Bubble::~Bubble() -{ - if (cache) - delete cache; -} - -void Bubble::updateBrush() -{ - QRadialGradient gradient(QPointF(radius, radius), radius, - QPointF(radius*0.5, radius*0.5)); - - gradient.setColorAt(0, QColor(255, 255, 255, 255)); - gradient.setColorAt(0.25, innerColor); - gradient.setColorAt(1, outerColor); - brush = QBrush(gradient); - updateCache(); -} - -//! [1] -void Bubble::drawBubble(QPainter *painter) -{ - painter->save(); - painter->translate(position.x() - radius, position.y() - radius); - painter->setOpacity(0.8); - painter->drawImage(0, 0, *cache); - painter->restore(); -} -//! [1] - -QColor Bubble::randomColor() -{ - int red = int(185 + 70.0*qrand()/(RAND_MAX+1.0)); - int green = int(185 + 70.0*qrand()/(RAND_MAX+1.0)); - int blue = int(205 + 50.0*qrand()/(RAND_MAX+1.0)); - int alpha = int(91 + 100.0*qrand()/(RAND_MAX+1.0)); - - return QColor(red, green, blue, alpha); -} - -void Bubble::move(const QRect &bbox) -{ - position += vel; - qreal leftOverflow = position.x() - radius - bbox.left(); - qreal rightOverflow = position.x() + radius - bbox.right(); - qreal topOverflow = position.y() - radius - bbox.top(); - qreal bottomOverflow = position.y() + radius - bbox.bottom(); - - if (leftOverflow < 0.0) { - position.setX(position.x() - 2 * leftOverflow); - vel.setX(-vel.x()); - } else if (rightOverflow > 0.0) { - position.setX(position.x() - 2 * rightOverflow); - vel.setX(-vel.x()); - } - - if (topOverflow < 0.0) { - position.setY(position.y() - 2 * topOverflow); - vel.setY(-vel.y()); - } else if (bottomOverflow > 0.0) { - position.setY(position.y() - 2 * bottomOverflow); - vel.setY(-vel.y()); - } -} - -QRectF Bubble::rect() -{ - return QRectF(position.x() - radius, position.y() - radius, - 2 * radius, 2 * radius); -} diff --git a/examples/opengl/hellogl_es/bubble.h b/examples/opengl/hellogl_es/bubble.h deleted file mode 100644 index 21f5add43e..0000000000 --- a/examples/opengl/hellogl_es/bubble.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BUBBLE_H -#define BUBBLE_H - -#include <QBrush> -#include <QColor> -#include <QPointF> -#include <QRect> -#include <QRectF> - -class QPainter; - -class Bubble -{ -public: - Bubble(const QPointF &position, qreal radius, const QPointF &velocity); - ~Bubble(); - - void drawBubble(QPainter *painter); - void updateBrush(); - void move(const QRect &bbox); - void updateCache(); - QRectF rect(); - -private: - QColor randomColor(); - - QBrush brush; - QPointF position; - QPointF vel; - qreal radius; - QColor innerColor; - QColor outerColor; - QImage *cache; -}; - -#endif diff --git a/examples/opengl/hellogl_es/glwidget.cpp b/examples/opengl/hellogl_es/glwidget.cpp deleted file mode 100644 index 80444dfdbe..0000000000 --- a/examples/opengl/hellogl_es/glwidget.cpp +++ /dev/null @@ -1,455 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "glwidget.h" -#include <QPainter> -#include <math.h> - -#include "bubble.h" - - -const int bubbleNum = 8; - -inline void CrossProduct(qreal &xOut, qreal &yOut, qreal &zOut, qreal x1, qreal y1, qreal z1, qreal x2, qreal y2, qreal z2) -{ - xOut = y1 * z2 - z1 * y2; - yOut = z1 * x2 - x1 * z2; - zOut = x1 * y2 - y1 * x2; -} - -inline void Normalize(qreal &x, qreal &y, qreal &z) -{ - qreal l = sqrt(x*x + y*y + z*z); - x = x / l; - y = y / l; - z = z / l; -} - -GLWidget::GLWidget(QWidget *parent) - : QGLWidget(parent) -{ - qtLogo = true; - createdVertices = 0; - createdNormals = 0; - m_vertexNumber = 0; - frames = 0; - setAttribute(Qt::WA_PaintOnScreen); - setAttribute(Qt::WA_NoSystemBackground); - setAutoBufferSwap(false); - m_showBubbles = true; -} - -GLWidget::~GLWidget() -{ - if (createdVertices) - delete[] createdVertices; - if (createdNormals) - delete[] createdNormals; -} - -void GLWidget::setScaling(int scale) { - - if (scale > 50) - m_fScale = 1 + qreal(scale -50) / 50 * 0.5; - else if (scale < 50) - m_fScale = 1- (qreal(50 - scale) / 50 * 1/2); - else - m_fScale = 1; -} - -void GLWidget::setLogo() { - qtLogo = true; -} - -void GLWidget::setTexture() { - qtLogo = false; -} - -void GLWidget::showBubbles(bool bubbles) -{ - m_showBubbles = bubbles; -} - -//! [2] -void GLWidget::paintQtLogo() -{ - glDisable(GL_TEXTURE_2D); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3,GL_FLOAT,0, createdVertices); - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT,0,createdNormals); - glDrawArrays(GL_TRIANGLES, 0, m_vertexNumber / 3); -} -//! [2] - -void GLWidget::paintTexturedCube() -{ - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, m_uiTexture); - GLfloat afVertices[] = { - -0.5, 0.5, 0.5, 0.5,-0.5,0.5,-0.5,-0.5,0.5, - 0.5, -0.5, 0.5, -0.5,0.5,0.5,0.5,0.5,0.5, - -0.5, -0.5, -0.5, 0.5,-0.5,-0.5,-0.5,0.5,-0.5, - 0.5, 0.5, -0.5, -0.5,0.5,-0.5,0.5,-0.5,-0.5, - - 0.5, -0.5, -0.5, 0.5,-0.5,0.5,0.5,0.5,-0.5, - 0.5, 0.5, 0.5, 0.5,0.5,-0.5,0.5,-0.5,0.5, - -0.5, 0.5, -0.5, -0.5,-0.5,0.5,-0.5,-0.5,-0.5, - -0.5, -0.5, 0.5, -0.5,0.5,-0.5,-0.5,0.5,0.5, - - 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, - -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, - -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, - 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5 - }; - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3,GL_FLOAT,0,afVertices); - - GLfloat afTexCoord[] = { - 0.0f,0.0f, 1.0f,1.0f, 1.0f,0.0f, - 1.0f,1.0f, 0.0f,0.0f, 0.0f,1.0f, - 1.0f,1.0f, 1.0f,0.0f, 0.0f,1.0f, - 0.0f,0.0f, 0.0f,1.0f, 1.0f,0.0f, - - 1.0f,1.0f, 1.0f,0.0f, 0.0f,1.0f, - 0.0f,0.0f, 0.0f,1.0f, 1.0f,0.0f, - 0.0f,0.0f, 1.0f,1.0f, 1.0f,0.0f, - 1.0f,1.0f, 0.0f,0.0f, 0.0f,1.0f, - - 0.0f,1.0f, 1.0f,0.0f, 1.0f,1.0f, - 1.0f,0.0f, 0.0f,1.0f, 0.0f,0.0f, - 1.0f,0.0f, 1.0f,1.0f, 0.0f,0.0f, - 0.0f,1.0f, 0.0f,0.0f, 1.0f,1.0f - }; - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(2,GL_FLOAT,0,afTexCoord); - - GLfloat afNormals[] = { - - 0,0,-1, 0,0,-1, 0,0,-1, - 0,0,-1, 0,0,-1, 0,0,-1, - 0,0,1, 0,0,1, 0,0,1, - 0,0,1, 0,0,1, 0,0,1, - - -1,0,0, -1,0,0, -1,0,0, - -1,0,0, -1,0,0, -1,0,0, - 1,0,0, 1,0,0, 1,0,0, - 1,0,0, 1,0,0, 1,0,0, - - 0,-1,0, 0,-1,0, 0,-1,0, - 0,-1,0, 0,-1,0, 0,-1,0, - 0,1,0, 0,1,0, 0,1,0, - 0,1,0, 0,1,0, 0,1,0 - }; - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT,0,afNormals); - - glDrawArrays(GL_TRIANGLES, 0, 36); -} - -void GLWidget::initializeGL () -{ - glClearColor(0.1f, 0.1f, 0.2f, 1.0f); - - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &m_uiTexture); - m_uiTexture = bindTexture(QImage(":/qt.png")); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - - GLfloat aLightPosition[] = {0.0f,0.3f,1.0f,0.0f}; - - glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, aLightPosition); - m_fAngle = 0; - m_fScale = 1; - createGeometry(); - createBubbles(bubbleNum - bubbles.count()); -} - -void GLWidget::paintGL() -{ - createBubbles(bubbleNum - bubbles.count()); - -//! [3] - QPainter painter; - painter.begin(this); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); -//! [3] - -//! [4] - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glMatrixMode(GL_TEXTURE); - glPushMatrix(); - - //Since OpenGL ES does not support glPush/PopAttrib(GL_ALL_ATTRIB_BITS) - //we have to take care of the states ourselves - - glClearColor(0.1f, 0.1f, 0.2f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_TEXTURE_2D); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - - glShadeModel(GL_FLAT); - glFrontFace(GL_CW); - glCullFace(GL_FRONT); - glEnable(GL_CULL_FACE); - glEnable(GL_DEPTH_TEST); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glRotatef(m_fAngle, 0.0f, 1.0f, 0.0f); - glRotatef(m_fAngle, 1.0f, 0.0f, 0.0f); - glRotatef(m_fAngle, 0.0f, 0.0f, 1.0f); - glScalef(m_fScale, m_fScale,m_fScale); - glTranslatef(0.0f,-0.2f,0.0f); - - GLfloat matDiff[] = {0.40f, 1.0f, 0.0f, 1.0f}; - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiff); - - if (qtLogo) - paintQtLogo(); - else - paintTexturedCube(); -//! [4] - -//![5] - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_TEXTURE); - glPopMatrix(); - - glDisable(GL_LIGHTING); - glDisable(GL_LIGHT0); - - glDisable(GL_DEPTH_TEST); - glDisable(GL_CULL_FACE); -//![5] - -//! [6] - if (m_showBubbles) - foreach (Bubble *bubble, bubbles) { - bubble->drawBubble(&painter); - } -//! [6] - -//! [7] - QString framesPerSecond; - framesPerSecond.setNum(frames /(time.elapsed() / 1000.0), 'f', 2); - - painter.setPen(Qt::white); - - painter.drawText(20, 40, framesPerSecond + " fps"); - - painter.end(); -//! [7] - -//! [8] - swapBuffers(); -//! [8] - - QMutableListIterator<Bubble*> iter(bubbles); - - while (iter.hasNext()) { - Bubble *bubble = iter.next(); - bubble->move(rect()); - } - if (!(frames % 100)) { - time.start(); - frames = 0; - } - m_fAngle += 1.0f; - frames ++; -} - -void GLWidget::createBubbles(int number) -{ - for (int i = 0; i < number; ++i) { - QPointF position(width()*(0.1 + (0.8*qrand()/(RAND_MAX+1.0))), - height()*(0.1 + (0.8*qrand()/(RAND_MAX+1.0)))); - qreal radius = qMin(width(), height())*(0.0175 + 0.0875*qrand()/(RAND_MAX+1.0)); - QPointF velocity(width()*0.0175*(-0.5 + qrand()/(RAND_MAX+1.0)), - height()*0.0175*(-0.5 + qrand()/(RAND_MAX+1.0))); - - bubbles.append(new Bubble(position, radius, velocity)); - } -} - -void GLWidget::createGeometry() -{ - vertices.clear(); - normals.clear(); - - qreal x1 = +0.06f; - qreal y1 = -0.14f; - qreal x2 = +0.14f; - qreal y2 = -0.06f; - qreal x3 = +0.08f; - qreal y3 = +0.00f; - qreal x4 = +0.30f; - qreal y4 = +0.22f; - - quad(x1, y1, x2, y2, y2, x2, y1, x1); - quad(x3, y3, x4, y4, y4, x4, y3, x3); - - extrude(x1, y1, x2, y2); - extrude(x2, y2, y2, x2); - extrude(y2, x2, y1, x1); - extrude(y1, x1, x1, y1); - extrude(x3, y3, x4, y4); - extrude(x4, y4, y4, x4); - extrude(y4, x4, y3, x3); - - const qreal Pi = 3.14159f; - const int NumSectors = 100; - - for (int i = 0; i < NumSectors; ++i) { - qreal angle1 = (i * 2 * Pi) / NumSectors; - qreal x5 = 0.30 * sin(angle1); - qreal y5 = 0.30 * cos(angle1); - qreal x6 = 0.20 * sin(angle1); - qreal y6 = 0.20 * cos(angle1); - - qreal angle2 = ((i + 1) * 2 * Pi) / NumSectors; - qreal x7 = 0.20 * sin(angle2); - qreal y7 = 0.20 * cos(angle2); - qreal x8 = 0.30 * sin(angle2); - qreal y8 = 0.30 * cos(angle2); - - quad(x5, y5, x6, y6, x7, y7, x8, y8); - - extrude(x6, y6, x7, y7); - extrude(x8, y8, x5, y5); - } - -//! [1] - m_vertexNumber = vertices.size(); - createdVertices = new GLfloat[m_vertexNumber]; - createdNormals = new GLfloat[m_vertexNumber]; - for (int i = 0;i < m_vertexNumber;i++) { - createdVertices[i] = vertices.at(i) * 2; - createdNormals[i] = normals.at(i); - } - vertices.clear(); - normals.clear(); -} -//! [1] - -//! [0] -void GLWidget::quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4) -{ - qreal nx, ny, nz; - - vertices << x1 << y1 << -0.05f; - vertices << x2 << y2 << -0.05f; - vertices << x4 << y4 << -0.05f; - - vertices << x3 << y3 << -0.05f; - vertices << x4 << y4 << -0.05f; - vertices << x2 << y2 << -0.05f; - - CrossProduct(nx, ny, nz, x2 - x1, y2 - y1, 0, x4 - x1, y4 - y1, 0); - Normalize(nx, ny, nz); - - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; - - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; - - vertices << x4 << y4 << 0.05f; - vertices << x2 << y2 << 0.05f; - vertices << x1 << y1 << 0.05f; - - vertices << x2 << y2 << 0.05f; - vertices << x4 << y4 << 0.05f; - vertices << x3 << y3 << 0.05f; - - CrossProduct(nx, ny, nz, x2 - x4, y2 - y4, 0, x1 - x4, y1 - y4, 0); - Normalize(nx, ny, nz); - - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; - - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; -} -//! [0] - -void GLWidget::extrude(qreal x1, qreal y1, qreal x2, qreal y2) -{ - qreal nx, ny, nz; - - vertices << x1 << y1 << +0.05f; - vertices << x2 << y2 << +0.05f; - vertices << x1 << y1 << -0.05f; - - vertices << x2 << y2 << -0.05f; - vertices << x1 << y1 << -0.05f; - vertices << x2 << y2 << +0.05f; - - CrossProduct(nx, ny, nz, x2 - x1, y2 - y1, 0.0f, 0.0f, 0.0f, -0.1f); - Normalize(nx, ny, nz); - - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; - - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; -} diff --git a/examples/opengl/hellogl_es/glwidget.h b/examples/opengl/hellogl_es/glwidget.h deleted file mode 100644 index 9908f63fd8..0000000000 --- a/examples/opengl/hellogl_es/glwidget.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GLWIDGET_H -#define GLWIDGET_H - -#include <QGLWidget> -#include <QTime> - - - -class Bubble; -class GLWidget : public QGLWidget { - - Q_OBJECT -public: - GLWidget(QWidget *parent = 0); - ~GLWidget(); -public slots: - void setScaling(int scale); - void setLogo(); - void setTexture(); - void showBubbles(bool); -protected: - void paintGL (); - void initializeGL (); -private: - GLuint m_uiTexture; - qreal m_fAngle; - qreal m_fScale; - bool m_showBubbles; - void paintTexturedCube(); - void paintQtLogo(); - void createGeometry(); - void createBubbles(int number); - void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4); - void extrude(qreal x1, qreal y1, qreal x2, qreal y2); - QList<qreal> vertices; - QList<qreal> normals; - GLfloat *createdVertices; - GLfloat *createdNormals; - int m_vertexNumber; - bool qtLogo; - QList<Bubble*> bubbles; - int frames; - QTime time; -}; -#endif diff --git a/examples/opengl/hellogl_es/hellogl_es.desktop b/examples/opengl/hellogl_es/hellogl_es.desktop deleted file mode 100644 index 11c1dd795c..0000000000 --- a/examples/opengl/hellogl_es/hellogl_es.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Name=Hello GL ES -Exec=/opt/usr/bin/hellogl_es -Icon=hellogl_es -X-Window-Icon= -X-HildonDesk-ShowInToolbar=true -X-Osso-Type=application/x-executable diff --git a/examples/opengl/hellogl_es/hellogl_es.pro b/examples/opengl/hellogl_es/hellogl_es.pro deleted file mode 100644 index c25ab30235..0000000000 --- a/examples/opengl/hellogl_es/hellogl_es.pro +++ /dev/null @@ -1,33 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Thu Oct 4 19:01:12 2007 -###################################################################### - -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . - -# Input -SOURCES += main.cpp -SOURCES += glwidget.cpp -SOURCES += mainwindow.cpp -SOURCES += bubble.cpp - -HEADERS += glwidget.h -HEADERS += mainwindow.h -HEADERS += bubble.h - -RESOURCES += texture.qrc -QT += opengl - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl_es -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hellogl_es.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl_es -INSTALLS += target sources - -symbian: CONFIG += qt_example -maemo5: CONFIG += qt_example - -symbian: warning(This example might not fully work on Symbian platform) -maemo5: warning(This example does not work on Maemo platform) -simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/opengl/hellogl_es/main.cpp b/examples/opengl/hellogl_es/main.cpp deleted file mode 100644 index 5693d7ad55..0000000000 --- a/examples/opengl/hellogl_es/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QApplication> -#include <QMainWindow> -#include "mainwindow.h" - -int main( int argc, char ** argv ) -{ - Q_INIT_RESOURCE(texture); - QApplication a( argc, argv ); - MainWindow mw; - mw.showMaximized(); - return a.exec(); -} diff --git a/examples/opengl/hellogl_es/mainwindow.cpp b/examples/opengl/hellogl_es/mainwindow.cpp deleted file mode 100644 index cd253fcd19..0000000000 --- a/examples/opengl/hellogl_es/mainwindow.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mainwindow.h" - -#include <QApplication> -#include <QMenuBar> -#include <QGroupBox> -#include <QGridLayout> -#include <QSlider> -#include <QLabel> -#include <QTimer> - -#include "glwidget.h" - -MainWindow::MainWindow() -{ - GLWidget *glwidget = new GLWidget(); - QLabel *label = new QLabel(this); - QTimer *timer = new QTimer(this); - QSlider *slider = new QSlider(this); - slider->setOrientation(Qt::Horizontal); - - slider->setRange(0, 100); - slider->setSliderPosition(50); - timer->setInterval(10); - label->setText("A QGlWidget with OpenGl ES"); - label->setAlignment(Qt::AlignHCenter); - - QGroupBox * groupBox = new QGroupBox(this); - setCentralWidget(groupBox); - groupBox->setTitle("OpenGL ES Example"); - - QGridLayout *layout = new QGridLayout(groupBox); - - layout->addWidget(glwidget,1,0,8,1); - layout->addWidget(label,9,0,1,1); - layout->addWidget(slider, 11,0,1,1); - - groupBox->setLayout(layout); - - QMenu *fileMenu = new QMenu("File"); - QMenu *helpMenu = new QMenu("Help"); - QMenu *showMenu = new QMenu("Show"); - menuBar()->addMenu(fileMenu); - menuBar()->addMenu(showMenu); - menuBar()->addMenu(helpMenu); - QAction *exit = new QAction("Exit", fileMenu); - QAction *aboutQt = new QAction("AboutQt", helpMenu); - QAction *showLogo = new QAction("Show 3D Logo", showMenu); - QAction *showTexture = new QAction("Show 2D Texture", showMenu); - QAction *showBubbles = new QAction("Show bubbles", showMenu); - showBubbles->setCheckable(true); - showBubbles->setChecked(true); - fileMenu->addAction(exit); - helpMenu->addAction(aboutQt); - showMenu->addAction(showLogo); - showMenu->addAction(showTexture); - showMenu->addAction(showBubbles); - - QObject::connect(timer, SIGNAL(timeout()), glwidget, SLOT(updateGL())); - QObject::connect(exit, SIGNAL(triggered(bool)), this, SLOT(close())); - QObject::connect(aboutQt, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt())); - - QObject::connect(showLogo, SIGNAL(triggered(bool)), glwidget, SLOT(setLogo())); - QObject::connect(showTexture, SIGNAL(triggered(bool)), glwidget, SLOT(setTexture())); - QObject::connect(showBubbles, SIGNAL(triggered(bool)), glwidget, SLOT(showBubbles(bool))); - QObject::connect(slider, SIGNAL(valueChanged(int)), glwidget, SLOT(setScaling(int))); - timer->start(); -} diff --git a/examples/opengl/hellogl_es/mainwindow.h b/examples/opengl/hellogl_es/mainwindow.h deleted file mode 100644 index a0a6adfc3c..0000000000 --- a/examples/opengl/hellogl_es/mainwindow.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include <QMainWindow> - -class QSlider; -class GLWidget; - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(); - -private: -}; - -#endif diff --git a/examples/opengl/hellogl_es/qt.png b/examples/opengl/hellogl_es/qt.png Binary files differdeleted file mode 100644 index 79e383cf50..0000000000 --- a/examples/opengl/hellogl_es/qt.png +++ /dev/null diff --git a/examples/opengl/hellogl_es/texture.qrc b/examples/opengl/hellogl_es/texture.qrc deleted file mode 100644 index ff1d0e535f..0000000000 --- a/examples/opengl/hellogl_es/texture.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>qt.png</file> -</qresource> -</RCC> diff --git a/examples/opengl/hellogl_es2/bubble.cpp b/examples/opengl/hellogl_es2/bubble.cpp index 167d9abd92..6db14e32bd 100644 --- a/examples/opengl/hellogl_es2/bubble.cpp +++ b/examples/opengl/hellogl_es2/bubble.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include "bubble.h" diff --git a/examples/opengl/hellogl_es2/hellogl_es2.pro b/examples/opengl/hellogl_es2/hellogl_es2.pro index 4061a0f678..2eef986ed2 100644 --- a/examples/opengl/hellogl_es2/hellogl_es2.pro +++ b/examples/opengl/hellogl_es2/hellogl_es2.pro @@ -17,7 +17,7 @@ HEADERS += mainwindow.h HEADERS += bubble.h RESOURCES += texture.qrc -QT += opengl +QT += opengl widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl_es2 diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp new file mode 100644 index 0000000000..10d9d346a6 --- /dev/null +++ b/examples/opengl/hellowindow/hellowindow.cpp @@ -0,0 +1,276 @@ +#include "hellowindow.h" + +#include <QOpenGLContext> + +#include <QTimer> + +#include <qmath.h> + +Renderer::Renderer(const QSurfaceFormat &format, Renderer *share) + : m_initialized(false) + , m_format(format) +{ + m_context = new QOpenGLContext(this); + m_context->setFormat(format); + if (share) + m_context->setShareContext(share->m_context); + m_context->create(); +} + +HelloWindow::HelloWindow(Renderer *renderer) + : m_colorIndex(0) + , m_renderer(renderer) +{ + setSurfaceType(QWindow::OpenGLSurface); + setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); + + setGeometry(QRect(10, 10, 640, 480)); + + setFormat(renderer->format()); + + create(); + + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(render())); + timer->start(10); + + connect(this, SIGNAL(needRender(QSurface *, const QColor &, const QSize &)), + renderer, SLOT(render(QSurface *, const QColor &, const QSize &))); + + updateColor(); +} + +void HelloWindow::mousePressEvent(QMouseEvent *) +{ + updateColor(); +} + +void HelloWindow::render() +{ + emit needRender(this, m_color, size()); +} + +void HelloWindow::updateColor() +{ + QColor colors[] = + { + QColor(100, 255, 0), + QColor(0, 100, 255) + }; + + m_color = colors[m_colorIndex]; + + m_colorIndex++; + if (m_colorIndex >= int(sizeof(colors) / sizeof(colors[0]))) + m_colorIndex = 0; +} + +void Renderer::render(QSurface *surface, const QColor &color, const QSize &viewSize) +{ + if (!m_context->makeCurrent(surface)) + return; + + if (!m_initialized) { + initialize(); + m_initialized = true; + } + + glViewport(0, 0, viewSize.width(), viewSize.height()); + + glClearColor(0.1f, 0.1f, 0.2f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glFrontFace(GL_CW); + glCullFace(GL_FRONT); + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + QMatrix4x4 modelview; + modelview.rotate(m_fAngle, 0.0f, 1.0f, 0.0f); + modelview.rotate(m_fAngle, 1.0f, 0.0f, 0.0f); + modelview.rotate(m_fAngle, 0.0f, 0.0f, 1.0f); + modelview.translate(0.0f, -0.2f, 0.0f); + + m_program->bind(); + m_program->setUniformValue(matrixUniform, modelview); + m_program->setUniformValue(colorUniform, color); + paintQtLogo(); + m_program->release(); + + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + + m_context->swapBuffers(surface); + + m_fAngle += 1.0f; +} + +void Renderer::paintQtLogo() +{ + m_program->enableAttributeArray(normalAttr); + m_program->enableAttributeArray(vertexAttr); + m_program->setAttributeArray(vertexAttr, vertices.constData()); + m_program->setAttributeArray(normalAttr, normals.constData()); + glDrawArrays(GL_TRIANGLES, 0, vertices.size()); + m_program->disableAttributeArray(normalAttr); + m_program->disableAttributeArray(vertexAttr); +} + +void Renderer::initialize() +{ + glClearColor(0.1f, 0.1f, 0.2f, 1.0f); + + QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this); + const char *vsrc = + "attribute highp vec4 vertex;\n" + "attribute mediump vec3 normal;\n" + "uniform mediump mat4 matrix;\n" + "uniform lowp vec4 sourceColor;\n" + "varying mediump vec4 color;\n" + "void main(void)\n" + "{\n" + " vec3 toLight = normalize(vec3(0.0, 0.3, 1.0));\n" + " float angle = max(dot(normal, toLight), 0.0);\n" + " vec3 col = sourceColor.rgb;\n" + " color = vec4(col * 0.2 + col * 0.8 * angle, 1.0);\n" + " color = clamp(color, 0.0, 1.0);\n" + " gl_Position = matrix * vertex;\n" + "}\n"; + vshader->compileSourceCode(vsrc); + + QOpenGLShader *fshader = new QOpenGLShader(QOpenGLShader::Fragment, this); + const char *fsrc = + "varying mediump vec4 color;\n" + "void main(void)\n" + "{\n" + " gl_FragColor = color;\n" + "}\n"; + fshader->compileSourceCode(fsrc); + + m_program = new QOpenGLShaderProgram; + m_program->addShader(vshader); + m_program->addShader(fshader); + m_program->link(); + + vertexAttr = m_program->attributeLocation("vertex"); + normalAttr = m_program->attributeLocation("normal"); + matrixUniform = m_program->uniformLocation("matrix"); + colorUniform = m_program->uniformLocation("sourceColor"); + + m_fAngle = 0; + createGeometry(); +} + +void Renderer::createGeometry() +{ + vertices.clear(); + normals.clear(); + + qreal x1 = +0.06f; + qreal y1 = -0.14f; + qreal x2 = +0.14f; + qreal y2 = -0.06f; + qreal x3 = +0.08f; + qreal y3 = +0.00f; + qreal x4 = +0.30f; + qreal y4 = +0.22f; + + quad(x1, y1, x2, y2, y2, x2, y1, x1); + quad(x3, y3, x4, y4, y4, x4, y3, x3); + + extrude(x1, y1, x2, y2); + extrude(x2, y2, y2, x2); + extrude(y2, x2, y1, x1); + extrude(y1, x1, x1, y1); + extrude(x3, y3, x4, y4); + extrude(x4, y4, y4, x4); + extrude(y4, x4, y3, x3); + + const qreal Pi = 3.14159f; + const int NumSectors = 100; + + for (int i = 0; i < NumSectors; ++i) { + qreal angle1 = (i * 2 * Pi) / NumSectors; + qreal x5 = 0.30 * qSin(angle1); + qreal y5 = 0.30 * qCos(angle1); + qreal x6 = 0.20 * qSin(angle1); + qreal y6 = 0.20 * qCos(angle1); + + qreal angle2 = ((i + 1) * 2 * Pi) / NumSectors; + qreal x7 = 0.20 * qSin(angle2); + qreal y7 = 0.20 * qCos(angle2); + qreal x8 = 0.30 * qSin(angle2); + qreal y8 = 0.30 * qCos(angle2); + + quad(x5, y5, x6, y6, x7, y7, x8, y8); + + extrude(x6, y6, x7, y7); + extrude(x8, y8, x5, y5); + } + + for (int i = 0;i < vertices.size();i++) + vertices[i] *= 2.0f; +} + +void Renderer::quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4) +{ + vertices << QVector3D(x1, y1, -0.05f); + vertices << QVector3D(x2, y2, -0.05f); + vertices << QVector3D(x4, y4, -0.05f); + + vertices << QVector3D(x3, y3, -0.05f); + vertices << QVector3D(x4, y4, -0.05f); + vertices << QVector3D(x2, y2, -0.05f); + + QVector3D n = QVector3D::normal + (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(x4 - x1, y4 - y1, 0.0f)); + + normals << n; + normals << n; + normals << n; + + normals << n; + normals << n; + normals << n; + + vertices << QVector3D(x4, y4, 0.05f); + vertices << QVector3D(x2, y2, 0.05f); + vertices << QVector3D(x1, y1, 0.05f); + + vertices << QVector3D(x2, y2, 0.05f); + vertices << QVector3D(x4, y4, 0.05f); + vertices << QVector3D(x3, y3, 0.05f); + + n = QVector3D::normal + (QVector3D(x2 - x4, y2 - y4, 0.0f), QVector3D(x1 - x4, y1 - y4, 0.0f)); + + normals << n; + normals << n; + normals << n; + + normals << n; + normals << n; + normals << n; +} + +void Renderer::extrude(qreal x1, qreal y1, qreal x2, qreal y2) +{ + vertices << QVector3D(x1, y1, +0.05f); + vertices << QVector3D(x2, y2, +0.05f); + vertices << QVector3D(x1, y1, -0.05f); + + vertices << QVector3D(x2, y2, -0.05f); + vertices << QVector3D(x1, y1, -0.05f); + vertices << QVector3D(x2, y2, +0.05f); + + QVector3D n = QVector3D::normal + (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(0.0f, 0.0f, -0.1f)); + + normals << n; + normals << n; + normals << n; + + normals << n; + normals << n; + normals << n; +} diff --git a/examples/opengl/hellowindow/hellowindow.h b/examples/opengl/hellowindow/hellowindow.h new file mode 100644 index 0000000000..6ff7411251 --- /dev/null +++ b/examples/opengl/hellowindow/hellowindow.h @@ -0,0 +1,65 @@ +#include <QWindow> + +#include <QtGui/qopengl.h> +#include <QtGui/qopenglshaderprogram.h> + +#include <QColor> +#include <QTime> + +class QOpenGLContext; + +class Renderer : public QObject +{ + Q_OBJECT +public: + Renderer(const QSurfaceFormat &format, Renderer *share = 0); + + QSurfaceFormat format() const { return m_format; } + +public slots: + void render(QSurface *surface, const QColor &color, const QSize &viewSize); + +private: + void initialize(); + + qreal m_fAngle; + bool m_showBubbles; + void paintQtLogo(); + void createGeometry(); + void createBubbles(int number); + void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4); + void extrude(qreal x1, qreal y1, qreal x2, qreal y2); + QVector<QVector3D> vertices; + QVector<QVector3D> normals; + int vertexAttr; + int normalAttr; + int matrixUniform; + int colorUniform; + + bool m_initialized; + QSurfaceFormat m_format; + QOpenGLContext *m_context; + QOpenGLShaderProgram *m_program; +}; + +class HelloWindow : public QWindow +{ + Q_OBJECT +public: + HelloWindow(Renderer *renderer); + + void updateColor(); + +signals: + void needRender(QSurface *surface, const QColor &color, const QSize &viewSize); + +private slots: + void render(); + +private: + void mousePressEvent(QMouseEvent *); + + int m_colorIndex; + QColor m_color; + Renderer *m_renderer; +}; diff --git a/examples/opengl/hellowindow/hellowindow.pro b/examples/opengl/hellowindow/hellowindow.pro new file mode 100644 index 0000000000..555dc83574 --- /dev/null +++ b/examples/opengl/hellowindow/hellowindow.pro @@ -0,0 +1,18 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Wed Apr 27 16:40:46 2011 +###################################################################### + +TEMPLATE = app +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += hellowindow.h +SOURCES += hellowindow.cpp main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellowindow +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hellowindow.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellowindow +INSTALLS += target sources + diff --git a/examples/opengl/hellowindow/main.cpp b/examples/opengl/hellowindow/main.cpp new file mode 100644 index 0000000000..b247807019 --- /dev/null +++ b/examples/opengl/hellowindow/main.cpp @@ -0,0 +1,50 @@ +#include <QGuiApplication> +#include <QScreen> +#include <QThread> + +#include "hellowindow.h" + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + QScreen *screen = QGuiApplication::primaryScreen(); + + QRect screenGeometry = screen->availableGeometry(); + + QSurfaceFormat format; + format.setDepthBufferSize(16); + format.setSamples(4); + + QPoint center = QPoint(screenGeometry.center().x(), screenGeometry.top() + 80); + QSize windowSize(400, 320); + int delta = 40; + + Renderer rendererA(format); + Renderer rendererB(format, &rendererA); + + QThread renderThread; + rendererB.moveToThread(&renderThread); + renderThread.start(); + + QObject::connect(qGuiApp, SIGNAL(lastWindowClosed()), &renderThread, SLOT(quit())); + + HelloWindow windowA(&rendererA); + windowA.setGeometry(QRect(center, windowSize).translated(-windowSize.width() - delta / 2, 0)); + windowA.setWindowTitle(QLatin1String("Thread A - Context A")); + windowA.setVisible(true); + + HelloWindow windowB(&rendererA); + windowB.setGeometry(QRect(center, windowSize).translated(delta / 2, 0)); + windowB.setWindowTitle(QLatin1String("Thread A - Context A")); + windowB.setVisible(true); + + HelloWindow windowC(&rendererB); + windowC.setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, windowSize.height() + delta)); + windowC.setWindowTitle(QLatin1String("Thread B - Context B")); + windowC.setVisible(true); + + app.exec(); + + renderThread.wait(); +} diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro index 2a96807102..5502ee270a 100644 --- a/examples/opengl/opengl.pro +++ b/examples/opengl/opengl.pro @@ -22,6 +22,11 @@ contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2){ textures } +qpa { + SUBDIRS += hellowindow + SUBDIRS += paintedwindow +} + # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS opengl.pro README @@ -29,4 +34,5 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl INSTALLS += target sources symbian: CONFIG += qt_example +QT += widgets maemo5: CONFIG += qt_example diff --git a/examples/opengl/overpainting/bubble.cpp b/examples/opengl/overpainting/bubble.cpp index eb315057fa..bb6d2b8070 100644 --- a/examples/opengl/overpainting/bubble.cpp +++ b/examples/opengl/overpainting/bubble.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include "bubble.h" diff --git a/examples/opengl/overpainting/glwidget.cpp b/examples/opengl/overpainting/glwidget.cpp index ded7bf1cf5..4572e69644 100644 --- a/examples/opengl/overpainting/glwidget.cpp +++ b/examples/opengl/overpainting/glwidget.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include <QtOpenGL> #include <stdlib.h> diff --git a/examples/opengl/overpainting/overpainting.pro b/examples/opengl/overpainting/overpainting.pro index 6dfcf28ad1..1584c3c3d4 100644 --- a/examples/opengl/overpainting/overpainting.pro +++ b/examples/opengl/overpainting/overpainting.pro @@ -1,7 +1,7 @@ VPATH += ../shared INCLUDEPATH += ../shared -QT += opengl +QT += opengl widgets HEADERS = bubble.h \ glwidget.h \ qtlogo.h diff --git a/examples/opengl/paintedwindow/main.cpp b/examples/opengl/paintedwindow/main.cpp new file mode 100644 index 0000000000..345cea7bc5 --- /dev/null +++ b/examples/opengl/paintedwindow/main.cpp @@ -0,0 +1,23 @@ +#include <QGuiApplication> +#include <QRect> +#include <QScreen> + +#include "paintedwindow.h" + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + QScreen *screen = QGuiApplication::primaryScreen(); + + QRect screenGeometry = screen->availableGeometry(); + + QPoint center = screenGeometry.center(); + QRect windowRect(0, 0, 640, 480); + + PaintedWindow window; + window.setGeometry(QRect(center - windowRect.center(), windowRect.size())); + window.show(); + + app.exec(); +} diff --git a/examples/opengl/paintedwindow/paintedwindow.cpp b/examples/opengl/paintedwindow/paintedwindow.cpp new file mode 100644 index 0000000000..9b27c56914 --- /dev/null +++ b/examples/opengl/paintedwindow/paintedwindow.cpp @@ -0,0 +1,53 @@ +#include "paintedwindow.h" + +#include <QOpenGLContext> +#include <QOpenGLPaintDevice> +#include <QPainter> +#include <QTimer> + +#include <qmath.h> + +PaintedWindow::PaintedWindow() +{ + QSurfaceFormat format; + format.setStencilBufferSize(8); + format.setSamples(4); + + setSurfaceType(QWindow::OpenGLSurface); + setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); + setFormat(format); + + create(); + + m_context = new QOpenGLContext(this); + m_context->setFormat(format); + m_context->create(); +} + +void PaintedWindow::resizeEvent(QResizeEvent *) +{ + paint(); +} + +void PaintedWindow::exposeEvent(QExposeEvent *) +{ + paint(); +} + +void PaintedWindow::paint() +{ + m_context->makeCurrent(this); + + QPainterPath path; + path.addEllipse(0, 0, width(), height()); + + QOpenGLPaintDevice device(size()); + + QPainter painter(&device); + painter.fillRect(0, 0, width(), height(), Qt::white); + painter.setRenderHint(QPainter::Antialiasing); + painter.fillPath(path, Qt::blue); + painter.end(); + + m_context->swapBuffers(this); +} diff --git a/examples/opengl/paintedwindow/paintedwindow.h b/examples/opengl/paintedwindow/paintedwindow.h new file mode 100644 index 0000000000..9da9992a3e --- /dev/null +++ b/examples/opengl/paintedwindow/paintedwindow.h @@ -0,0 +1,26 @@ +#include <QWindow> + +#include <QtGui/qopengl.h> +#include <QtGui/qopenglshaderprogram.h> +#include <QtGui/qopenglframebufferobject.h> + +#include <QColor> +#include <QTime> + +class QOpenGLContext; + +class PaintedWindow : public QWindow +{ + Q_OBJECT +public: + PaintedWindow(); + +private slots: + void paint(); + +private: + void resizeEvent(QResizeEvent *); + void exposeEvent(QExposeEvent *); + + QOpenGLContext *m_context; +}; diff --git a/examples/opengl/paintedwindow/paintedwindow.pro b/examples/opengl/paintedwindow/paintedwindow.pro new file mode 100644 index 0000000000..a3ae3bace5 --- /dev/null +++ b/examples/opengl/paintedwindow/paintedwindow.pro @@ -0,0 +1,18 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Wed Apr 27 16:40:46 2011 +###################################################################### + +TEMPLATE = app +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += paintedwindow.h +SOURCES += paintedwindow.cpp main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/paintedwindow +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS paintedwindow.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/paintedwindow +INSTALLS += target sources + diff --git a/examples/opengl/pbuffers/main.cpp b/examples/opengl/pbuffers/main.cpp index b4f1512cfe..aac6d1939c 100644 --- a/examples/opengl/pbuffers/main.cpp +++ b/examples/opengl/pbuffers/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ -#include <QtGui/QApplication> -#include <QtGui/QMessageBox> +#include <QtWidgets/QApplication> +#include <QtWidgets/QMessageBox> #include <QtOpenGL/QGLPixelBuffer> #include "glwidget.h" diff --git a/examples/opengl/pbuffers/pbuffers.pro b/examples/opengl/pbuffers/pbuffers.pro index 755ed8c6a8..3264be3cef 100644 --- a/examples/opengl/pbuffers/pbuffers.pro +++ b/examples/opengl/pbuffers/pbuffers.pro @@ -4,7 +4,7 @@ SOURCES += glwidget.cpp \ main.cpp \ cube.cpp RESOURCES += pbuffers.qrc -QT += opengl +QT += opengl widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/pbuffers diff --git a/examples/opengl/pbuffers2/main.cpp b/examples/opengl/pbuffers2/main.cpp index 0abe0b9faa..573b7f2cda 100644 --- a/examples/opengl/pbuffers2/main.cpp +++ b/examples/opengl/pbuffers2/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ -#include <QtGui/QApplication> -#include <QtGui/QMessageBox> +#include <QtWidgets/QApplication> +#include <QtWidgets/QMessageBox> #include "glwidget.h" int main(int argc, char **argv) diff --git a/examples/opengl/pbuffers2/pbuffers2.pro b/examples/opengl/pbuffers2/pbuffers2.pro index d70981879d..9b30d793b8 100644 --- a/examples/opengl/pbuffers2/pbuffers2.pro +++ b/examples/opengl/pbuffers2/pbuffers2.pro @@ -6,7 +6,7 @@ TEMPLATE = app DEPENDPATH += . INCLUDEPATH += . -QT += opengl svg +QT += opengl svg widgets # Input HEADERS += glwidget.h diff --git a/examples/opengl/samplebuffers/main.cpp b/examples/opengl/samplebuffers/main.cpp index 8d4df924dd..c940541327 100644 --- a/examples/opengl/samplebuffers/main.cpp +++ b/examples/opengl/samplebuffers/main.cpp @@ -38,8 +38,8 @@ ** ****************************************************************************/ -#include <QtGui/QApplication> -#include <QtGui/QMessageBox> +#include <QtWidgets/QApplication> +#include <QtWidgets/QMessageBox> #include "glwidget.h" int main(int argc, char **argv) diff --git a/examples/opengl/samplebuffers/samplebuffers.pro b/examples/opengl/samplebuffers/samplebuffers.pro index a8938b9dc1..d8f9ff1cd7 100644 --- a/examples/opengl/samplebuffers/samplebuffers.pro +++ b/examples/opengl/samplebuffers/samplebuffers.pro @@ -1,7 +1,7 @@ HEADERS += glwidget.h SOURCES += glwidget.cpp main.cpp -QT += opengl +QT += opengl widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/samplebuffers diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp index b5374c0200..4e74cf9d1d 100644 --- a/examples/opengl/textures/glwidget.cpp +++ b/examples/opengl/textures/glwidget.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include <QtOpenGL> #include "glwidget.h" diff --git a/examples/opengl/textures/glwidget.h b/examples/opengl/textures/glwidget.h index fd9246bef2..86dc889107 100644 --- a/examples/opengl/textures/glwidget.h +++ b/examples/opengl/textures/glwidget.h @@ -41,7 +41,7 @@ #ifndef GLWIDGET_H #define GLWIDGET_H -#include <QtGui> +#include <QtWidgets> #include <QGLWidget> class QGLShaderProgram; diff --git a/examples/opengl/textures/textures.pro b/examples/opengl/textures/textures.pro index 5bb0d5782e..d8941b3890 100644 --- a/examples/opengl/textures/textures.pro +++ b/examples/opengl/textures/textures.pro @@ -4,7 +4,7 @@ SOURCES = glwidget.cpp \ main.cpp \ window.cpp RESOURCES = textures.qrc -QT += opengl +QT += opengl widgets # install target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/textures diff --git a/examples/opengl/textures/window.cpp b/examples/opengl/textures/window.cpp index 50f3afecce..16f402efab 100644 --- a/examples/opengl/textures/window.cpp +++ b/examples/opengl/textures/window.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include "glwidget.h" #include "window.h" |