summaryrefslogtreecommitdiffstats
path: root/demos/qt3d/pageflip
diff options
context:
space:
mode:
Diffstat (limited to 'demos/qt3d/pageflip')
-rw-r--r--demos/qt3d/pageflip/gradient.pngbin229 -> 0 bytes
-rw-r--r--demos/qt3d/pageflip/pageflip.cpp388
-rw-r--r--demos/qt3d/pageflip/pageflip.desktop7
-rw-r--r--demos/qt3d/pageflip/pageflip.pro17
-rw-r--r--demos/qt3d/pageflip/pageflip.qrc9
-rw-r--r--demos/qt3d/pageflip/pageflip.rc1
-rw-r--r--demos/qt3d/pageflip/pageflipmath.cpp592
-rw-r--r--demos/qt3d/pageflip/pageflipmath_p.h120
-rw-r--r--demos/qt3d/pageflip/qqpage1.pngbin77887 -> 0 bytes
-rw-r--r--demos/qt3d/pageflip/qqpage2.pngbin74710 -> 0 bytes
-rw-r--r--demos/qt3d/pageflip/qqpage3.pngbin73043 -> 0 bytes
-rw-r--r--demos/qt3d/pageflip/qqpage4.pngbin78092 -> 0 bytes
-rw-r--r--demos/qt3d/pageflip/qt3d.icobin67646 -> 0 bytes
-rw-r--r--demos/qt3d/pageflip/qt3d.pngbin3677 -> 0 bytes
14 files changed, 0 insertions, 1134 deletions
diff --git a/demos/qt3d/pageflip/gradient.png b/demos/qt3d/pageflip/gradient.png
deleted file mode 100644
index ddadf69d..00000000
--- a/demos/qt3d/pageflip/gradient.png
+++ /dev/null
Binary files differ
diff --git a/demos/qt3d/pageflip/pageflip.cpp b/demos/qt3d/pageflip/pageflip.cpp
deleted file mode 100644
index a6e1f232..00000000
--- a/demos/qt3d/pageflip/pageflip.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation ([email protected])
-**
-** This file is part of the QtQuick3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QTimer>
-#include <QMouseEvent>
-#include "qglpainter.h"
-#include "qglabstracteffect.h"
-#include "qgltexture2d.h"
-#include "qglshaderprogrameffect.h"
-#include <QtOpenGL/qglshaderprogram.h>
-#include "pageflipmath_p.h"
-
-class PageFlipGradientEffect;
-
-class PageFlipView : public QGLWidget
-{
- Q_OBJECT
-public:
- PageFlipView(QWidget *parent = 0);
- ~PageFlipView();
-
- void setBlend(bool value) { blend = value; }
- void setVertical(bool value) { vertical = value; }
-
-protected:
- void resizeGL(int width, int height);
- void initializeGL();
- void paintGL();
- void mousePressEvent(QMouseEvent *e);
-
-private slots:
- void animate();
-
-private:
- bool blend;
- bool vertical;
-
- qreal posn; // Position within the animation - 0...1
- QSize pageSize; // Size of a page within the window.
-
- QRect pageRect1;
- QRect pageRect2;
-
- QColor colors[4];
- int colorIndex;
-
- QGLTexture2D textures[4];
-
- QGLTexture2D gradientTexture;
-
- PageFlipMath pageFlipMath;
-
- PageFlipGradientEffect *effect;
-
- void setAlphaValue(QGLPainter *painter, GLfloat value);
-};
-
-class PageFlipGradientEffect : public QGLShaderProgramEffect
-{
-public:
- PageFlipGradientEffect();
- ~PageFlipGradientEffect();
-
- void setAlphaValue(GLfloat value);
-};
-
-PageFlipView::PageFlipView(QWidget *parent)
- : QGLWidget(parent)
-{
- posn = 0.0f;
- blend = false;
- vertical = false;
-
- colors[0] = QColor(0, 192, 192, 255);
- colors[1] = QColor(192, 0, 0, 255);
- colors[2] = QColor(192, 192, 0, 255);
- colors[3] = QColor(128, 128, 0, 255);
- colorIndex = 0;
-
- QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(animate()));
- timer->start(40);
-
- effect = new PageFlipGradientEffect();
-}
-
-PageFlipView::~PageFlipView()
-{
- delete effect;
-}
-
-void PageFlipView::resizeGL(int width, int height)
-{
- glViewport(0, 0, width, height);
-}
-
-void PageFlipView::initializeGL()
-{
- QGLPainter painter(this);
-
- //QSize size = rect().size();
- //int width = size.width() / 3;
- //int height = (int)(width * 1.414f);
- int width = 227;
- int height = 320;
- pageSize = QSize(width, height);
-
- textures[0].setImage(QImage(QLatin1String(":/qqpage1.png")));
- textures[1].setImage(QImage(QLatin1String(":/qqpage2.png")));
- textures[2].setImage(QImage(QLatin1String(":/qqpage3.png")));
- textures[3].setImage(QImage(QLatin1String(":/qqpage4.png")));
-
- gradientTexture.setImage(QImage(QLatin1String(":/gradient.png")));
-
- if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendColor))
- painter.glBlendColor(0, 0, 0, 0);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendEquation))
- painter.glBlendEquation(GL_FUNC_ADD);
- else if (painter.hasOpenGLFeature(QOpenGLFunctions::BlendEquationSeparate))
- painter.glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
-
- glEnable(GL_BLEND);
-
- if (vertical)
- pageFlipMath.setStartCorner(PageFlipMath::VerticalBottomRight);
- else
- pageFlipMath.setStartCorner(PageFlipMath::BottomRight);
-}
-
-void PageFlipView::paintGL()
-{
- QGLPainter painter(this);
-
- QRect rect = this->rect();
- int midx = rect.width() / 2;
- int topy = (rect.height() - pageSize.height()) / 2;
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- QMatrix4x4 projm;
- projm.ortho(rect);
- painter.projectionMatrix() = projm;
- painter.modelViewMatrix().setToIdentity();
-
- if (vertical) {
- pageRect2 = QRect(QPoint(midx - pageSize.width() / 2, topy), pageSize);
- pageRect1 = QRect(QPoint(pageRect2.x() - pageSize.width(), topy), pageSize);
- } else {
- pageRect1 = QRect(QPoint(midx - pageSize.width(), topy), pageSize);
- pageRect2 = QRect(QPoint(midx, topy), pageSize);
- }
- pageFlipMath.setPageRect(pageRect2);
- pageFlipMath.setShowPageReverse(false);
- pageFlipMath.compute(posn);
-
- QGLAttributeValue positions
- (2, GL_FLOAT, pageFlipMath.stride(), pageFlipMath.vertexArray());
- QGLAttributeValue texCoords
- (2, GL_FLOAT, pageFlipMath.stride(), pageFlipMath.vertexArray() + 2);
- QGLAttributeValue gradientCoords
- (1, GL_FLOAT, pageFlipMath.stride(), pageFlipMath.vertexArray() + 4);
-
- if (painter.isFixedFunction())
- painter.setStandardEffect(QGL::FlatReplaceTexture2D);
- else
- painter.setUserEffect(effect);
- painter.setColor(colors[colorIndex]);
- painter.glActiveTexture(GL_TEXTURE0);
- textures[colorIndex].bind();
- if (!painter.isFixedFunction()) {
- painter.glActiveTexture(GL_TEXTURE1);
- gradientTexture.bind();
- }
- painter.clearAttributes();
- painter.setVertexAttribute(QGL::Position, positions);
- painter.setVertexAttribute(QGL::TextureCoord0, texCoords);
- painter.setVertexAttribute(QGL::CustomVertex0, gradientCoords);
- setAlphaValue(&painter, 1.0f);
- painter.update();
- pageFlipMath.drawPage(0);
-
- painter.setColor(colors[(colorIndex + 1) % 4]);
- painter.glActiveTexture(GL_TEXTURE0);
- textures[(colorIndex + 1) % 4].bind();
- setAlphaValue(&painter, 1.0f);
- painter.update();
- pageFlipMath.drawPage(1);
-
- painter.setColor(colors[(colorIndex + 2) % 4]);
- if (!pageFlipMath.showPageReverse())
- textures[(colorIndex + 2) % 4].bind();
- if (blend)
- setAlphaValue(&painter, 0.75f);
- else
- setAlphaValue(&painter, 1.0f);
- painter.update();
- pageFlipMath.drawPage(2);
-
- painter.setColor(colors[(colorIndex + 3) % 4]);
- textures[(colorIndex + 3) % 4].bind();
- setAlphaValue(&painter, 1.0f);
- painter.update();
- pageFlipMath.drawPage(3);
-
- glBindTexture(GL_TEXTURE_2D, 0);
- painter.glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, 0);
-
- painter.setStandardEffect(QGL::FlatColor);
- painter.clearAttributes();
- painter.setVertexAttribute(QGL::Position, positions);
- painter.setVertexAttribute(QGL::TextureCoord0, texCoords);
- painter.setVertexAttribute(QGL::CustomVertex0, gradientCoords);
- painter.setColor(QColor(0, 0, 0, 255));
- painter.update();
- pageFlipMath.drawOutline(2);
-}
-
-void PageFlipView::mousePressEvent(QMouseEvent *e)
-{
- int x = e->x();
- int y = e->y();
- bool changed = true;
- if (vertical) {
- if (x >= pageRect2.x() && x < (pageRect2.x() + 20) &&
- y >= pageRect2.y() && y < (pageRect2.y() + 20))
- pageFlipMath.setStartCorner(PageFlipMath::VerticalTopLeft);
- else if (x >= pageRect2.x() && x < (pageRect2.x() + 20) &&
- y >= (pageRect2.bottom() - 20) && y <= pageRect2.bottom())
- pageFlipMath.setStartCorner(PageFlipMath::VerticalBottomLeft);
- else if (x >= (pageRect2.right() - 20) && x <= pageRect2.right() &&
- y >= pageRect2.y() && y < (pageRect2.y() + 20))
- pageFlipMath.setStartCorner(PageFlipMath::VerticalTopRight);
- else if (x >= (pageRect2.right() - 20) && x <= pageRect2.right() &&
- y >= (pageRect2.bottom() - 20) && y <= pageRect2.bottom())
- pageFlipMath.setStartCorner(PageFlipMath::VerticalBottomRight);
- else
- changed = false;
- } else {
- if (x >= pageRect1.x() && x < (pageRect1.x() + 20) &&
- y >= pageRect1.y() && y < (pageRect1.y() + 20))
- pageFlipMath.setStartCorner(PageFlipMath::TopLeft);
- else if (x >= pageRect1.x() && x < (pageRect1.x() + 20) &&
- y >= (pageRect1.bottom() - 20) && y <= pageRect1.bottom())
- pageFlipMath.setStartCorner(PageFlipMath::BottomLeft);
- else if (x >= pageRect2.x() && x < (pageRect2.x() + 20) &&
- y >= pageRect2.y() && y < (pageRect2.y() + 20))
- pageFlipMath.setStartCorner(PageFlipMath::TopLeftOnePage);
- else if (x >= pageRect2.x() && x < (pageRect2.x() + 20) &&
- y >= (pageRect2.bottom() - 20) && y <= pageRect2.bottom())
- pageFlipMath.setStartCorner(PageFlipMath::BottomLeftOnePage);
- else if (x >= (pageRect2.right() - 20) && x <= pageRect2.right() &&
- y >= pageRect2.y() && y < (pageRect2.y() + 20))
- pageFlipMath.setStartCorner(PageFlipMath::TopRight);
- else if (x >= (pageRect2.right() - 20) && x <= pageRect2.right() &&
- y >= (pageRect2.bottom() - 20) && y <= pageRect2.bottom())
- pageFlipMath.setStartCorner(PageFlipMath::BottomRight);
- else
- changed = false;
- }
- if (changed)
- posn = 0.0f;
- QGLWidget::mousePressEvent(e);
-}
-
-void PageFlipView::animate()
-{
- posn += 0.04f;
- if (posn >= 1.0f) {
- posn = 0.0f;
- colorIndex = (colorIndex + 2) % 4;
- }
- updateGL();
-}
-
-void PageFlipView::setAlphaValue(QGLPainter *painter, GLfloat value)
-{
- if (!painter->isFixedFunction())
- effect->setAlphaValue(value);
-}
-
-static char const gradientVertexShader[] =
- "attribute highp vec4 qt_Vertex;\n"
- "attribute highp vec4 qt_MultiTexCoord0;\n"
- "attribute highp float qt_Custom0;\n"
- "uniform mediump mat4 qt_ModelViewProjectionMatrix;\n"
- "varying highp vec4 qt_TexCoord0;\n"
- "varying highp float qGradCtrl;\n"
- "void main(void)\n"
- "{\n"
- " gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;\n"
- " qt_TexCoord0 = qt_MultiTexCoord0;\n"
- " qGradCtrl = qt_Custom0;\n"
- "}\n";
-
-static char const gradientFragmentShader[] =
- "uniform sampler2D qt_Texture0;\n"
- "uniform sampler2D qt_Texture1;\n"
- "uniform mediump float alphaValue;\n"
- "varying highp vec4 qt_TexCoord0;\n"
- "varying highp float qGradCtrl;\n"
- "void main(void)\n"
- "{\n"
- " mediump vec4 col = texture2D(qt_Texture0, qt_TexCoord0.st);\n"
- " mediump vec4 gradcol = texture2D(qt_Texture1, vec2(qGradCtrl, qt_TexCoord0.t));\n"
- " gl_FragColor = vec4((col * gradcol).xyz, alphaValue);\n"
- "}\n";
-
-PageFlipGradientEffect::PageFlipGradientEffect()
-{
- setVertexShader(gradientVertexShader);
- setFragmentShader(gradientFragmentShader);
-}
-
-PageFlipGradientEffect::~PageFlipGradientEffect()
-{
-}
-
-void PageFlipGradientEffect::setAlphaValue(GLfloat value)
-{
- program()->setUniformValue("alphaValue", value);
-}
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- PageFlipView view;
- if (QApplication::arguments().contains(QLatin1String("-blend")))
- view.setBlend(true);
- if (QApplication::arguments().contains(QLatin1String("-vertical")))
- view.setVertical(true);
-
-
-#ifdef Q_OS_SYMBIAN
- view.setAttribute(Qt::WA_LockLandscapeOrientation, true);
- view.showFullScreen();
-#else
- if (QApplication::arguments().contains(QLatin1String("-maximize")))
- view.showMaximized();
- else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
- view.showFullScreen();
- else
- view.show();
-#endif
-
- return app.exec();
-}
-
-#include "pageflip.moc"
diff --git a/demos/qt3d/pageflip/pageflip.desktop b/demos/qt3d/pageflip/pageflip.desktop
deleted file mode 100644
index 4ee69dad..00000000
--- a/demos/qt3d/pageflip/pageflip.desktop
+++ /dev/null
@@ -1,7 +0,0 @@
-[Desktop Entry]
-Type=Application
-Name=Pageflip
-Icon=/usr/share/icons/hicolor/80x80/apps/qt3d.png
-Exec=/usr/bin/invoker --type=e -s /usr/bin/pageflip -fullscreen
-OnlyShowIn=X-MeeGo;
-X-MeeGo-Logical-Id=qtn_comm_appname_pageflip
diff --git a/demos/qt3d/pageflip/pageflip.pro b/demos/qt3d/pageflip/pageflip.pro
deleted file mode 100644
index cdcfd4f9..00000000
--- a/demos/qt3d/pageflip/pageflip.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-TEMPLATE = app
-TARGET = pageflip
-CONFIG += qt warn_on
-
-CONFIG += qt3d_deploy_pkg
-include(../../../pkg.pri)
-
-SOURCES = pageflip.cpp pageflipmath.cpp
-HEADERS = pageflipmath_p.h
-RESOURCES = pageflip.qrc
-
-OTHER_FILES += \
- pageflip.rc \
- pageflip.desktop
-
-RC_FILE = pageflip.rc
-
diff --git a/demos/qt3d/pageflip/pageflip.qrc b/demos/qt3d/pageflip/pageflip.qrc
deleted file mode 100644
index 1584add5..00000000
--- a/demos/qt3d/pageflip/pageflip.qrc
+++ /dev/null
@@ -1,9 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>qqpage1.png</file>
- <file>qqpage2.png</file>
- <file>qqpage3.png</file>
- <file>qqpage4.png</file>
- <file>gradient.png</file>
-</qresource>
-</RCC>
diff --git a/demos/qt3d/pageflip/pageflip.rc b/demos/qt3d/pageflip/pageflip.rc
deleted file mode 100644
index b40ecdc1..00000000
--- a/demos/qt3d/pageflip/pageflip.rc
+++ /dev/null
@@ -1 +0,0 @@
-IDI_ICON1 ICON DISCARDABLE "qt3d.ico"
diff --git a/demos/qt3d/pageflip/pageflipmath.cpp b/demos/qt3d/pageflip/pageflipmath.cpp
deleted file mode 100644
index afb66dbc..00000000
--- a/demos/qt3d/pageflip/pageflipmath.cpp
+++ /dev/null
@@ -1,592 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation ([email protected])
-**
-** This file is part of the QtQuick3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "pageflipmath_p.h"
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-PageFlipMath::PageFlipMath()
-{
- m_showPageReverse = false;
- m_startCorner = BottomRight;
-
- qMemSet(vertices, 0, sizeof(vertices));
- qMemSet(pageCount, 0, sizeof(pageCount));
-}
-
-PageFlipMath::~PageFlipMath()
-{
-}
-
-void PageFlipMath::drawPage(int page) const
-{
- if (page < 0 || page >= 4 || pageCount[page] == 0)
- return;
- glDrawArrays(GL_TRIANGLE_FAN, page * 5, pageCount[page]);
-}
-
-void PageFlipMath::drawOutline(int page) const
-{
- if (page < 0 || page >= 4 || pageCount[page] == 0)
- return;
- glDrawArrays(GL_LINE_LOOP, page * 5, pageCount[page]);
-}
-
-void PageFlipMath::compute(qreal t)
-{
- int page, vertex;
-
- // Compute the relative vertices for position t.
- if (m_startCorner < VerticalBottomRight)
- flip(m_pageRect.width() - 1, m_pageRect.height() - 1, t);
- else
- flip(m_pageRect.height() - 1, m_pageRect.width() - 1, t);
-
- // Deal with starting corner issues by swapping co-ordinates.
- switch (m_startCorner) {
-
- case BottomRight: break;
-
- case TopRight:
- for (page = 0; page < 4; ++page) {
- for (vertex = 0; vertex < pageCount[page]; ++vertex) {
- vertices[page][vertex][1]
- = m_pageRect.height() - 1 - vertices[page][vertex][1];
- vertices[page][vertex][3]
- = 1.0f - vertices[page][vertex][3];
- }
- }
- break;
-
- case BottomLeft:
- for (page = 0; page < 4; ++page) {
- for (vertex = 0; vertex < pageCount[page]; ++vertex) {
- vertices[page][vertex][0]
- = m_pageRect.width() - 1 - vertices[page][vertex][0];
- vertices[page][vertex][0] -= m_pageRect.width();
- vertices[page][vertex][2]
- = 1.0f - vertices[page][vertex][2];
- }
- }
- break;
-
- case TopLeft:
- for (page = 0; page < 4; ++page) {
- for (vertex = 0; vertex < pageCount[page]; ++vertex) {
- vertices[page][vertex][0]
- = m_pageRect.width() - 1 - vertices[page][vertex][0];
- vertices[page][vertex][0] -= m_pageRect.width();
- vertices[page][vertex][1]
- = m_pageRect.height() - 1 - vertices[page][vertex][1];
- vertices[page][vertex][2]
- = 1.0f - vertices[page][vertex][2];
- vertices[page][vertex][3]
- = 1.0f - vertices[page][vertex][3];
- }
- }
- break;
-
- case BottomLeftOnePage:
- for (page = 1; page < 4; ++page) {
- for (vertex = 0; vertex < pageCount[page]; ++vertex) {
- vertices[page][vertex][0]
- = m_pageRect.width() - 1 - vertices[page][vertex][0];
- vertices[page][vertex][2]
- = 1.0f - vertices[page][vertex][2];
- }
- }
- break;
-
- case TopLeftOnePage:
- for (page = 1; page < 4; ++page) {
- for (vertex = 0; vertex < pageCount[page]; ++vertex) {
- vertices[page][vertex][0]
- = m_pageRect.width() - 1 - vertices[page][vertex][0];
- vertices[page][vertex][1]
- = m_pageRect.height() - 1 - vertices[page][vertex][1];
- vertices[page][vertex][2]
- = 1.0f - vertices[page][vertex][2];
- vertices[page][vertex][3]
- = 1.0f - vertices[page][vertex][3];
- }
- }
- break;
-
- case VerticalBottomRight:
- for (page = 0; page < 4; ++page) {
- for (vertex = 0; vertex < pageCount[page]; ++vertex) {
- qSwap(vertices[page][vertex][0], vertices[page][vertex][1]);
- vertices[page][vertex][0]
- = m_pageRect.width() - 1 - vertices[page][vertex][0];
- vertices[page][vertex][1]
- = m_pageRect.height() - 1 - vertices[page][vertex][1];
- qSwap(vertices[page][vertex][2], vertices[page][vertex][3]);
- vertices[page][vertex][2]
- = 1.0f - vertices[page][vertex][2];
- vertices[page][vertex][3]
- = 1.0f - vertices[page][vertex][3];
- }
- }
- break;
-
- case VerticalTopRight:
- for (page = 0; page < 4; ++page) {
- for (vertex = 0; vertex < pageCount[page]; ++vertex) {
- qSwap(vertices[page][vertex][0], vertices[page][vertex][1]);
- vertices[page][vertex][0]
- = m_pageRect.width() - 1 - vertices[page][vertex][0];
- qSwap(vertices[page][vertex][2], vertices[page][vertex][3]);
- vertices[page][vertex][2]
- = 1.0f - vertices[page][vertex][2];
- }
- }
- break;
-
- case VerticalBottomLeft:
- for (page = 0; page < 4; ++page) {
- for (vertex = 0; vertex < pageCount[page]; ++vertex) {
- qSwap(vertices[page][vertex][0], vertices[page][vertex][1]);
- vertices[page][vertex][1]
- = m_pageRect.height() - 1 - vertices[page][vertex][1];
- qSwap(vertices[page][vertex][2], vertices[page][vertex][3]);
- vertices[page][vertex][3]
- = 1.0f - vertices[page][vertex][3];
- }
- }
- break;
-
- case VerticalTopLeft:
- for (page = 0; page < 4; ++page) {
- for (vertex = 0; vertex < pageCount[page]; ++vertex) {
- qSwap(vertices[page][vertex][0], vertices[page][vertex][1]);
- qSwap(vertices[page][vertex][2], vertices[page][vertex][3]);
- }
- }
- break;
- }
-
- // Adjust the vertices for the final rectangle position.
- for (page = 0; page < 4; ++page) {
- for (vertex = 0; vertex < pageCount[page]; ++vertex) {
- vertices[page][vertex][0] += m_pageRect.x();
- vertices[page][vertex][1]
- = m_pageRect.y() +
- (m_pageRect.height() - 1 - vertices[page][vertex][1]);
- }
- }
-
- // Flip the x texture co-ordinates for page 2 if showing the page reverse.
- if (m_showPageReverse) {
- if (m_startCorner < VerticalBottomRight) {
- for (int vertex = 0; vertex < pageCount[2]; ++vertex)
- vertices[2][vertex][2] = 1.0f - vertices[2][vertex][2];
- } else {
- for (int vertex = 0; vertex < pageCount[2]; ++vertex)
- vertices[2][vertex][3] = 1.0f - vertices[2][vertex][3];
- }
- }
-}
-
-// Page 1 is the reference page and extends from the bottom-left
-// corner at (0, 0) to the top-right corner at (pageWidth, pageHeight).
-// The flip starts at the bottom-right corner and proceeds leftwards
-// across the page. All other flip directions and starting corners
-// can be derived from this basic reference flip animation.
-void PageFlipMath::flip(qreal pageWidth, qreal pageHeight, qreal t)
-{
- // Handle the simple start and end position cases first.
- if (t <= 0.0f) {
- // Starting position: pages 0 and 1 in their rest states
- // and pages 2 and 3 not visible.
- pageCount[0] = 4;
- pageCount[1] = 4;
- pageCount[2] = 0;
- pageCount[3] = 0;
-
- vertices[0][0][0] = -pageWidth; // corner 0 at (-pageWidth, 0)
- vertices[0][0][1] = 0.0f;
- vertices[0][0][2] = 0.0f; // texture co-ordinate
- vertices[0][0][3] = 0.0f;
- vertices[0][0][4] = 0.0f; // gradient control
-
- vertices[0][1][0] = 0.0f; // corner 1 at (0, 0)
- vertices[0][1][1] = 0.0f;
- vertices[0][1][2] = 1.0f;
- vertices[0][1][3] = 0.0f;
- vertices[0][1][4] = 1.0f; // gradient along fold on the right
-
- vertices[0][2][0] = 0.0f; // corner 2 at (0, pageHeight)
- vertices[0][2][1] = pageHeight;
- vertices[0][2][2] = 1.0f;
- vertices[0][2][3] = 1.0f;
- vertices[0][2][4] = 1.0f;
-
- vertices[0][3][0] = -pageWidth; // corner 3 at (-pageWidth, pageHeight)
- vertices[0][3][1] = pageHeight;
- vertices[0][3][2] = 0.0f;
- vertices[0][3][3] = 1.0f;
- vertices[0][3][4] = 0.0f;
-
- vertices[1][0][0] = 0.0f; // corner 0 at (0, 0)
- vertices[1][0][1] = 0.0f;
- vertices[1][0][2] = 0.0f; // texture co-ordinate
- vertices[1][0][3] = 0.0f;
- vertices[1][0][4] = 1.0f; // gradient along fold on the left
-
- vertices[1][1][0] = pageWidth; // corner 1 at (pageWidth, 0)
- vertices[1][1][1] = 0.0f;
- vertices[1][1][2] = 1.0f;
- vertices[1][1][3] = 0.0f;
- vertices[1][1][4] = 0.0f;
-
- vertices[1][2][0] = pageWidth; // corner 2 at (pageWidth, pageHeight)
- vertices[1][2][1] = pageHeight;
- vertices[1][2][2] = 1.0f;
- vertices[1][2][3] = 1.0f;
- vertices[1][2][4] = 0.0f;
-
- vertices[1][3][0] = 0.0f; // corner 3 at (0, pageHeight)
- vertices[1][3][1] = pageHeight;
- vertices[1][3][2] = 0.0f;
- vertices[1][3][3] = 1.0f;
- vertices[1][3][4] = 1.0f;
- return;
- } else if (t >= 1.0f) {
- // Ending position: pages 0 and 1 are not visible, but
- // pages 2 and 3 are visible in the rest states.
- pageCount[0] = 0;
- pageCount[1] = 0;
- pageCount[2] = 4;
- pageCount[3] = 4;
-
- vertices[2][0][0] = -pageWidth; // corner 0 at (-pageWidth, 0)
- vertices[2][0][1] = 0.0f;
- vertices[2][0][2] = 0.0f; // texture co-ordinate
- vertices[2][0][3] = 0.0f;
- vertices[2][0][4] = 0.0f; // gradient control
-
- vertices[2][1][0] = 0.0f; // corner 1 at (0, 0)
- vertices[2][1][1] = 0.0f;
- vertices[2][1][2] = 1.0f;
- vertices[2][1][3] = 0.0f;
- vertices[2][1][4] = 1.0f; // gradient along fold on the right
-
- vertices[2][2][0] = 0.0f; // corner 2 at (0, pageHeight)
- vertices[2][2][1] = pageHeight;
- vertices[2][2][2] = 1.0f;
- vertices[2][2][3] = 1.0f;
- vertices[2][2][4] = 1.0f;
-
- vertices[2][3][0] = -pageWidth; // corner 3 at (-pageWidth, pageHeight)
- vertices[2][3][1] = pageHeight;
- vertices[2][3][2] = 0.0f;
- vertices[2][3][3] = 1.0f;
- vertices[2][3][4] = 0.0f;
-
- vertices[3][0][0] = 0.0f; // corner 0 at (0, 0)
- vertices[3][0][1] = 0.0f;
- vertices[3][0][2] = 0.0f; // texture co-ordinate
- vertices[3][0][3] = 0.0f;
- vertices[3][0][4] = 1.0f; // gradient along fold on the left
-
- vertices[3][1][0] = pageWidth; // corner 1 at (pageWidth, 0)
- vertices[3][1][1] = 0.0f;
- vertices[3][1][2] = 1.0f;
- vertices[3][1][3] = 0.0f;
- vertices[3][1][4] = 0.0f;
-
- vertices[3][2][0] = pageWidth; // corner 2 at (pageWidth, pageHeight)
- vertices[3][2][1] = pageHeight;
- vertices[3][2][2] = 1.0f;
- vertices[3][2][3] = 1.0f;
- vertices[3][2][4] = 0.0f;
-
- vertices[3][3][0] = 0.0f; // corner 3 at (0, pageHeight)
- vertices[3][3][1] = pageHeight;
- vertices[3][3][2] = 0.0f;
- vertices[3][3][3] = 1.0f;
- vertices[3][3][4] = 1.0f;
- return;
- }
-
- // Page 0 is the same for all other animation positions.
- pageCount[0] = 4;
-
- vertices[0][0][0] = -pageWidth; // corner 0 at (-pageWidth, 0)
- vertices[0][0][1] = 0.0f;
- vertices[0][0][2] = 0.0f; // texture co-ordinate
- vertices[0][0][3] = 0.0f;
- vertices[0][0][4] = 0.0f; // gradient control
-
- vertices[0][1][0] = 0.0f; // corner 1 at (0, 0)
- vertices[0][1][1] = 0.0f;
- vertices[0][1][2] = 1.0f;
- vertices[0][1][3] = 0.0f;
- vertices[0][1][4] = 1.0f; // gradient along fold on the right
-
- vertices[0][2][0] = 0.0f; // corner 2 at (0, pageHeight)
- vertices[0][2][1] = pageHeight;
- vertices[0][2][2] = 1.0f;
- vertices[0][2][3] = 1.0f;
- vertices[0][2][4] = 1.0f;
-
- vertices[0][3][0] = -pageWidth; // corner 3 at (-pageWidth, pageHeight)
- vertices[0][3][1] = pageHeight;
- vertices[0][3][2] = 0.0f;
- vertices[0][3][3] = 1.0f;
- vertices[0][3][4] = 0.0f;
-
- // Get the angle of the "curling" dividing line to the bottom of the page.
- // Basically: 45deg + (45deg * t) = 45deg * (1 + t), where t is between
- // 0 and 1 but is neither 0 nor 1.
- qreal angle = (M_PI / 4.0f) * (1.0f + t);
-
- // We need the cos and sin of both the angle and angle * 2.
- qreal cosAngle = qCos(angle);
- qreal sinAngle = qSin(angle);
- qreal cosAngle2 = qCos(angle * 2.0f);
- qreal sinAngle2 = qSin(angle * 2.0f);
-
- // Find the reference point. This is the point along the bottom of
- // the page where the dividing line intersects the page bottom.
- qreal refx = pageWidth * (1.0f - t);
- qreal refy = 0.0f;
-
- // Distance from the reference point to the right side of the page.
- qreal d = pageWidth - refx;
-
- // Determine the intersection of the dividing line with the
- // top of the page. If the intersection is not on the page (k >= d),
- // then we need to generate similar triangles. If the intersection is
- // on the page (k < d), then we need to generate similar trapezoids.
- qreal k = (pageHeight * cosAngle) / sinAngle;
- if (k >= d) {
- // Generate similar triangles. Find the intersection with
- // the right-hand side of the page at x == pageWidth.
- qreal intx = pageWidth;
- qreal inty = refy + (d * sinAngle) / cosAngle;
-
- // Find the opposite triangle corner on the back page.
- qreal oppx = refx + d * cosAngle2;
- qreal oppy = refy + d * sinAngle2;
-
- // Generate vertices and texture co-ordinates for the back page.
- qreal texa = 1.0f - (d * sinAngle) / (pageHeight * cosAngle);
- qreal texb = d / pageWidth;
- vertices[2][0][0] = intx;
- vertices[2][0][1] = inty;
- vertices[2][0][2] = 0.0f;
- vertices[2][0][3] = 1.0f - texa;
- vertices[2][0][4] = 1.0f;
-
- vertices[2][1][0] = oppx;
- vertices[2][1][1] = oppy;
- vertices[2][1][2] = 0.0f;
- vertices[2][1][3] = 0.0f;
- vertices[2][1][4] = 1.0f - texb;
-
- vertices[2][2][0] = refx;
- vertices[2][2][1] = refy;
- vertices[2][2][2] = texb;
- vertices[2][2][3] = 0.0f;
- vertices[2][2][4] = 1.0f;
-
- pageCount[2] = 3;
-
- // Generate vertices and texture co-ordinates for the next page.
- vertices[3][0][0] = intx;
- vertices[3][0][1] = inty;
- vertices[3][0][2] = 1.0f;
- vertices[3][0][3] = 1.0f - texa;
- vertices[3][0][4] = 1.0f;
-
- vertices[3][1][0] = refx;
- vertices[3][1][1] = refy;
- vertices[3][1][2] = 1.0f - texb;
- vertices[3][1][3] = 0.0f;
- vertices[3][1][4] = 1.0f;
-
- vertices[3][2][0] = pageWidth;
- vertices[3][2][1] = 0.0f;
- vertices[3][2][2] = 1.0f;
- vertices[3][2][3] = 0.0f;
- vertices[3][2][4] = 1.0f - texb;
-
- pageCount[3] = 3;
-
- // Set page 1's vertices to clip off pixels we don't need to draw.
- vertices[1][0][0] = 0.0f;
- vertices[1][0][1] = 0.0f;
- vertices[1][0][2] = 0.0f;
- vertices[1][0][3] = 0.0f;
- vertices[1][0][4] = 1.0f;
-
- vertices[1][1][0] = pageWidth - d;
- vertices[1][1][1] = 0.0f;
- vertices[1][1][2] = 1.0f - texb;
- vertices[1][1][3] = 0.0f;
- vertices[1][1][4] = texb;
-
- vertices[1][2][0] = intx;
- vertices[1][2][1] = inty;
- vertices[1][2][2] = 1.0f;
- vertices[1][2][3] = 1.0f - texa;
- vertices[1][2][4] = 0.0f;
-
- vertices[1][3][0] = pageWidth;
- vertices[1][3][1] = pageHeight;
- vertices[1][3][2] = 1.0f;
- vertices[1][3][3] = 1.0f;
- vertices[1][3][4] = 0.0f;
-
- vertices[1][4][0] = 0.0f;
- vertices[1][4][1] = pageHeight;
- vertices[1][4][2] = 0.0f;
- vertices[1][4][3] = 1.0f;
- vertices[1][4][4] = 1.0f;
-
- pageCount[1] = 5;
- } else {
- // Generate similar trapezoids. Find the intersection with
- // the top of the page at y == pageHeight.
- qreal intx = refx + (pageHeight * cosAngle) / sinAngle;
- qreal inty = pageHeight;
-
- // Get the distance between the intersection and the right of the page.
- qreal e = pageWidth - intx;
-
- // Find the opposite trapezoid corners to "ref" and "int".
- qreal opprefx = refx + d * cosAngle2;
- qreal opprefy = refy + d * sinAngle2;
- qreal oppintx = intx + e * cosAngle2;
- qreal oppinty = inty + e * sinAngle2;
-
- // Generate vertices and texture co-ordinates for the back page.
- qreal texa = e / pageWidth;
- qreal texb = d / pageWidth;
- vertices[2][0][0] = intx;
- vertices[2][0][1] = inty;
- vertices[2][0][2] = texa;
- vertices[2][0][3] = 1.0f;
- vertices[2][0][4] = 1.0f;
-
- vertices[2][1][0] = oppintx;
- vertices[2][1][1] = oppinty;
- vertices[2][1][2] = 0.0f;
- vertices[2][1][3] = 1.0f;
- vertices[2][1][4] = 1.0f - texa;
-
- vertices[2][2][0] = opprefx;
- vertices[2][2][1] = opprefy;
- vertices[2][2][2] = 0.0f;
- vertices[2][2][3] = 0.0f;
- vertices[2][2][4] = 1.0f - texb;
-
- vertices[2][3][0] = refx;
- vertices[2][3][1] = refy;
- vertices[2][3][2] = texb;
- vertices[2][3][3] = 0.0f;
- vertices[2][3][4] = 1.0f;
-
- pageCount[2] = 4;
-
- // Generate vertices and texture co-ordinates for the next page.
- vertices[3][0][0] = intx;
- vertices[3][0][1] = inty;
- vertices[3][0][2] = 1.0f - texa;
- vertices[3][0][3] = 1.0f;
- vertices[3][0][4] = 1.0f;
-
- vertices[3][1][0] = refx;
- vertices[3][1][1] = refy;
- vertices[3][1][2] = 1.0f - texb;
- vertices[3][1][3] = 0.0f;
- vertices[3][1][4] = 1.0f;
-
- vertices[3][2][0] = pageWidth;
- vertices[3][2][1] = 0.0f;
- vertices[3][2][2] = 1.0f;
- vertices[3][2][3] = 0.0f;
- vertices[3][2][4] = 1.0f - texb;
-
- vertices[3][3][0] = pageWidth;
- vertices[3][3][1] = pageHeight;
- vertices[3][3][2] = 1.0f;
- vertices[3][3][3] = 1.0f;
- vertices[3][3][4] = 1.0f - texa;
-
- pageCount[3] = 4;
-
- // Set page 1's vertices to clip off pixels we don't need to draw.
- vertices[1][0][0] = 0.0f;
- vertices[1][0][1] = 0.0f;
- vertices[1][0][2] = 0.0f;
- vertices[1][0][3] = 0.0f;
- vertices[1][0][4] = 1.0f;
-
- vertices[1][1][0] = pageWidth - d;
- vertices[1][1][1] = 0.0f;
- vertices[1][1][2] = 1.0f - texb;
- vertices[1][1][3] = 0.0f;
- vertices[1][1][4] = texb;
-
- vertices[1][2][0] = pageWidth - e;
- vertices[1][2][1] = pageHeight;
- vertices[1][2][2] = 1.0f - texa;
- vertices[1][2][3] = 1.0f;
- vertices[1][2][4] = texa;
-
- vertices[1][3][0] = 0.0f;
- vertices[1][3][1] = pageHeight;
- vertices[1][3][2] = 0.0f;
- vertices[1][3][3] = 1.0f;
- vertices[1][3][4] = 1.0f;
-
- pageCount[1] = 4;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/demos/qt3d/pageflip/pageflipmath_p.h b/demos/qt3d/pageflip/pageflipmath_p.h
deleted file mode 100644
index 21280b05..00000000
--- a/demos/qt3d/pageflip/pageflipmath_p.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation ([email protected])
-**
-** This file is part of the QtQuick3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PAGEFLIPMATH_P_H
-#define PAGEFLIPMATH_P_H
-
-#include <QtOpenGL/qgl.h>
-
-QT_BEGIN_NAMESPACE
-
-class PageFlipMath
-{
-public:
- PageFlipMath();
- ~PageFlipMath();
-
- enum StartCorner
- {
- BottomRight,
- TopRight,
- BottomLeft,
- TopLeft,
- BottomLeftOnePage,
- TopLeftOnePage,
- VerticalBottomRight,
- VerticalTopRight,
- VerticalBottomLeft,
- VerticalTopLeft
- };
-
- // Corner to start flipping from.
- StartCorner startCorner() const { return m_startCorner; }
- void setStartCorner(StartCorner value) { m_startCorner = value; }
-
- // Rectangle to display the main page (usually the one on the right).
- QRect pageRect() const { return m_pageRect; }
- void setPageRect(const QRect& rect) { m_pageRect = rect; }
-
- // Show the reverse of the right-hand page on the back when
- // flipping pages. That is, the user will essentially see
- // the texture on the front of the page "through" it in reverse
- // while it is being flipped.
- bool showPageReverse() const { return m_showPageReverse; }
- void setShowPageReverse(bool value) { m_showPageReverse = value; }
-
- // Get the vertex array pointer.
- const GLfloat *vertexArray() const { return vertices[0][0]; }
-
- // Get the vertex array stride in bytes.
- int stride() const { return 5 * sizeof(GLfloat); }
-
- // Draw a specific page.
- void drawPage(int page) const;
-
- // Draw the outline of a page as a set of lines.
- void drawOutline(int page) const;
-
- // Compute the frame at position t (0...1) in the animation.
- void compute(qreal t);
-
-private:
- StartCorner m_startCorner;
- QRect m_pageRect;
- bool m_showPageReverse;
-
- // Vertex array: up to 4 pages, with up to 5 vertices per page,
- // and 5 components (2D position, 2D texcoord, 1D gradient control)
- // per vertex. The gradient control value is interpolated between
- // 0 and 1 - it is 1 at the fold point and 0 on the side of the page
- // opposite the fold point. Shaders can use this to extract a color
- // value from a gradient texture to blend with the page texture.
- GLfloat vertices[4][5][5];
-
- // Number of vertices for drawing the triangle fan for each page.
- int pageCount[4];
-
- void flip(qreal pageWidth, qreal pageHeight, qreal t);
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/demos/qt3d/pageflip/qqpage1.png b/demos/qt3d/pageflip/qqpage1.png
deleted file mode 100644
index 8abf37d9..00000000
--- a/demos/qt3d/pageflip/qqpage1.png
+++ /dev/null
Binary files differ
diff --git a/demos/qt3d/pageflip/qqpage2.png b/demos/qt3d/pageflip/qqpage2.png
deleted file mode 100644
index afd1b047..00000000
--- a/demos/qt3d/pageflip/qqpage2.png
+++ /dev/null
Binary files differ
diff --git a/demos/qt3d/pageflip/qqpage3.png b/demos/qt3d/pageflip/qqpage3.png
deleted file mode 100644
index fa2a85a0..00000000
--- a/demos/qt3d/pageflip/qqpage3.png
+++ /dev/null
Binary files differ
diff --git a/demos/qt3d/pageflip/qqpage4.png b/demos/qt3d/pageflip/qqpage4.png
deleted file mode 100644
index 0a6ba7b0..00000000
--- a/demos/qt3d/pageflip/qqpage4.png
+++ /dev/null
Binary files differ
diff --git a/demos/qt3d/pageflip/qt3d.ico b/demos/qt3d/pageflip/qt3d.ico
deleted file mode 100644
index e6442baf..00000000
--- a/demos/qt3d/pageflip/qt3d.ico
+++ /dev/null
Binary files differ
diff --git a/demos/qt3d/pageflip/qt3d.png b/demos/qt3d/pageflip/qt3d.png
deleted file mode 100644
index 21ec0176..00000000
--- a/demos/qt3d/pageflip/qt3d.png
+++ /dev/null
Binary files differ