Include GLES 3.0 and 3.1 headers when available

In ES builds configure will now check for OpenGL ES 3.0 and 3.1
availability. This allows qopengl.h to include the correct header
and, by defining QT_OPENGL_ES_3 and QT_OPENGL_ES_3_1, the OpenGL
wrappers can provide support for MapBuffer, VAOs, etc. on GLES 3.0+
too. Right now this is not possible since the only standard way to
use an ES function specific to a given version is to use the function
directly. The extension mechanism (eglGetProcAddress and friends), that
is often used in desktop GL, is not available for such functions.

[ChangeLog][QtGui] QtGui's OpenGL headers are now automatically including
the highest available header (gl31.h, gl3.h or gl2.h) in OpenGL ES builds.

Task-number: QTBUG-38168
Change-Id: Ib857c58fe1696a9546fdd1aa143a9237e80325a5
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
Laszlo Agocs 2014-04-23 11:53:38 +02:00 committed by The Qt Project
parent bded052aad
commit a26e3ecc3d
6 changed files with 183 additions and 11 deletions

View File

@ -0,0 +1,57 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the config.tests of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifdef BUILD_ON_MAC
#include <OpenGLES/ES3/gl.h>
#else
#include <GLES3/gl3.h>
#endif
int main(int, char **)
{
glGetStringi(GL_EXTENSIONS, 0);
glReadBuffer(GL_COLOR_ATTACHMENT1);
static GLfloat f[6];
glUniformMatrix2x3fv(0, 0, GL_FALSE, f);
glMapBufferRange(GL_ARRAY_BUFFER, 0, 0, GL_MAP_READ_BIT);
return 0;
}

View File

@ -0,0 +1,16 @@
# The library is expected to be the same as in ES 2.0 (libGLESv2).
# The difference is the header and the presence of the functions in
# the library.
SOURCES = opengles3.cpp
INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES2
for(p, QMAKE_LIBDIR_OPENGL_ES2) {
exists($$p):LIBS += -L$$p
}
CONFIG -= qt
LIBS += $$QMAKE_LIBS_OPENGL_ES2
mac {
DEFINES += BUILD_ON_MAC
}

View File

@ -0,0 +1,50 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the config.tests of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <GLES3/gl31.h>
int main(int, char **)
{
glDispatchCompute(1, 1, 1);
glProgramUniform1i(0, 0, 0);
return 0;
}

View File

@ -0,0 +1,13 @@
# The library is expected to be the same as in ES 2.0 (libGLESv2).
# The difference is the header and the presence of the functions in
# the library.
SOURCES = opengles31.cpp
INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES2
for(p, QMAKE_LIBDIR_OPENGL_ES2) {
exists($$p):LIBS += -L$$p
}
CONFIG -= qt
LIBS += $$QMAKE_LIBS_OPENGL_ES2

35
configure vendored
View File

