From ba92fe922244a66b4851a049af61cf9be7b1bc9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 24 Oct 2011 14:35:50 +0200 Subject: [PATCH] Re-added hellogl_es and ES 1 support for QOpenGLContext. Change-Id: I576cf3595cdeeefb4ed840bb3b2b7097b3609cc7 Reviewed-by: Gunnar Sletta --- examples/opengl/hellogl_es/glwindow.cpp | 318 ++++++++++++++++++ examples/opengl/hellogl_es/glwindow.h | 78 +++++ examples/opengl/hellogl_es/hellogl_es.desktop | 11 + examples/opengl/hellogl_es/hellogl_es.pro | 18 + examples/opengl/hellogl_es/main.cpp | 52 +++ examples/opengl/hellogl_es/qt.png | Bin 0 -> 5174 bytes examples/opengl/hellogl_es/texture.qrc | 5 + src/gui/kernel/qsurfaceformat.cpp | 8 +- .../eglconvenience/qeglconvenience.cpp | 2 +- .../eglconvenience/qeglplatformcontext.cpp | 4 +- .../eglconvenience/qeglplatformcontext_p.h | 2 +- 11 files changed, 492 insertions(+), 6 deletions(-) create mode 100644 examples/opengl/hellogl_es/glwindow.cpp create mode 100644 examples/opengl/hellogl_es/glwindow.h create mode 100644 examples/opengl/hellogl_es/hellogl_es.desktop create mode 100644 examples/opengl/hellogl_es/hellogl_es.pro create mode 100644 examples/opengl/hellogl_es/main.cpp create mode 100644 examples/opengl/hellogl_es/qt.png create mode 100644 examples/opengl/hellogl_es/texture.qrc diff --git a/examples/opengl/hellogl_es/glwindow.cpp b/examples/opengl/hellogl_es/glwindow.cpp new file mode 100644 index 00000000000..407cb533541 --- /dev/null +++ b/examples/opengl/hellogl_es/glwindow.cpp @@ -0,0 +1,318 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "glwindow.h" + +#include +#include +#include + +#include +#include + +inline void CrossProduct(qreal &xOut, qreal &yOut, qreal &zOut, qreal x1, qreal y1, qreal z1, qreal x2, qreal y2, qreal z2) +{ + xOut = y1 * z2 - z1 * y2; + yOut = z1 * x2 - x1 * z2; + zOut = x1 * y2 - y1 * x2; +} + +inline void Normalize(qreal &x, qreal &y, qreal &z) +{ + qreal l = sqrt(x*x + y*y + z*z); + x = x / l; + y = y / l; + z = z / l; +} + +GLWindow::GLWindow() +{ + qtLogo = true; + createdVertices = 0; + createdNormals = 0; + m_vertexNumber = 0; + frames = 0; + + m_fScale = 1; + + QSurfaceFormat format; + format.setDepthBufferSize(24); + format.setMajorVersion(1); + format.setMinorVersion(1); + + setGeometry(QGuiApplication::primaryScreen()->availableGeometry()); + setFormat(format); + create(); + + m_context = new QOpenGLContext; + m_context->setFormat(format); + m_context->create(); + + m_context->makeCurrent(this); + initializeGL(); + + QTimer *timer = new QTimer(this); + timer->setInterval(16); + connect(timer, SIGNAL(timeout()), this, SLOT(paintGL())); + timer->start(); +} + +GLWindow::~GLWindow() +{ + if (createdVertices) + delete[] createdVertices; + if (createdNormals) + delete[] createdNormals; + + delete m_context; +} + +void GLWindow::paintQtLogo() +{ + glDisable(GL_TEXTURE_2D); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3,GL_FLOAT,0, createdVertices); + glEnableClientState(GL_NORMAL_ARRAY); + glNormalPointer(GL_FLOAT,0,createdNormals); + glDrawArrays(GL_TRIANGLES, 0, m_vertexNumber / 3); +} + +void GLWindow::initializeGL () +{ + glClearColor(0.1f, 0.1f, 0.2f, 1.0f); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + GLfloat aLightPosition[] = {0.0f,0.3f,1.0f,0.0f}; + + glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, aLightPosition); + m_fAngle = 0; + m_fScale = 1; + createGeometry(); +} + +void GLWindow::paintGL() +{ + m_context->makeCurrent(this); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + + //Since OpenGL ES does not support glPush/PopAttrib(GL_ALL_ATTRIB_BITS) + //we have to take care of the states ourselves + + glClearColor(0.1f, 0.1f, 0.2f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glEnable(GL_TEXTURE_2D); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glShadeModel(GL_FLAT); + glFrontFace(GL_CW); + glCullFace(GL_FRONT); + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glRotatef(m_fAngle, 0.0f, 1.0f, 0.0f); + glRotatef(m_fAngle, 1.0f, 0.0f, 0.0f); + glRotatef(m_fAngle, 0.0f, 0.0f, 1.0f); + glScalef(m_fScale, m_fScale,m_fScale); + glTranslatef(0.0f,-0.2f,0.0f); + + GLfloat matDiff[] = {0.40f, 1.0f, 0.0f, 1.0f}; + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiff); + + paintQtLogo(); + + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_TEXTURE); + glPopMatrix(); + + glDisable(GL_LIGHTING); + glDisable(GL_LIGHT0); + + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + + m_context->swapBuffers(this); + + m_fAngle += 1.0f; +} + +void GLWindow::createGeometry() +{ + vertices.clear(); + normals.clear(); + + qreal x1 = +0.06f; + qreal y1 = -0.14f; + qreal x2 = +0.14f; + qreal y2 = -0.06f; + qreal x3 = +0.08f; + qreal y3 = +0.00f; + qreal x4 = +0.30f; + qreal y4 = +0.22f; + + quad(x1, y1, x2, y2, y2, x2, y1, x1); + quad(x3, y3, x4, y4, y4, x4, y3, x3); + + extrude(x1, y1, x2, y2); + extrude(x2, y2, y2, x2); + extrude(y2, x2, y1, x1); + extrude(y1, x1, x1, y1); + extrude(x3, y3, x4, y4); + extrude(x4, y4, y4, x4); + extrude(y4, x4, y3, x3); + + const qreal Pi = 3.14159f; + const int NumSectors = 100; + + for (int i = 0; i < NumSectors; ++i) { + qreal angle1 = (i * 2 * Pi) / NumSectors; + qreal x5 = 0.30 * sin(angle1); + qreal y5 = 0.30 * cos(angle1); + qreal x6 = 0.20 * sin(angle1); + qreal y6 = 0.20 * cos(angle1); + + qreal angle2 = ((i + 1) * 2 * Pi) / NumSectors; + qreal x7 = 0.20 * sin(angle2); + qreal y7 = 0.20 * cos(angle2); + qreal x8 = 0.30 * sin(angle2); + qreal y8 = 0.30 * cos(angle2); + + quad(x5, y5, x6, y6, x7, y7, x8, y8); + + extrude(x6, y6, x7, y7); + extrude(x8, y8, x5, y5); + } + + m_vertexNumber = vertices.size(); + createdVertices = new GLfloat[m_vertexNumber]; + createdNormals = new GLfloat[m_vertexNumber]; + for (int i = 0;i < m_vertexNumber;i++) { + createdVertices[i] = vertices.at(i) * 2; + createdNormals[i] = normals.at(i); + } + vertices.clear(); + normals.clear(); +} + +void GLWindow::quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4) +{ + qreal nx, ny, nz; + + vertices << x1 << y1 << -0.05f; + vertices << x2 << y2 << -0.05f; + vertices << x4 << y4 << -0.05f; + + vertices << x3 << y3 << -0.05f; + vertices << x4 << y4 << -0.05f; + vertices << x2 << y2 << -0.05f; + + CrossProduct(nx, ny, nz, x2 - x1, y2 - y1, 0, x4 - x1, y4 - y1, 0); + Normalize(nx, ny, nz); + + normals << nx << ny << nz; + normals << nx << ny << nz; + normals << nx << ny << nz; + + normals << nx << ny << nz; + normals << nx << ny << nz; + normals << nx << ny << nz; + + vertices << x4 << y4 << 0.05f; + vertices << x2 << y2 << 0.05f; + vertices << x1 << y1 << 0.05f; + + vertices << x2 << y2 << 0.05f; + vertices << x4 << y4 << 0.05f; + vertices << x3 << y3 << 0.05f; + + CrossProduct(nx, ny, nz, x2 - x4, y2 - y4, 0, x1 - x4, y1 - y4, 0); + Normalize(nx, ny, nz); + + normals << nx << ny << nz; + normals << nx << ny << nz; + normals << nx << ny << nz; + + normals << nx << ny << nz; + normals << nx << ny << nz; + normals << nx << ny << nz; +} + +void GLWindow::extrude(qreal x1, qreal y1, qreal x2, qreal y2) +{ + qreal nx, ny, nz; + + vertices << x1 << y1 << +0.05f; + vertices << x2 << y2 << +0.05f; + vertices << x1 << y1 << -0.05f; + + vertices << x2 << y2 << -0.05f; + vertices << x1 << y1 << -0.05f; + vertices << x2 << y2 << +0.05f; + + CrossProduct(nx, ny, nz, x2 - x1, y2 - y1, 0.0f, 0.0f, 0.0f, -0.1f); + Normalize(nx, ny, nz); + + normals << nx << ny << nz; + normals << nx << ny << nz; + normals << nx << ny << nz; + + normals << nx << ny << nz; + normals << nx << ny << nz; + normals << nx << ny << nz; +} diff --git a/examples/opengl/hellogl_es/glwindow.h b/examples/opengl/hellogl_es/glwindow.h new file mode 100644 index 00000000000..f1f1f2ae183 --- /dev/null +++ b/examples/opengl/hellogl_es/glwindow.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GLWINDOW_H +#define GLWINDOW_H + +#include + +#include +#include +#include + +class GLWindow : public QWindow { + Q_OBJECT +public: + GLWindow(); + ~GLWindow(); + +protected slots: + void paintGL(); + void initializeGL(); + +private: + qreal m_fAngle; + qreal m_fScale; + QOpenGLContext *m_context; + void paintQtLogo(); + void createGeometry(); + void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4); + void extrude(qreal x1, qreal y1, qreal x2, qreal y2); + QList vertices; + QList normals; + GLfloat *createdVertices; + GLfloat *createdNormals; + int m_vertexNumber; + bool qtLogo; + int frames; + QTime time; +}; + +#endif diff --git a/examples/opengl/hellogl_es/hellogl_es.desktop b/examples/opengl/hellogl_es/hellogl_es.desktop new file mode 100644 index 00000000000..11c1dd795c2 --- /dev/null +++ b/examples/opengl/hellogl_es/hellogl_es.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Hello GL ES +Exec=/opt/usr/bin/hellogl_es +Icon=hellogl_es +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/opengl/hellogl_es/hellogl_es.pro b/examples/opengl/hellogl_es/hellogl_es.pro new file mode 100644 index 00000000000..6932b778319 --- /dev/null +++ b/examples/opengl/hellogl_es/hellogl_es.pro @@ -0,0 +1,18 @@ +TEMPLATE = app +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += main.cpp +SOURCES += glwindow.cpp + +HEADERS += glwindow.h + +RESOURCES += texture.qrc +QT += gui + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl_es +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hellogl_es.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl_es +INSTALLS += target sources diff --git a/examples/opengl/hellogl_es/main.cpp b/examples/opengl/hellogl_es/main.cpp new file mode 100644 index 00000000000..1b42a48fe18 --- /dev/null +++ b/examples/opengl/hellogl_es/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "glwindow.h" + +int main( int argc, char ** argv ) +{ + Q_INIT_RESOURCE(texture); + QGuiApplication a( argc, argv ); + GLWindow window; + window.show(); + return a.exec(); +} diff --git a/examples/opengl/hellogl_es/qt.png b/examples/opengl/hellogl_es/qt.png new file mode 100644 index 0000000000000000000000000000000000000000..79e383cf50da42a4c1206cdb24b263b70b065ffc GIT binary patch literal 5174 zcmV-66v^v}P)!cpAhmUGxywk%J2Nn87cf) z;+e%6FF`DTSOD>i1rQ4$p0NO80mL&FKrDcG#sY{15YJcuu>j&33m_Ii7UzdMb*|Vg zYxc^z?_~Y=vf(G$^bgtmt9K`Tz8|g0}(Nd0TBgY&k-FnNVH_D_pbkR{z z8xH94N<46fr~u6K7qRa9<;(x7ihuDvUH8FP$|>FC=wqZoBZ+D>Y9hy-Bz*^~B*s3c zXJYd&vhk-1NgQ$lV9OWp*3DkBU*>O+r{>Cacgd+er0L<3?$N5X^dBZ;o>XhW(qpl) z5N0=IOA=Yo^=9k6wO*ciQ?9(NCbgcv(XEe);nhO5G%LSR9hj}tkOcv-@8*@rMZ=|8 zbIHq>tPBhWL?St9;J`n;|cNEhhC>HO0JC)PLXRy$=e^P4A>%>R7YuFebnpvA7t@X88tyVbdp>i zy$8xmi#23hQYQvh;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w92)V<&r8^TZ^W>{ZRDlf;Lj~(po4x@6MME!09zaGOZdz*& z2hBssxxh)R7VXN7IG~o|cjv|NaC=`b)}wIZsS$t{A;;m(wHAZclk8${jHEv@Xy2)J zZVL&hdnP%>ReQrCqZtxF;t2(|<57VSF1uO5y9~U^JT<4-rk(BpN|9JTIuRK}f&D=U z$r-J=Q3QLR)z|mie3QMLaCp6h)#BkPpoHFSI#lJQnN4N13XT9Nb!edIL$Ce0rz*8; z*>(k&$Pra1JT#A?4deSP|gvuR&d7rE%YKrVi>Li5#{!9viZ4O+@i^J%!MXz31j&S8@SWRUWHBty0?NM{D zZI3h$#0KHRgphd85XH=Ez!H;;VBPrR2$LefG5 zEU9Yh&$p=_V^aH=3JlolYtJf>U&CPVr`?|)+ybcDPVCl{B)d=B=I*U_nuZf5TU%5X z!3!chZ_Q*tBYfjToe{vHFykeN1rQ4$p0NO80mL&FKrDcG#sY{15YJcuu>j&33m_Ii kJYxaG0*GfUfP;VjAD9@6C)G$~CjbBd07*qoM6N<$f@mC= + + qt.png + + diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 33b04cc708b..b200cdb1136 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -69,8 +69,8 @@ public: , swapBehavior(QSurfaceFormat::DefaultSwapBehavior) , numSamples(-1) , profile(QSurfaceFormat::NoProfile) - , major(1) - , minor(1) + , major(2) + , minor(0) { } @@ -399,6 +399,8 @@ void QSurfaceFormat::setMajorVersion(int major) /*! Returns the major OpenGL version. + + The default version is 2.0. */ int QSurfaceFormat::majorVersion() const { @@ -407,6 +409,8 @@ int QSurfaceFormat::majorVersion() const /*! Sets the desired minor OpenGL version. + + The default version is 2.0. */ void QSurfaceFormat::setMinorVersion(int minor) { diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index b8643784705..ea4b5566c52 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -212,7 +212,7 @@ EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, configureAttributes.append(surfaceType); configureAttributes.append(EGL_RENDERABLE_TYPE); - configureAttributes.append(EGL_OPENGL_ES2_BIT); + configureAttributes.append(format.majorVersion() == 1 ? EGL_OPENGL_ES_BIT : EGL_OPENGL_ES2_BIT); configureAttributes.append(EGL_NONE); do { diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 58debb8ba83..dfa0bacd358 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -48,7 +48,7 @@ #include QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, - EGLint eglClientVersion, EGLenum eglApi) + EGLenum eglApi) : m_eglDisplay(display) , m_eglApi(eglApi) , m_format(format) @@ -60,7 +60,7 @@ QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatform QVector contextAttrs; contextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); - contextAttrs.append(eglClientVersion); + contextAttrs.append(format.majorVersion()); contextAttrs.append(EGL_NONE); eglBindAPI(m_eglApi); diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h index 2fe0e04388b..c38af1dfdab 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h @@ -50,7 +50,7 @@ class QEGLPlatformContext : public QPlatformOpenGLContext { public: QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, - EGLint eglClientVersion = 2, EGLenum eglApi = EGL_OPENGL_ES_API); + EGLenum eglApi = EGL_OPENGL_ES_API); ~QEGLPlatformContext(); bool makeCurrent(QPlatformSurface *surface);