summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarah Smith <sarah.j.smith@nokia.com>2009-10-09 12:00:25 +1000
committerSarah Smith <sarah.j.smith@nokia.com>2009-10-09 12:00:25 +1000
commit3d91051ce5ff92501b33580f1726f6726795c42d (patch)
treeceb60ad4e2f0b26fa6ef4412552118ad96705dc8
parentef8d9fa7091b0d45fe15aae43b8f1c47547cb16d (diff)
hellogl now runs on QT_OPENGL_ES_1 (ie N95).
effort to have examples show portable GL code continues. One #ifdef in whole example and it now runs on N95 and desktop. Reviewed-by: Rhys Weatherley
-rw-r--r--examples/opengl/hellogl/glwidget.cpp12
-rw-r--r--examples/opengl/hellogl/main.cpp10
-rw-r--r--examples/opengl/hellogl/window.cpp8
-rw-r--r--examples/opengl/hellogl/window.h3
-rw-r--r--examples/opengl/opengl.pro3
-rw-r--r--examples/opengl/shared/qtlogo.cpp6
-rw-r--r--examples/opengl/shared/qtlogo.h2
7 files changed, 38 insertions, 6 deletions
diff --git a/examples/opengl/hellogl/glwidget.cpp b/examples/opengl/hellogl/glwidget.cpp
index 282f21f8cf..ffb3b15750 100644
--- a/examples/opengl/hellogl/glwidget.cpp
+++ b/examples/opengl/hellogl/glwidget.cpp
@@ -150,10 +150,10 @@ void GLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
- glTranslated(0.0, 0.0, -10.0);
- glRotated(xRot / 16.0, 1.0, 0.0, 0.0);
- glRotated(yRot / 16.0, 0.0, 1.0, 0.0);
- glRotated(zRot / 16.0, 0.0, 0.0, 1.0);
+ glTranslatef(0.0, 0.0, -10.0);
+ glRotatef(xRot / 16.0, 1.0, 0.0, 0.0);
+ glRotatef(yRot / 16.0, 0.0, 1.0, 0.0);
+ glRotatef(zRot / 16.0, 0.0, 0.0, 1.0);
logo->draw();
}
//! [7]
@@ -166,7 +166,11 @@ void GLWidget::resizeGL(int width, int height)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
+#ifdef QT_OPENGL_ES_1
+ glOrthof(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0);
+#else
glOrtho(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0);
+#endif
glMatrixMode(GL_MODELVIEW);
}
//! [8]
diff --git a/examples/opengl/hellogl/main.cpp b/examples/opengl/hellogl/main.cpp
index e645dbaef6..f610b3b179 100644
--- a/examples/opengl/hellogl/main.cpp
+++ b/examples/opengl/hellogl/main.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include <QApplication>
+#include <QDesktopWidget>
#include "window.h"
@@ -47,6 +48,13 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Window window;
- window.show();
+ window.resize(window.sizeHint());
+ int desktopArea = QApplication::desktop()->width() *
+ QApplication::desktop()->height();
+ int widgetArea = window.width() * window.height();
+ if (((float)widgetArea / (float)desktopArea) < 0.75f)
+ window.show();
+ else
+ window.showMaximized();
return app.exec();
}
diff --git a/examples/opengl/hellogl/window.cpp b/examples/opengl/hellogl/window.cpp
index 2b06b9c50a..19a8aacc99 100644
--- a/examples/opengl/hellogl/window.cpp
+++ b/examples/opengl/hellogl/window.cpp
@@ -88,3 +88,11 @@ QSlider *Window::createSlider()
return slider;
}
//! [2]
+
+void Window::keyPressEvent(QKeyEvent *e)
+{
+ if (e->key() == Qt::Key_Escape)
+ close();
+ else
+ QWidget::keyPressEvent(e);
+}
diff --git a/examples/opengl/hellogl/window.h b/examples/opengl/hellogl/window.h
index 7269a05e0e..4cfd31b8b5 100644
--- a/examples/opengl/hellogl/window.h
+++ b/examples/opengl/hellogl/window.h
@@ -57,6 +57,9 @@ class Window : public QWidget
public:
Window();
+protected:
+ void keyPressEvent(QKeyEvent *event);
+
private:
QSlider *createSlider();
diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro
index 2cb8227068..eaac9b8924 100644
--- a/examples/opengl/opengl.pro
+++ b/examples/opengl/opengl.pro
@@ -9,6 +9,9 @@ contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles1cl)|contains(QT_CONF
!contains(QT_CONFIG, opengles1cl) {
SUBDIRS += textures
}
+ contains(QT_CONFIG, opengles1) {
+ SUBDIRS += hellogl
+ }
} else {
SUBDIRS = 2dpainting \
grabber \
diff --git a/examples/opengl/shared/qtlogo.cpp b/examples/opengl/shared/qtlogo.cpp
index b32b416a92..bad83d10d4 100644
--- a/examples/opengl/shared/qtlogo.cpp
+++ b/examples/opengl/shared/qtlogo.cpp
@@ -39,6 +39,12 @@
**
****************************************************************************/
+#include <QGLWidget>
+#include <QMatrix4x4>
+#include <QVector3D>
+
+#include <qmath.h>
+
#include "qtlogo.h"
static const qreal tee_height = 0.311126;
diff --git a/examples/opengl/shared/qtlogo.h b/examples/opengl/shared/qtlogo.h
index 4f5c35776f..152958b0fe 100644
--- a/examples/opengl/shared/qtlogo.h
+++ b/examples/opengl/shared/qtlogo.h
@@ -43,7 +43,7 @@
#define QTLOGO_H
#include <QObject>
-#include <QtOpenGL>
+#include <QColor>
class Patch;
struct Geometry;