| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information ([email protected])
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the examples of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #include "mainwindow.h"
|
|---|
| 43 |
|
|---|
| 44 | #include <QApplication>
|
|---|
| 45 | #include <QMenuBar>
|
|---|
| 46 | #include <QGroupBox>
|
|---|
| 47 | #include <QGridLayout>
|
|---|
| 48 | #include <QSlider>
|
|---|
| 49 | #include <QLabel>
|
|---|
| 50 | #include <QTimer>
|
|---|
| 51 |
|
|---|
| 52 | #include "glwidget.h"
|
|---|
| 53 |
|
|---|
| 54 | MainWindow::MainWindow()
|
|---|
| 55 | {
|
|---|
| 56 | GLWidget *glwidget = new GLWidget();
|
|---|
| 57 | QLabel *label = new QLabel(this);
|
|---|
| 58 | QTimer *timer = new QTimer(this);
|
|---|
| 59 | QSlider *slider = new QSlider(this);
|
|---|
| 60 | slider->setOrientation(Qt::Horizontal);
|
|---|
| 61 |
|
|---|
| 62 | slider->setRange(0, 100);
|
|---|
| 63 | slider->setSliderPosition(50);
|
|---|
| 64 | timer->setInterval(10);
|
|---|
| 65 | label->setText("A QGlWidget with OpenGl ES");
|
|---|
| 66 | label->setAlignment(Qt::AlignHCenter);
|
|---|
| 67 |
|
|---|
| 68 | QGroupBox * groupBox = new QGroupBox(this);
|
|---|
| 69 | setCentralWidget(groupBox);
|
|---|
| 70 | groupBox->setTitle("OpenGL ES Example");
|
|---|
| 71 |
|
|---|
| 72 | QGridLayout *layout = new QGridLayout(groupBox);
|
|---|
| 73 |
|
|---|
| 74 | layout->addWidget(glwidget,1,0,8,1);
|
|---|
| 75 | layout->addWidget(label,9,0,1,1);
|
|---|
| 76 | layout->addWidget(slider, 11,0,1,1);
|
|---|
| 77 |
|
|---|
| 78 | groupBox->setLayout(layout);
|
|---|
| 79 |
|
|---|
| 80 | QMenu *fileMenu = new QMenu("File");
|
|---|
| 81 | QMenu *helpMenu = new QMenu("Help");
|
|---|
| 82 | QMenu *showMenu = new QMenu("Show");
|
|---|
| 83 | menuBar()->addMenu(fileMenu);
|
|---|
| 84 | menuBar()->addMenu(showMenu);
|
|---|
| 85 | menuBar()->addMenu(helpMenu);
|
|---|
| 86 | QAction *exit = new QAction("Exit", fileMenu);
|
|---|
| 87 | QAction *aboutQt = new QAction("AboutQt", helpMenu);
|
|---|
| 88 | QAction *showLogo = new QAction("Show 3D Logo", showMenu);
|
|---|
| 89 | QAction *showTexture = new QAction("Show 2D Texture", showMenu);
|
|---|
| 90 | QAction *showBubbles = new QAction("Show bubbles", showMenu);
|
|---|
| 91 | showBubbles->setCheckable(true);
|
|---|
| 92 | showBubbles->setChecked(true);
|
|---|
| 93 | fileMenu->addAction(exit);
|
|---|
| 94 | helpMenu->addAction(aboutQt);
|
|---|
| 95 | showMenu->addAction(showLogo);
|
|---|
| 96 | showMenu->addAction(showTexture);
|
|---|
| 97 | showMenu->addAction(showBubbles);
|
|---|
| 98 |
|
|---|
| 99 | QObject::connect(timer, SIGNAL(timeout()), glwidget, SLOT(updateGL()));
|
|---|
| 100 | QObject::connect(exit, SIGNAL(triggered(bool)), this, SLOT(close()));
|
|---|
| 101 | QObject::connect(aboutQt, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt()));
|
|---|
| 102 |
|
|---|
| 103 | QObject::connect(showLogo, SIGNAL(triggered(bool)), glwidget, SLOT(setLogo()));
|
|---|
| 104 | QObject::connect(showTexture, SIGNAL(triggered(bool)), glwidget, SLOT(setTexture()));
|
|---|
| 105 | QObject::connect(showBubbles, SIGNAL(triggered(bool)), glwidget, SLOT(showBubbles(bool)));
|
|---|
| 106 | QObject::connect(slider, SIGNAL(valueChanged(int)), glwidget, SLOT(setScaling(int)));
|
|---|
| 107 | timer->start();
|
|---|
| 108 | }
|
|---|