qt5base-lts/examples
Laszlo Agocs 97c187da3c 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-02-14 10:51:44 +01:00
..
aggregate install a sane top-level examples.pro file 2012-12-11 13:37:57 +01:00
dbus Remove warnings about examples not running in the Qt Simulator 2013-10-09 21:45:31 +02:00
embedded expand tabs and related whitespace fixes in *.{cpp,h,qdoc} 2014-01-13 22:46:50 +01:00
gui skip gui-needing examples with -no-gui 2013-10-11 21:03:34 +02:00
ipc expand tabs and related whitespace fixes in *.{cpp,h,qdoc} 2014-01-13 22:46:50 +01:00
json Add json/savegame example. 2013-08-22 19:14:03 +02:00
network Merge remote-tracking branch 'origin/stable' into dev 2014-02-07 13:07:25 +01:00
opengl Dynamic GL switch on Windows 2014-02-14 10:51:44 +01:00
qmake Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qpa skip gui-needing examples with -no-gui 2013-10-11 21:03:34 +02:00
qtconcurrent remove remaining non-concurrent branches from concurrent samples 2013-10-29 15:37:30 +01:00
qtestlib Whitespace cleanup: remove trailing whitespace 2013-03-16 20:22:50 +01:00
sql Doc: Moved Books SQL Example documentation 2013-12-05 14:56:29 +01:00
threads Doc: corrected link/example errors 2014-01-31 16:18:07 +01:00
tools Doc: Fix broken links 2013-11-05 00:29:01 +01:00
touch expand tabs and related whitespace fixes in *.{cpp,h,qdoc} 2014-01-13 22:46:50 +01:00
webkit/webkit-guide Changed digia contact details to */legal, updated licenses 2013-07-20 11:21:46 +02:00
widgets Merge remote-tracking branch 'origin/stable' into dev 2014-02-12 16:28:07 +01:00
xml Doc: Move XML example documentation to correct location 2013-12-20 10:37:43 +01:00
examples.pro Doc: corrected link/example errors 2014-01-31 16:18:07 +01:00
README Remove more references to demos. 2011-07-08 15:36:26 +02:00

Qt is supplied with a number of example applications that have been
written to provide developers with examples of the Qt API in use,
highlight good programming practice, and showcase features found in each of
Qt's core technologies.


Documentation for examples can be found in the Examples section
of the Qt documentation.