@ -2484,7 +2484,7 @@ Additional options:
-no-opengl .......... Do not support OpenGL.
-opengl <api> ....... Enable OpenGL support
With no parameter, this will attempt to auto-detect
OpenGL ES 2, or regular desktop OpenGL.
OpenGL ES 2.0 and higher, or regular desktop OpenGL.
Use es2 for <api> to override auto-detection.
* -no-system-proxies .. Do not use system network proxies by default.
@ -4675,7 +4675,7 @@ fi
# X11/MINGW OpenGL
if [ "$XPLATFORM_MINGW" = "yes" ]; then
# auto-detect OpenGL support (es2 = OpenGL ES 2.x)
# auto-detect OpenGL support (es2 = OpenGL ES 2.0 or higher)
if [ "$CFG_GUI" = "no" ]; then
if [ "$CFG_OPENGL" = "auto" ]; then
CFG_OPENGL=no
@ -4689,7 +4689,7 @@ if [ "$XPLATFORM_MINGW" = "yes" ]; then
if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then
if compileTest x11/opengl "OpenGL"; then
CFG_OPENGL=desktop
elif compileTest unix/opengles2 "OpenGL ES 2.x"; then
elif compileTest unix/opengles2 "OpenGL ES 2.0"; then
CFG_OPENGL=es2
else
if [ "$CFG_OPENGL" = "yes" ]; then
@ -4715,8 +4715,8 @@ if [ "$XPLATFORM_MINGW" = "yes" ]; then
;;
esac
elif [ "$CFG_OPENGL" = "es2" ]; then
#OpenGL ES 2.x
compileTest unix/opengles2 "OpenGL ES 2.x"
#OpenGL ES 2.0
compileTest unix/opengles2 "OpenGL ES 2.0"
if [ $? != "0" ]; then
echo "The OpenGL ES 2.0 functionality test failed!"
echo " You might need to modify the include and library search paths by editing"
@ -4758,11 +4758,11 @@ if [ "$XPLATFORM_MAC" = "yes" ]; then
fi
fi
# auto-detect OpenGL support (es2 = OpenGL ES 2.x)
# auto-detect OpenGL support (es2 = OpenGL ES 2.0 or higher)
if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then
if compileTest unix/opengldesktop "OpenGL"; then
CFG_OPENGL=desktop
elif compileTest unix/opengles2 "OpenGL ES 2.x"; then
elif compileTest unix/opengles2 "OpenGL ES 2.0"; then
CFG_OPENGL=es2
else
if [ "$CFG_OPENGL" = "yes" ]; then
@ -4775,7 +4775,7 @@ if [ "$CFG_OPENGL" = "auto" ] || [ "$CFG_OPENGL" = "yes" ]; then
CFG_OPENGL=no
fi
elif [ "$CFG_OPENGL" = "es2" ]; then
#OpenGL ES 2.x
#OpenGL ES 2.0
if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists glesv2 2>/dev/null; then
QMAKE_INCDIR_OPENGL_ES2=`$PKG_CONFIG --cflags-only-I glesv2 2>/dev/null | sed -e 's,^-I,,g' -e 's, -I, ,g'`
QMAKE_LIBDIR_OPENGL_ES2=`$PKG_CONFIG --libs-only-L glesv2 2>/dev/null | sed -e 's,^-L,,g' -e 's, -L, ,g'`
@ -4786,7 +4786,7 @@ elif [ "$CFG_OPENGL" = "es2" ]; then
QMakeVar set QMAKE_LIBS_OPENGL_ES2 "`shellArgumentListToQMakeList "$QMAKE_LIBS_OPENGL_ES2"`"
fi
compileTest unix/opengles2 "OpenGL ES 2.x" $QMAKE_LIBS_OPENGL_ES2 $QMAKE_CFLAGS_OPENGL_ES2
compileTest unix/opengles2 "OpenGL ES 2.0" $QMAKE_LIBS_OPENGL_ES2 $QMAKE_CFLAGS_OPENGL_ES2
if [ $? != "0" ]; then
echo "The OpenGL ES 2.0 functionality test failed!"
echo " You might need to modify the include and library search paths by editing"
@ -4806,6 +4806,21 @@ elif [ "$CFG_OPENGL" = "desktop" ]; then
fi
fi
# If OpenGL ES 2.0 is enabled, check for 3.0 and higher. This is used to allow
# compile-time differentiation and including the version specific (but backwards
# compatible) ES headers (for example, GLES3/gl31.h). Other than that, there is
# no difference in the configuration, even the library is the same.
if [ "$CFG_OPENGL" = "es2" ]; then
if compileTest unix/opengles3 "OpenGL ES 3.0" $QMAKE_LIBS_OPENGL_ES2 $QMAKE_CFLAGS_OPENGL_ES2; then
# Add a define for ES3, in addition to ES and ES2.
QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES_3"
fi
if compileTest unix/opengles31 "OpenGL ES 3.1" $QMAKE_LIBS_OPENGL_ES2 $QMAKE_CFLAGS_OPENGL_ES2; then
# Add a define for ES31.
QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES_3_1"
fi
fi
# auto-detect FontConfig support
if [ "$CFG_FONTCONFIG" != "no" ]; then
if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists fontconfig --exists freetype2 2>/dev/null; then
@ -6494,7 +6509,7 @@ report_support " OpenSSL .............." "$CFG_OPENSSL" yes "loading librarie
report_support " NIS ...................." "$CFG_NIS"
report_support " OpenGL / OpenVG:"
report_support " EGL .................." "$CFG_EGL"
report_support " OpenGL ..............." "$CFG_OPENGL" yes "Desktop OpenGL" es2 "OpenGL ES 2.x"
report_support " OpenGL ..............." "$CFG_OPENGL" yes "Desktop OpenGL" es2 "OpenGL ES 2.0+"
report_support " OpenVG ..............." "$CFG_OPENVG-$CFG_OPENVG_SHIVA" yes-yes "ShivaVG" yes-no "native"
report_support " PCRE ..................." "$CFG_PCRE" yes "system library" qt "bundled copy"
if [ -n "$PKG_CONFIG" ]; then

View File

@ -79,7 +79,28 @@
typedef void* GLeglImageOES;
# else // "uncontrolled" ES2 platforms
# include <GLES2/gl2.h>
// In "es2" builds (QT_OPENGL_ES_2) additional defines indicate if ES
// 3.0 or higher is available. In this case include the corresponding
// header. These are backwards compatible and it should be safe to
// include headers on top of each other, meaning that applications can
// include gl2.h even if gl31.h gets included here.
// This compile time differentation is important inside Qt because,
// unlike desktop GL, GLES is different when it comes to versioning
// and extensions: Standard functions that are new in a given version
// are always available in a version-specific header and are not
// guaranteed to be dynamically resolvable via eglGetProcAddress (and
// are typically not available as extensions even if they were part of
// an extension for a previous version).
# if defined(QT_OPENGL_ES_3_1)
# include <GLES3/gl31.h>
# elif defined(QT_OPENGL_ES_3)
# include <GLES3/gl3.h>
# else
# include <GLES2/gl2.h>
#endif
/*
Some GLES2 implementations (like the one on Harmattan) are missing the