summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopengltexturehelper_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Dynamic GL switch on WindowsLaszlo Agocs2014-02-141-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QOpenGLTextureHelper: add a clarifying commentGiuseppe D'Angelo2014-02-071-1/+3
| | | | | | Change-Id: Ia27fd6616b2259b3fbe71ea8737b270c323a1256 Reviewed-by: James Turner <james.turner@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* QOpenGLTextureHelper: de-inline the DSA / DSA emulator wrappersGiuseppe D'Angelo2014-02-061-383/+118
| | | | | | | | | | | | There's no advantage at keeping them inline because we never call them directly: we take pointers to them. This can actually cause multiple copies of the function to be emitted, then the linker may or may not decide to discard N-1 copies. Just avoid this route and deinline them. Change-Id: I5adc704b50ec7f26498846fcbb86cb5b5d016b4b Reviewed-by: James Turner <james.turner@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* QOpenGLTextureHelper: fix the DSA emulationGiuseppe D'Angelo2014-02-031-150/+174
| | | | | | | | | | | | | | | | | | | | | | The DSA emulator functions query which texture is currently bound to a given target, then bind the new one, perform an operation, and bind the old one back. The problem is that in order to query what's currently bound to the GL_TEXTURE_<X> target one needs to call glGetIntegerv passing GL_BINDING_TEXTURE_<X>. Since both GL_TEXTURE_X and GL_BINDING_TEXTURE_X values are completely arbitrary (not contiguous nor related in any way) we need to pass *both* them to the functions. The right GL_BINDING_TEXTURE_X was getting already chosen (and stored) at texture creation time by QOpenGLTexture, so it's just a matter of passing it around. For the "real" DSA functions, the binding target is ignored. Change-Id: Ida823abbfb142d4a22bf9f9a762b160b7e281c6d Reviewed-by: James Turner <james.turner@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Enable QOpenGLTexture for OpenGL ES 2Jorgen Lind2013-11-141-0/+8
| | | | | Change-Id: I3ec2b7af303070c92e86c0f5ca729eb1a1731682 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Long live QOpenGLTexture!Sean Harmer2013-09-221-0/+1078
Task-number: QTBUG-33274 Change-Id: I9259d947d11f8ba330a2cd7f5620d8f1af0a804b Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>