summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/gui/gui.pro2
-rw-r--r--examples/opengl/hellogl_es/glwindow.cpp320
-rw-r--r--examples/opengl/hellogl_es/glwindow.h78
-rw-r--r--examples/opengl/hellogl_es/hellogl_es.pro11
-rw-r--r--examples/opengl/hellogl_es/main.cpp52
-rw-r--r--examples/opengl/hellogl_es/qt.pngbin5174 -> 0 bytes
-rw-r--r--examples/opengl/hellogl_es/texture.qrc5
-rw-r--r--examples/opengl/opengl.pro18
-rw-r--r--examples/widgets/painting/shared/shared.pri2
-rw-r--r--examples/widgets/widgets.pro4
10 files changed, 9 insertions, 483 deletions
diff --git a/examples/gui/gui.pro b/examples/gui/gui.pro
index 5fb4241e74..3a63ffb5eb 100644
--- a/examples/gui/gui.pro
+++ b/examples/gui/gui.pro
@@ -5,6 +5,6 @@ CONFIG += no_docs_target
SUBDIRS += analogclock
SUBDIRS += rasterwindow
-contains(QT_CONFIG, opengl(es1|es2)?) {
+contains(QT_CONFIG, opengl(es2)?) {
SUBDIRS += openglwindow
}
diff --git a/examples/opengl/hellogl_es/glwindow.cpp b/examples/opengl/hellogl_es/glwindow.cpp
deleted file mode 100644
index 38366ee785..0000000000
--- a/examples/opengl/hellogl_es/glwindow.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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 "glwindow.h"
-
-#include <QGuiApplication>
-#include <QScreen>
-#include <QTimer>
-
-#include <math.h>
-#include <stdio.h>
-
-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;
-}
-
-GLWindow::GLWindow()
-{
- setSurfaceType(OpenGLSurface);
-
- qtLogo = true;
- createdVertices = 0;
- createdNormals = 0;
- m_vertexNumber = 0;
- frames = 0;
-
- m_fScale = 1;
-
- QSurfaceFormat format;
- format.setDepthBufferSize(24);
- format.setMajorVersion(1);
- format.setMinorVersion(1);
-
- setGeometry(QGuiApplication::primaryScreen()->availableGeometry());
- setFormat(format);
- create();
-
- m_context = new QOpenGLContext;
- m_context->setFormat(format);
- m_context->create();
-
- m_context->makeCurrent(this);
- initializeGL();
-
- QTimer *timer = new QTimer(this);
- timer->setInterval(16);
- connect(timer, SIGNAL(timeout()), this, SLOT(paintGL()));
- timer->start();
-}
-
-GLWindow::~GLWindow()
-{
- if (createdVertices)
- delete[] createdVertices;
- if (createdNormals)
- delete[] createdNormals;
-
- delete m_context;
-}
-
-void GLWindow::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);
-}
-
-void GLWindow::initializeGL ()
-{
- glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
-
- 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();
-}
-
-void GLWindow::paintGL()
-{
- m_context->makeCurrent(this);
-
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- 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);
-
- paintQtLogo();
-
- 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);
-
- m_context->swapBuffers(this);
-
- m_fAngle += 1.0f;
-}
-
-void GLWindow::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);
- }
-
- 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();
-}
-
-void GLWindow::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;
-}
-
-void GLWindow::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/glwindow.h b/examples/opengl/hellogl_es/glwindow.h
deleted file mode 100644
index 752145fff9..0000000000
--- a/examples/opengl/hellogl_es/glwindow.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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 GLWINDOW_H
-#define GLWINDOW_H
-
-#include <GLES/gl.h>
-
-#include <QOpenGLContext>
-#include <QWindow>
-#include <QTime>
-
-class GLWindow : public QWindow {
- Q_OBJECT
-public:
- GLWindow();
- ~GLWindow();
-
-protected slots:
- void paintGL();
- void initializeGL();
-
-private:
- qreal m_fAngle;
- qreal m_fScale;
- QOpenGLContext *m_context;
- void paintQtLogo();
- void createGeometry();
- 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;
- int frames;
- QTime time;
-};
-
-#endif
diff --git a/examples/opengl/hellogl_es/hellogl_es.pro b/examples/opengl/hellogl_es/hellogl_es.pro
deleted file mode 100644
index 56328030d5..0000000000
--- a/examples/opengl/hellogl_es/hellogl_es.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-QT += gui
-
-SOURCES += main.cpp
-SOURCES += glwindow.cpp
-
-HEADERS += glwindow.h
-
-RESOURCES += texture.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellogl_es
-INSTALLS += target
diff --git a/examples/opengl/hellogl_es/main.cpp b/examples/opengl/hellogl_es/main.cpp
deleted file mode 100644
index 6cb5647024..0000000000
--- a/examples/opengl/hellogl_es/main.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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 <QGuiApplication>
-
-#include "glwindow.h"
-
-int main( int argc, char ** argv )
-{
- Q_INIT_RESOURCE(texture);
- QGuiApplication a( argc, argv );
- GLWindow window;
- window.show();
- return a.exec();
-}
diff --git a/examples/opengl/hellogl_es/qt.png b/examples/opengl/hellogl_es/qt.png
deleted file mode 100644
index 79e383cf50..0000000000
--- a/examples/opengl/hellogl_es/qt.png
+++ /dev/null
Binary files differ
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/opengl.pro b/examples/opengl/opengl.pro
index bcf62b6551..7bc96234df 100644
--- a/examples/opengl/opengl.pro
+++ b/examples/opengl/opengl.pro
@@ -2,16 +2,8 @@ requires(qtHaveModule(opengl))
TEMPLATE = subdirs
-contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2){
- contains(QT_CONFIG, opengles2) {
- SUBDIRS = hellogl_es2
- } else {
- SUBDIRS = hellogl_es
- }
- SUBDIRS += textures
- contains(QT_CONFIG, opengles1) {
- SUBDIRS += hellogl
- }
+contains(QT_CONFIG, opengles2) {
+ SUBDIRS = hellogl_es2
} else {
SUBDIRS = 2dpainting \
grabber \
@@ -19,13 +11,13 @@ contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2){
overpainting \
pbuffers \
framebufferobject2 \
- samplebuffers \
- textures
+ samplebuffers
}
SUBDIRS += hellowindow \
paintedwindow \
contextinfo \
- cube
+ cube \
+ textures
EXAMPLE_FILES = shared
diff --git a/examples/widgets/painting/shared/shared.pri b/examples/widgets/painting/shared/shared.pri
index af027e081a..c8d119f4e5 100644
--- a/examples/widgets/painting/shared/shared.pri
+++ b/examples/widgets/painting/shared/shared.pri
@@ -1,6 +1,6 @@
INCLUDEPATH += $$PWD
-qtHaveModule(opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2) {
+qtHaveModule(opengl)|contains(QT_CONFIG, opengles2) {
DEFINES += QT_OPENGL_SUPPORT
QT += opengl widgets
}
diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro
index d7d3dbc445..cc489b5c16 100644
--- a/examples/widgets/widgets.pro
+++ b/examples/widgets/widgets.pro
@@ -22,11 +22,11 @@ SUBDIRS = \
tutorials \
widgets
-contains(QT_CONFIG, opengl(es1|es2)?) {
+contains(QT_CONFIG, opengl(es2)?) {
SUBDIRS += windowcontainer
}
-!contains(QT_CONFIG, opengl(es1|es2)?): SUBDIRS -= windowcontainer
+!contains(QT_CONFIG, opengl(es2)?): SUBDIRS -= windowcontainer
contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= mainwindows
contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= draganddrop
mac:SUBDIRS += mac