2011-04-27 10:05:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2015-01-28 08:44:43 +00:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://www.qt.io/licensing/
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** This file is part of the QtOpenGL module of the Qt Toolkit.
|
|
|
|
**
|
2014-08-21 13:51:22 +00:00
|
|
|
** $QT_BEGIN_LICENSE:LGPL21$
|
2012-09-19 12:28:29 +00:00
|
|
|
** 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
|
2015-01-28 08:44:43 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at http://www.qt.io/contact-us.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2011-04-27 10:05:43 +00:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-09-19 12:28:29 +00:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-08-21 13:51:22 +00:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2015-01-28 08:44:43 +00:00
|
|
|
** As a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2011-04-27 10:05:43 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <QtTest/QtTest>
|
|
|
|
#include <QtOpenGL/qglfunctions.h>
|
|
|
|
|
|
|
|
class tst_QGLFunctions : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
tst_QGLFunctions() {}
|
|
|
|
~tst_QGLFunctions() {}
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void features();
|
|
|
|
void multitexture();
|
|
|
|
void blendColor();
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool hasExtension(const char *name);
|
|
|
|
};
|
|
|
|
|
|
|
|
bool tst_QGLFunctions::hasExtension(const char *name)
|
|
|
|
{
|
|
|
|
QString extensions =
|
|
|
|
QString::fromLatin1
|
2014-04-23 07:08:16 +00:00
|
|
|
(reinterpret_cast<const char *>(QOpenGLContext::currentContext()->functions()->glGetString(GL_EXTENSIONS)));
|
2011-04-27 10:05:43 +00:00
|
|
|
return extensions.split(QLatin1Char(' ')).contains
|
|
|
|
(QString::fromLatin1(name));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that the reported features are consistent with the platform.
|
|
|
|
void tst_QGLFunctions::features()
|
|
|
|
{
|
|
|
|
// Before being associated with a context, there should be
|
|
|
|
// no features enabled.
|
|
|
|
QGLFunctions funcs;
|
|
|
|
QVERIFY(!funcs.openGLFeatures());
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Multitexture));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Shaders));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Buffers));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Framebuffers));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendColor));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendEquation));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendEquationSeparate));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendFuncSeparate));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendSubtract));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::CompressedTextures));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Multisample));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::StencilSeparate));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures));
|
|
|
|
|
|
|
|
// Make a context current.
|
|
|
|
QGLWidget glw;
|
|
|
|
if (!glw.isValid())
|
2011-10-19 02:53:13 +00:00
|
|
|
QSKIP("Could not create a GL context");
|
2011-04-27 10:05:43 +00:00
|
|
|
glw.makeCurrent();
|
|
|
|
funcs.initializeGLFunctions();
|
|
|
|
|
|
|
|
// Validate the features against what we expect for this platform.
|
2014-04-24 15:11:23 +00:00
|
|
|
if (QOpenGLContext::currentContext()->isOpenGLES()) {
|
Dynamic GL switch on Windows
The patch introduces a new build configuration on Windows which
can be requested by passing -opengl dynamic to configure.
Platforms other than Windows (including WinRT) are not affected.
The existing Angle and desktop configurations are not affected.
These continue to function as before and Angle remains the default.
In the future, when all modules have added support for the dynamic
path, as described below, the default configuration could be changed
to be the dynamic one. This would allow providing a single set of
binaries in the official builds instead of the current two.
When requesting dynamic GL, Angle is built but QT_OPENGL_ES[_2] are
never defined. Instead, the code path that has traditionally been
desktop GL only becomes the dynamic path that has to do runtime
checks. Qt modules and applications are not linked to opengl32.dll or
libegl/glesv2.dll in this case. Instead, QtGui exports all necessary
egl/egl/gl functions which will, under the hood, forward all requests
to a dynamically loaded EGL/WGL/GL implementation.
Porting guide (better said, changes needed to prepare your code to
work with dynamic GL builds when the fallback to Angle is utilized):
1. In !QT_OPENGL_ES[_2] code branches use QOpenGLFunctions::isES() to
differentiate between desktop and ES where needed. Keep in mind that
it is the desktop GL header (plus qopenglext.h) that is included,
not the GLES one.
QtGui's proxy will handle some differences, for example calling
glClearDepth will route to glClearDepthf when needed. The built-in
eglGetProcAddress is able to retrieve pointers for standard GLES2
functions too so code resolving OpenGL 2 functions will function
in any case.
2. QT_CONFIG will contain "opengl" and "dynamicgl" in dynamic builds,
but never "angle" or "opengles2".
3. The preprocessor define QT_OPENGL_DYNAMIC is also available in
dynamic builds. The usage of this is strongly discouraged and should
not be needed anywhere except for QtGui and the platform plugin.
4. Code in need of the library handle can use
QOpenGLFunctions::platformGLHandle().
The decision on which library to load is currently based on a simple
test that creates a dummy window/context and tries to resolve an
OpenGL 2 function. If this fails, it goes for Angle. This seems to work
well on Win7 PCs for example that do not have proper graphics drivers
providing OpenGL installed but are D3D9 capable using the default drivers.
Setting QT_OPENGL to desktop or angle skips the test and forces
usage of the given GL. There are also two new application attributes
that could be used for the same purpose.
If Angle is requested but the libraries are not present, desktop is
tried. If desktop is requested, or if angle is requested but nothing
works, the EGL/WGL functions will still be callable but will return 0.
This conveniently means that eglInitialize() and such will report a failure.
Debug messages can be enabled by setting QT_OPENGLPROXY_DEBUG. This will
tell which implementation is chosen.
The textures example application is ported to OpenGL 2, the GL 1
code path is removed.
[ChangeLog][QtGui] Qt builds on Windows can now be configured for
dynamic loading of the OpenGL implementation. This can be requested
by passing -opengl dynamic to configure. In this mode no modules will
link to opengl32.dll or Angle's libegl/libglesv2. Instead, QtGui will
dynamically choose between desktop and Angle during the first GL/EGL/WGL
call. This allows deploying applications with a single set of Qt libraries
with the ability of transparently falling back to Angle in case the
opengl32.dll is not suitable, due to missing graphics drivers for example.
Task-number: QTBUG-36483
Change-Id: I716fdebbf60b355b7d9ef57d1e069eef366b4ab9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-01-27 13:45:11 +00:00
|
|
|
#if !defined(QT_OPENGL_ES) || defined(QT_OPENGL_ES_2)
|
|
|
|
QGLFunctions::OpenGLFeatures allFeatures =
|
|
|
|
(QGLFunctions::Multitexture |
|
|
|
|
QGLFunctions::Shaders |
|
|
|
|
QGLFunctions::Buffers |
|
|
|
|
QGLFunctions::Framebuffers |
|
|
|
|
QGLFunctions::BlendColor |
|
|
|
|
QGLFunctions::BlendEquation |
|
|
|
|
QGLFunctions::BlendEquationSeparate |
|
|
|
|
QGLFunctions::BlendFuncSeparate |
|
|
|
|
QGLFunctions::BlendSubtract |
|
|
|
|
QGLFunctions::CompressedTextures |
|
|
|
|
QGLFunctions::Multisample |
|
|
|
|
QGLFunctions::StencilSeparate |
|
|
|
|
QGLFunctions::NPOTTextures);
|
|
|
|
QVERIFY((funcs.openGLFeatures() & allFeatures) == allFeatures);
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Multitexture));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Shaders));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Buffers));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Framebuffers));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::BlendColor));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::BlendEquation));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::BlendEquationSeparate));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::BlendFuncSeparate));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::BlendSubtract));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::CompressedTextures));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Multisample));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::StencilSeparate));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures));
|
|
|
|
#elif defined(QT_OPENGL_ES) && !defined(QT_OPENGL_ES_2)
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Multitexture));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Buffers));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::CompressedTextures));
|
|
|
|
QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Multisample));
|
2011-04-27 10:05:43 +00:00
|
|
|
|
Dynamic GL switch on Windows
The patch introduces a new build configuration on Windows which
can be requested by passing -opengl dynamic to configure.
Platforms other than Windows (including WinRT) are not affected.
The existing Angle and desktop configurations are not affected.
These continue to function as before and Angle remains the default.
In the future, when all modules have added support for the dynamic
path, as described below, the default configuration could be changed
to be the dynamic one. This would allow providing a single set of
binaries in the official builds instead of the current two.
When requesting dynamic GL, Angle is built but QT_OPENGL_ES[_2] are
never defined. Instead, the code path that has traditionally been
desktop GL only becomes the dynamic path that has to do runtime
checks. Qt modules and applications are not linked to opengl32.dll or
libegl/glesv2.dll in this case. Instead, QtGui exports all necessary
egl/egl/gl functions which will, under the hood, forward all requests
to a dynamically loaded EGL/WGL/GL implementation.
Porting guide (better said, changes needed to prepare your code to
work with dynamic GL builds when the fallback to Angle is utilized):
1. In !QT_OPENGL_ES[_2] code branches use QOpenGLFunctions::isES() to
differentiate between desktop and ES where needed. Keep in mind that
it is the desktop GL header (plus qopenglext.h) that is included,
not the GLES one.
QtGui's proxy will handle some differences, for example calling
glClearDepth will route to glClearDepthf when needed. The built-in
eglGetProcAddress is able to retrieve pointers for standard GLES2
functions too so code resolving OpenGL 2 functions will function
in any case.
2. QT_CONFIG will contain "opengl" and "dynamicgl" in dynamic builds,
but never "angle" or "opengles2".
3. The preprocessor define QT_OPENGL_DYNAMIC is also available in
dynamic builds. The usage of this is strongly discouraged and should
not be needed anywhere except for QtGui and the platform plugin.
4. Code in need of the library handle can use
QOpenGLFunctions::platformGLHandle().
The decision on which library to load is currently based on a simple
test that creates a dummy window/context and tries to resolve an
OpenGL 2 function. If this fails, it goes for Angle. This seems to work
well on Win7 PCs for example that do not have proper graphics drivers
providing OpenGL installed but are D3D9 capable using the default drivers.
Setting QT_OPENGL to desktop or angle skips the test and forces
usage of the given GL. There are also two new application attributes
that could be used for the same purpose.
If Angle is requested but the libraries are not present, desktop is
tried. If desktop is requested, or if angle is requested but nothing
works, the EGL/WGL functions will still be callable but will return 0.
This conveniently means that eglInitialize() and such will report a failure.
Debug messages can be enabled by setting QT_OPENGLPROXY_DEBUG. This will
tell which implementation is chosen.
The textures example application is ported to OpenGL 2, the GL 1
code path is removed.
[ChangeLog][QtGui] Qt builds on Windows can now be configured for
dynamic loading of the OpenGL implementation. This can be requested
by passing -opengl dynamic to configure. In this mode no modules will
link to opengl32.dll or Angle's libegl/libglesv2. Instead, QtGui will
dynamically choose between desktop and Angle during the first GL/EGL/WGL
call. This allows deploying applications with a single set of Qt libraries
with the ability of transparently falling back to Angle in case the
opengl32.dll is not suitable, due to missing graphics drivers for example.
Task-number: QTBUG-36483
Change-Id: I716fdebbf60b355b7d9ef57d1e069eef366b4ab9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-01-27 13:45:11 +00:00
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Shaders));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendColor));
|
|
|
|
QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::StencilSeparate));
|
2011-04-27 10:05:43 +00:00
|
|
|
|
Dynamic GL switch on Windows
The patch introduces a new build configuration on Windows which
can be requested by passing -opengl dynamic to configure.
Platforms other than Windows (including WinRT) are not affected.
The existing Angle and desktop configurations are not affected.
These continue to function as before and Angle remains the default.
In the future, when all modules have added support for the dynamic
path, as described below, the default configuration could be changed
to be the dynamic one. This would allow providing a single set of
binaries in the official builds instead of the current two.
When requesting dynamic GL, Angle is built but QT_OPENGL_ES[_2] are
never defined. Instead, the code path that has traditionally been
desktop GL only becomes the dynamic path that has to do runtime
checks. Qt modules and applications are not linked to opengl32.dll or
libegl/glesv2.dll in this case. Instead, QtGui exports all necessary
egl/egl/gl functions which will, under the hood, forward all requests
to a dynamically loaded EGL/WGL/GL implementation.
Porting guide (better said, changes needed to prepare your code to
work with dynamic GL builds when the fallback to Angle is utilized):
1. In !QT_OPENGL_ES[_2] code branches use QOpenGLFunctions::isES() to
differentiate between desktop and ES where needed. Keep in mind that
it is the desktop GL header (plus qopenglext.h) that is included,
not the GLES one.
QtGui's proxy will handle some differences, for example calling
glClearDepth will route to glClearDepthf when needed. The built-in
eglGetProcAddress is able to retrieve pointers for standard GLES2
functions too so code resolving OpenGL 2 functions will function
in any case.
2. QT_CONFIG will contain "opengl" and "dynamicgl" in dynamic builds,
but never "angle" or "opengles2".
3. The preprocessor define QT_OPENGL_DYNAMIC is also available in
dynamic builds. The usage of this is strongly discouraged and should
not be needed anywhere except for QtGui and the platform plugin.
4. Code in need of the library handle can use
QOpenGLFunctions::platformGLHandle().
The decision on which library to load is currently based on a simple
test that creates a dummy window/context and tries to resolve an
OpenGL 2 function. If this fails, it goes for Angle. This seems to work
well on Win7 PCs for example that do not have proper graphics drivers
providing OpenGL installed but are D3D9 capable using the default drivers.
Setting QT_OPENGL to desktop or angle skips the test and forces
usage of the given GL. There are also two new application attributes
that could be used for the same purpose.
If Angle is requested but the libraries are not present, desktop is
tried. If desktop is requested, or if angle is requested but nothing
works, the EGL/WGL functions will still be callable but will return 0.
This conveniently means that eglInitialize() and such will report a failure.
Debug messages can be enabled by setting QT_OPENGLPROXY_DEBUG. This will
tell which implementation is chosen.
The textures example application is ported to OpenGL 2, the GL 1
code path is removed.
[ChangeLog][QtGui] Qt builds on Windows can now be configured for
dynamic loading of the OpenGL implementation. This can be requested
by passing -opengl dynamic to configure. In this mode no modules will
link to opengl32.dll or Angle's libegl/libglesv2. Instead, QtGui will
dynamically choose between desktop and Angle during the first GL/EGL/WGL
call. This allows deploying applications with a single set of Qt libraries
with the ability of transparently falling back to Angle in case the
opengl32.dll is not suitable, due to missing graphics drivers for example.
Task-number: QTBUG-36483
Change-Id: I716fdebbf60b355b7d9ef57d1e069eef366b4ab9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-01-27 13:45:11 +00:00
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Framebuffers),
|
|
|
|
hasExtension("GL_OES_framebuffer_object"));
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendEquationSeparate),
|
|
|
|
hasExtension("GL_OES_blend_equation_separate"));
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendFuncSeparate),
|
|
|
|
hasExtension("GL_OES_blend_func_separate"));
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendSubtract),
|
|
|
|
hasExtension("GL_OES_blend_subtract"));
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures),
|
|
|
|
hasExtension("GL_OES_texture_npot"));
|
2011-04-27 10:05:43 +00:00
|
|
|
#endif
|
Dynamic GL switch on Windows
The patch introduces a new build configuration on Windows which
can be requested by passing -opengl dynamic to configure.
Platforms other than Windows (including WinRT) are not affected.
The existing Angle and desktop configurations are not affected.
These continue to function as before and Angle remains the default.
In the future, when all modules have added support for the dynamic
path, as described below, the default configuration could be changed
to be the dynamic one. This would allow providing a single set of
binaries in the official builds instead of the current two.
When requesting dynamic GL, Angle is built but QT_OPENGL_ES[_2] are
never defined. Instead, the code path that has traditionally been
desktop GL only becomes the dynamic path that has to do runtime
checks. Qt modules and applications are not linked to opengl32.dll or
libegl/glesv2.dll in this case. Instead, QtGui exports all necessary
egl/egl/gl functions which will, under the hood, forward all requests
to a dynamically loaded EGL/WGL/GL implementation.
Porting guide (better said, changes needed to prepare your code to
work with dynamic GL builds when the fallback to Angle is utilized):
1. In !QT_OPENGL_ES[_2] code branches use QOpenGLFunctions::isES() to
differentiate between desktop and ES where needed. Keep in mind that
it is the desktop GL header (plus qopenglext.h) that is included,
not the GLES one.
QtGui's proxy will handle some differences, for example calling
glClearDepth will route to glClearDepthf when needed. The built-in
eglGetProcAddress is able to retrieve pointers for standard GLES2
functions too so code resolving OpenGL 2 functions will function
in any case.
2. QT_CONFIG will contain "opengl" and "dynamicgl" in dynamic builds,
but never "angle" or "opengles2".
3. The preprocessor define QT_OPENGL_DYNAMIC is also available in
dynamic builds. The usage of this is strongly discouraged and should
not be needed anywhere except for QtGui and the platform plugin.
4. Code in need of the library handle can use
QOpenGLFunctions::platformGLHandle().
The decision on which library to load is currently based on a simple
test that creates a dummy window/context and tries to resolve an
OpenGL 2 function. If this fails, it goes for Angle. This seems to work
well on Win7 PCs for example that do not have proper graphics drivers
providing OpenGL installed but are D3D9 capable using the default drivers.
Setting QT_OPENGL to desktop or angle skips the test and forces
usage of the given GL. There are also two new application attributes
that could be used for the same purpose.
If Angle is requested but the libraries are not present, desktop is
tried. If desktop is requested, or if angle is requested but nothing
works, the EGL/WGL functions will still be callable but will return 0.
This conveniently means that eglInitialize() and such will report a failure.
Debug messages can be enabled by setting QT_OPENGLPROXY_DEBUG. This will
tell which implementation is chosen.
The textures example application is ported to OpenGL 2, the GL 1
code path is removed.
[ChangeLog][QtGui] Qt builds on Windows can now be configured for
dynamic loading of the OpenGL implementation. This can be requested
by passing -opengl dynamic to configure. In this mode no modules will
link to opengl32.dll or Angle's libegl/libglesv2. Instead, QtGui will
dynamically choose between desktop and Angle during the first GL/EGL/WGL
call. This allows deploying applications with a single set of Qt libraries
with the ability of transparently falling back to Angle in case the
opengl32.dll is not suitable, due to missing graphics drivers for example.
Task-number: QTBUG-36483
Change-Id: I716fdebbf60b355b7d9ef57d1e069eef366b4ab9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-01-27 13:45:11 +00:00
|
|
|
} else {
|
|
|
|
// We check for both the extension name and the minimum OpenGL version
|
|
|
|
// for the feature. This will help us catch situations where a platform
|
|
|
|
// doesn't list an extension by name but does have the feature by virtue
|
|
|
|
// of its version number.
|
|
|
|
QGLFormat::OpenGLVersionFlags versions = QGLFormat::openGLVersionFlags();
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Multitexture),
|
|
|
|
hasExtension("GL_ARB_multitexture") ||
|
|
|
|
(versions & QGLFormat::OpenGL_Version_1_3) != 0);
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Shaders),
|
|
|
|
hasExtension("GL_ARB_shader_objects") ||
|
|
|
|
(versions & QGLFormat::OpenGL_Version_2_0) != 0);
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Buffers),
|
|
|
|
(versions & QGLFormat::OpenGL_Version_1_5) != 0);
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Framebuffers),
|
|
|
|
hasExtension("GL_EXT_framebuffer_object") ||
|
|
|
|
hasExtension("GL_ARB_framebuffer_object"));
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendColor),
|
|
|
|
hasExtension("GL_EXT_blend_color") ||
|
|
|
|
(versions & QGLFormat::OpenGL_Version_1_2) != 0);
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendEquation),
|
|
|
|
(versions & QGLFormat::OpenGL_Version_1_2) != 0);
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendEquationSeparate),
|
|
|
|
hasExtension("GL_EXT_blend_equation_separate") ||
|
|
|
|
(versions & QGLFormat::OpenGL_Version_2_0) != 0);
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendFuncSeparate),
|
|
|
|
hasExtension("GL_EXT_blend_func_separate") ||
|
|
|
|
(versions & QGLFormat::OpenGL_Version_1_4) != 0);
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendSubtract),
|
|
|
|
hasExtension("GL_EXT_blend_subtract"));
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::CompressedTextures),
|
|
|
|
hasExtension("GL_ARB_texture_compression") ||
|
|
|
|
(versions & QGLFormat::OpenGL_Version_1_3) != 0);
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Multisample),
|
|
|
|
hasExtension("GL_ARB_multisample") ||
|
|
|
|
(versions & QGLFormat::OpenGL_Version_1_3) != 0);
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::StencilSeparate),
|
|
|
|
(versions & QGLFormat::OpenGL_Version_2_0) != 0);
|
|
|
|
QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures),
|
|
|
|
hasExtension("GL_ARB_texture_non_power_of_two") ||
|
|
|
|
(versions & QGLFormat::OpenGL_Version_2_0) != 0);
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Verify that the multitexture functions appear to resolve and work.
|
|
|
|
void tst_QGLFunctions::multitexture()
|
|
|
|
{
|
2014-04-23 07:08:16 +00:00
|
|
|
QOpenGLFunctions funcs;
|
2011-04-27 10:05:43 +00:00
|
|
|
QGLWidget glw;
|
|
|
|
if (!glw.isValid())
|
2011-10-19 02:53:13 +00:00
|
|
|
QSKIP("Could not create a GL context");
|
2011-04-27 10:05:43 +00:00
|
|
|
glw.makeCurrent();
|
2014-04-23 07:08:16 +00:00
|
|
|
funcs.initializeOpenGLFunctions();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2014-04-23 07:08:16 +00:00
|
|
|
if (!funcs.hasOpenGLFeature(QOpenGLFunctions::Multitexture))
|
2011-10-19 02:53:13 +00:00
|
|
|
QSKIP("Multitexture functions are not supported");
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
funcs.glActiveTexture(GL_TEXTURE1);
|
|
|
|
|
|
|
|
GLint active = 0;
|
2014-04-23 07:08:16 +00:00
|
|
|
funcs.glGetIntegerv(GL_ACTIVE_TEXTURE, &active);
|
2015-07-24 13:49:08 +00:00
|
|
|
QCOMPARE(active, GL_TEXTURE1);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
funcs.glActiveTexture(GL_TEXTURE0);
|
|
|
|
|
|
|
|
active = 0;
|
2014-04-23 07:08:16 +00:00
|
|
|
funcs.glGetIntegerv(GL_ACTIVE_TEXTURE, &active);
|
2015-07-24 13:49:08 +00:00
|
|
|
QCOMPARE(active, GL_TEXTURE0);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Verify that the glBlendColor() function appears to resolve and work.
|
|
|
|
void tst_QGLFunctions::blendColor()
|
|
|
|
{
|
2014-04-23 07:08:16 +00:00
|
|
|
QOpenGLFunctions funcs;
|
2011-04-27 10:05:43 +00:00
|
|
|
QGLWidget glw;
|
|
|
|
if (!glw.isValid())
|
2011-10-19 02:53:13 +00:00
|
|
|
QSKIP("Could not create a GL context");
|
2011-04-27 10:05:43 +00:00
|
|
|
glw.makeCurrent();
|
2014-04-23 07:08:16 +00:00
|
|
|
funcs.initializeOpenGLFunctions();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2014-04-23 07:08:16 +00:00
|
|
|
if (!funcs.hasOpenGLFeature(QOpenGLFunctions::BlendColor))
|
2011-10-19 02:53:13 +00:00
|
|
|
QSKIP("glBlendColor() is not supported");
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
funcs.glBlendColor(0.0f, 1.0f, 0.0f, 1.0f);
|
|
|
|
|
|
|
|
GLfloat colors[4] = {0.5f, 0.5f, 0.5f, 0.5f};
|
2014-04-23 07:08:16 +00:00
|
|
|
funcs.glGetFloatv(GL_BLEND_COLOR, colors);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QCOMPARE(colors[0], 0.0f);
|
|
|
|
QCOMPARE(colors[1], 1.0f);
|
|
|
|
QCOMPARE(colors[2], 0.0f);
|
|
|
|
QCOMPARE(colors[3], 1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
QTEST_MAIN(tst_QGLFunctions)
|
|
|
|
|
|
|
|
#include "tst_qglfunctions.moc"
|