From 8db9f834e604c3a9eda8f76eacad2a9af20dbd33 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 21 Sep 2009 12:40:34 +1000 Subject: Make OpenGL overpainting example compile under OpenGL/ES 1.1 Reviewed-by: trustme --- examples/opengl/overpainting/glwidget.cpp | 12 ++++++++---- examples/opengl/shared/qtlogo.cpp | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/examples/opengl/overpainting/glwidget.cpp b/examples/opengl/overpainting/glwidget.cpp index 0dcccbf..f36fd4f 100644 --- a/examples/opengl/overpainting/glwidget.cpp +++ b/examples/opengl/overpainting/glwidget.cpp @@ -168,10 +168,10 @@ void GLWidget::paintEvent(QPaintEvent *event) //! [7] 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] @@ -252,7 +252,11 @@ void GLWidget::setupViewport(int width, int height) glMatrixMode(GL_PROJECTION); glLoadIdentity(); +#ifdef QT_OPENGL_ES + 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); } //! [14] diff --git a/examples/opengl/shared/qtlogo.cpp b/examples/opengl/shared/qtlogo.cpp index 3294da1..b32b416 100644 --- a/examples/opengl/shared/qtlogo.cpp +++ b/examples/opengl/shared/qtlogo.cpp @@ -172,14 +172,17 @@ static inline void qMultMatrix(const QMatrix4x4 &mat) { if (sizeof(qreal) == sizeof(GLfloat)) glMultMatrixf((GLfloat*)mat.constData()); +#ifndef QT_OPENGL_ES else if (sizeof(qreal) == sizeof(GLdouble)) glMultMatrixd((GLdouble*)mat.constData()); +#endif else { GLfloat fmat[16]; qreal const *r = mat.constData(); for (int i = 0; i < 16; ++i) fmat[i] = r[i]; + glMultMatrixf(fmat); } } @@ -188,7 +191,7 @@ void Patch::draw() const { glPushMatrix(); qMultMatrix(mat); - glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, faceColor); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, faceColor); const GLushort *indices = geom->faces.constData(); glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, indices + start); -- cgit v0.12