diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-02-19 10:06:25 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-02-19 10:06:25 +0100 |
commit | 30fd22b9574def54726e7b193127cc0c901c1b4c (patch) | |
tree | 96dfc923044db0515064ba39d052d9ed577e3e40 /examples/opengl | |
parent | d7b0581c1c2ef60c08d238dae39298af6904918f (diff) | |
parent | 6aa09bbce59828d028f6d1e81d2bfc6ba537aae1 (diff) |
Merge remote-tracking branch 'origin/dev' into stable
Change-Id: Ice524edcc51373509f0023ae7f7c2963f4602f88
Diffstat (limited to 'examples/opengl')
-rw-r--r-- | examples/opengl/cube/geometryengine.cpp | 48 | ||||
-rw-r--r-- | examples/opengl/framebufferobject2/glwidget.cpp | 30 | ||||
-rw-r--r-- | examples/opengl/framebufferobject2/main.cpp | 4 | ||||
-rw-r--r-- | examples/opengl/pbuffers/main.cpp | 4 | ||||
-rw-r--r-- | examples/opengl/pbuffers2/main.cpp | 4 | ||||
-rw-r--r-- | examples/opengl/samplebuffers/main.cpp | 8 | ||||
-rw-r--r-- | examples/opengl/textures/glwidget.cpp | 36 | ||||
-rw-r--r-- | examples/opengl/textures/glwidget.h | 2 |
8 files changed, 50 insertions, 86 deletions
diff --git a/examples/opengl/cube/geometryengine.cpp b/examples/opengl/cube/geometryengine.cpp index bf63934656..0a34213084 100644 --- a/examples/opengl/cube/geometryengine.cpp +++ b/examples/opengl/cube/geometryengine.cpp @@ -79,40 +79,40 @@ void GeometryEngine::initCubeGeometry() // is different. VertexData vertices[] = { // Vertex data for face 0 - {QVector3D(-1.0, -1.0, 1.0), QVector2D(0.0, 0.0)}, // v0 - {QVector3D( 1.0, -1.0, 1.0), QVector2D(0.33, 0.0)}, // v1 - {QVector3D(-1.0, 1.0, 1.0), QVector2D(0.0, 0.5)}, // v2 - {QVector3D( 1.0, 1.0, 1.0), QVector2D(0.33, 0.5)}, // v3 + {QVector3D(-1.0f, -1.0f, 1.0f), QVector2D(0.0f, 0.0f)}, // v0 + {QVector3D( 1.0f, -1.0f, 1.0f), QVector2D(0.33f, 0.0f)}, // v1 + {QVector3D(-1.0f, 1.0f, 1.0f), QVector2D(0.0f, 0.5f)}, // v2 + {QVector3D( 1.0f, 1.0f, 1.0f), QVector2D(0.33f, 0.5f)}, // v3 // Vertex data for face 1 - {QVector3D( 1.0, -1.0, 1.0), QVector2D( 0.0, 0.5)}, // v4 - {QVector3D( 1.0, -1.0, -1.0), QVector2D(0.33, 0.5)}, // v5 - {QVector3D( 1.0, 1.0, 1.0), QVector2D(0.0, 1.0)}, // v6 - {QVector3D( 1.0, 1.0, -1.0), QVector2D(0.33, 1.0)}, // v7 + {QVector3D( 1.0f, -1.0f, 1.0f), QVector2D( 0.0f, 0.5f)}, // v4 + {QVector3D( 1.0f, -1.0f, -1.0f), QVector2D(0.33f, 0.5f)}, // v5 + {QVector3D( 1.0f, 1.0f, 1.0f), QVector2D(0.0f, 1.0f)}, // v6 + {QVector3D( 1.0f, 1.0f, -1.0f), QVector2D(0.33f, 1.0f)}, // v7 // Vertex data for face 2 - {QVector3D( 1.0, -1.0, -1.0), QVector2D(0.66, 0.5)}, // v8 - {QVector3D(-1.0, -1.0, -1.0), QVector2D(1.0, 0.5)}, // v9 - {QVector3D( 1.0, 1.0, -1.0), QVector2D(0.66, 1.0)}, // v10 - {QVector3D(-1.0, 1.0, -1.0), QVector2D(1.0, 1.0)}, // v11 + {QVector3D( 1.0f, -1.0f, -1.0f), QVector2D(0.66f, 0.5f)}, // v8 + {QVector3D(-1.0f, -1.0f, -1.0f), QVector2D(1.0f, 0.5f)}, // v9 + {QVector3D( 1.0f, 1.0f, -1.0f), QVector2D(0.66f, 1.0f)}, // v10 + {QVector3D(-1.0f, 1.0f, -1.0f), QVector2D(1.0f, 1.0f)}, // v11 // Vertex data for face 3 - {QVector3D(-1.0, -1.0, -1.0), QVector2D(0.66, 0.0)}, // v12 - {QVector3D(-1.0, -1.0, 1.0), QVector2D(1.0, 0.0)}, // v13 - {QVector3D(-1.0, 1.0, -1.0), QVector2D(0.66, 0.5)}, // v14 - {QVector3D(-1.0, 1.0, 1.0), QVector2D(1.0, 0.5)}, // v15 + {QVector3D(-1.0f, -1.0f, -1.0f), QVector2D(0.66f, 0.0f)}, // v12 + {QVector3D(-1.0f, -1.0f, 1.0f), QVector2D(1.0f, 0.0f)}, // v13 + {QVector3D(-1.0f, 1.0f, -1.0f), QVector2D(0.66f, 0.5f)}, // v14 + {QVector3D(-1.0f, 1.0f, 1.0f), QVector2D(1.0f, 0.5f)}, // v15 // Vertex data for face 4 - {QVector3D(-1.0, -1.0, -1.0), QVector2D(0.33, 0.0)}, // v16 - {QVector3D( 1.0, -1.0, -1.0), QVector2D(0.66, 0.0)}, // v17 - {QVector3D(-1.0, -1.0, 1.0), QVector2D(0.33, 0.5)}, // v18 - {QVector3D( 1.0, -1.0, 1.0), QVector2D(0.66, 0.5)}, // v19 + {QVector3D(-1.0f, -1.0f, -1.0f), QVector2D(0.33f, 0.0f)}, // v16 + {QVector3D( 1.0f, -1.0f, -1.0f), QVector2D(0.66f, 0.0f)}, // v17 + {QVector3D(-1.0f, -1.0f, 1.0f), QVector2D(0.33f, 0.5f)}, // v18 + {QVector3D( 1.0f, -1.0f, 1.0f), QVector2D(0.66f, 0.5f)}, // v19 // Vertex data for face 5 - {QVector3D(-1.0, 1.0, 1.0), QVector2D(0.33, 0.5)}, // v20 - {QVector3D( 1.0, 1.0, 1.0), QVector2D(0.66, 0.5)}, // v21 - {QVector3D(-1.0, 1.0, -1.0), QVector2D(0.33, 1.0)}, // v22 - {QVector3D( 1.0, 1.0, -1.0), QVector2D(0.66, 1.0)} // v23 + {QVector3D(-1.0f, 1.0f, 1.0f), QVector2D(0.33f, 0.5f)}, // v20 + {QVector3D( 1.0f, 1.0f, 1.0f), QVector2D(0.66f, 0.5f)}, // v21 + {QVector3D(-1.0f, 1.0f, -1.0f), QVector2D(0.33f, 1.0f)}, // v22 + {QVector3D( 1.0f, 1.0f, -1.0f), QVector2D(0.66f, 1.0f)} // v23 }; // Indices for drawing cube faces using triangle strips. diff --git a/examples/opengl/framebufferobject2/glwidget.cpp b/examples/opengl/framebufferobject2/glwidget.cpp index 27dc603f3c..32b9799a4a 100644 --- a/examples/opengl/framebufferobject2/glwidget.cpp +++ b/examples/opengl/framebufferobject2/glwidget.cpp @@ -112,20 +112,20 @@ void GLWidget::initializeGL() { glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - // draw cube background + // draw cube background glPushMatrix(); glLoadIdentity(); glTranslatef(0.5f, 0.5f, -2.0f); - glDisable(GL_TEXTURE_2D); - glEnableClientState(GL_COLOR_ARRAY); - glVertexPointer(2, GL_INT, 0, faceArray); - glDrawArrays(GL_QUADS, 0, 4); - glVertexPointer(3, GL_INT, 0, cubeArray); - glDisableClientState(GL_COLOR_ARRAY); - glEnable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_2D); + glEnableClientState(GL_COLOR_ARRAY); + glVertexPointer(2, GL_INT, 0, faceArray); + glDrawArrays(GL_QUADS, 0, 4); + glVertexPointer(3, GL_INT, 0, cubeArray); + glDisableClientState(GL_COLOR_ARRAY); + glEnable(GL_TEXTURE_2D); glPopMatrix(); - // draw cube + // draw cube glTranslatef(0.5f, 0.5f, 0.5f); glRotatef(3.0f, 1.0f, 1.0f, 1.0f); glTranslatef(-0.5f, -0.5f, -0.5f); @@ -205,12 +205,12 @@ void GLWidget::paintGL() glTranslatef(-1.2f, -0.8f, 0.0f); glScalef(0.2f, 0.2f, 0.2f); for (int y = 0; y < 5; ++y) { - for (int x = 0; x < 5; ++x) { - glTranslatef(2.0f, 0, 0); - glColor4f(0.8f, 0.8f, 0.8f, 1.0f); - glDrawArrays(GL_QUADS, 0, 4); - } - glTranslatef(-10.0f, 2.0f, 0); + for (int x = 0; x < 5; ++x) { + glTranslatef(2.0f, 0, 0); + glColor4f(0.8f, 0.8f, 0.8f, 1.0f); + glDrawArrays(GL_QUADS, 0, 4); + } + glTranslatef(-10.0f, 2.0f, 0); } glVertexPointer(3, GL_INT, 0, cubeArray); diff --git a/examples/opengl/framebufferobject2/main.cpp b/examples/opengl/framebufferobject2/main.cpp index ab7359bef3..4c9aa9840f 100644 --- a/examples/opengl/framebufferobject2/main.cpp +++ b/examples/opengl/framebufferobject2/main.cpp @@ -48,8 +48,8 @@ int main(int argc, char **argv) QApplication a(argc, argv); if (!QGLFormat::hasOpenGL() || !QGLFramebufferObject::hasOpenGLFramebufferObjects()) { - QMessageBox::information(0, "OpenGL framebuffer objects 2", - "This system does not support OpenGL/framebuffer objects."); + QMessageBox::information(0, "OpenGL framebuffer objects 2", + "This system does not support OpenGL/framebuffer objects."); return -1; } diff --git a/examples/opengl/pbuffers/main.cpp b/examples/opengl/pbuffers/main.cpp index e6b1fc5f48..8be6640e92 100644 --- a/examples/opengl/pbuffers/main.cpp +++ b/examples/opengl/pbuffers/main.cpp @@ -54,8 +54,8 @@ int main(int argc, char **argv) widget.makeCurrent(); if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { - QMessageBox::information(0, "OpenGL pbuffers", - "This system does not support OpenGL/pbuffers."); + QMessageBox::information(0, "OpenGL pbuffers", + "This system does not support OpenGL/pbuffers."); return -1; } diff --git a/examples/opengl/pbuffers2/main.cpp b/examples/opengl/pbuffers2/main.cpp index 60d8787c58..79fd88a3c8 100644 --- a/examples/opengl/pbuffers2/main.cpp +++ b/examples/opengl/pbuffers2/main.cpp @@ -51,8 +51,8 @@ int main(int argc, char **argv) widget.resize(640, 480); widget.makeCurrent(); if (!QGLFormat::hasOpenGL() || !QGLPixelBuffer::hasOpenGLPbuffers()) { - QMessageBox::information(0, "OpenGL pbuffers 2", - "This system does not support OpenGL/pbuffers."); + QMessageBox::information(0, "OpenGL pbuffers 2", + "This system does not support OpenGL/pbuffers."); return -1; } widget.show(); diff --git a/examples/opengl/samplebuffers/main.cpp b/examples/opengl/samplebuffers/main.cpp index cb25ffb3ec..a1272af4db 100644 --- a/examples/opengl/samplebuffers/main.cpp +++ b/examples/opengl/samplebuffers/main.cpp @@ -50,16 +50,16 @@ int main(int argc, char **argv) f.setSampleBuffers(true); QGLFormat::setDefaultFormat(f); if (!QGLFormat::hasOpenGL()) { - QMessageBox::information(0, "OpenGL samplebuffers", - "This system does not support OpenGL."); + QMessageBox::information(0, "OpenGL samplebuffers", + "This system does not support OpenGL."); return 0; } GLWidget widget(0); if (!widget.format().sampleBuffers()) { - QMessageBox::information(0, "OpenGL samplebuffers", - "This system does not have sample buffer support."); + QMessageBox::information(0, "OpenGL samplebuffers", + "This system does not have sample buffer support."); return 0; } diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp index 6cb0c2d6ec..ac1e7965af 100644 --- a/examples/opengl/textures/glwidget.cpp +++ b/examples/opengl/textures/glwidget.cpp @@ -50,9 +50,7 @@ GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) xRot = 0; yRot = 0; zRot = 0; -#ifdef QT_OPENGL_ES_2 program = 0; -#endif } GLWidget::~GLWidget() @@ -89,12 +87,10 @@ void GLWidget::initializeGL() glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); -#ifndef QT_OPENGL_ES_2 +#ifdef GL_TEXTURE_2D glEnable(GL_TEXTURE_2D); #endif -#ifdef QT_OPENGL_ES_2 - #define PROGRAM_VERTEX_ATTRIBUTE 0 #define PROGRAM_TEXCOORD_ATTRIBUTE 1 @@ -130,8 +126,6 @@ void GLWidget::initializeGL() program->bind(); program->setUniformValue("texture", 0); - -#endif } void GLWidget::paintGL() @@ -139,21 +133,6 @@ void GLWidget::paintGL() qglClearColor(clearColor); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -#if !defined(QT_OPENGL_ES_2) - - glLoadIdentity(); - glTranslatef(0.0f, 0.0f, -10.0f); - glRotatef(xRot / 16.0f, 1.0f, 0.0f, 0.0f); - glRotatef(yRot / 16.0f, 0.0f, 1.0f, 0.0f); - glRotatef(zRot / 16.0f, 0.0f, 0.0f, 1.0f); - - glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); - glTexCoordPointer(2, GL_FLOAT, 0, texCoords.constData()); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - -#else - QMatrix4x4 m; m.ortho(-0.5f, +0.5f, +0.5f, -0.5f, 4.0f, 15.0f); m.translate(0.0f, 0.0f, -10.0f); @@ -169,8 +148,6 @@ void GLWidget::paintGL() program->setAttributeArray (PROGRAM_TEXCOORD_ATTRIBUTE, texCoords.constData()); -#endif - for (int i = 0; i < 6; ++i) { glBindTexture(GL_TEXTURE_2D, textures[i]); glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); @@ -181,17 +158,6 @@ void GLWidget::resizeGL(int width, int height) { int side = qMin(width, height); glViewport((width - side) / 2, (height - side) / 2, side, side); - -#if !defined(QT_OPENGL_ES_2) - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); -#ifndef QT_OPENGL_ES - glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); -#else - glOrthof(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); -#endif - glMatrixMode(GL_MODELVIEW); -#endif } void GLWidget::mousePressEvent(QMouseEvent *event) diff --git a/examples/opengl/textures/glwidget.h b/examples/opengl/textures/glwidget.h index 3ffb35d1ab..fee47b9b48 100644 --- a/examples/opengl/textures/glwidget.h +++ b/examples/opengl/textures/glwidget.h @@ -81,9 +81,7 @@ private: GLuint textures[6]; QVector<QVector3D> vertices; QVector<QVector2D> texCoords; -#ifdef QT_OPENGL_ES_2 QGLShaderProgram *program; -#endif }; #endif |