With Qt 5 we are making the bold move of making OpenGL 2.0 a requirement for using QtQuick2. There are several challenges with this new requirement, many of which have been discussed on the blogs and mailing lists already, but today I want to talk about one issue in particular and that’s OpenGL on Windows.
Microsoft has included OpenGL in Windows since Windows 98 (or earlier?), however the initial version was a software implementation and only supported version 1.1 of the API. Over time, the implementation has been improved so that today it is implemented as a wrapper on top of Direct3D. This is great, but unfortunately the version of the API that is supported has remained the same and that means it is not sufficient for running QtQuick2 or even Qt’s GL paint engine. You can insert your own conspiracy theory about why Microsoft has let OpenGL stagnate on Windows, but every theory will likely involve Direct3D. D3D is a component of DirectX that offers similar functionality to OpenGL. It is most commonly used by game developers to target desktop Windows and also XBox, but is also used by CAD applications.
ANGLE is a BSD licensed project that implements the OpenGL ES 2.0 API on top of DirectX 9.0c. In addition to this, it also implements the EGL API and contains a shader cross compiler that takes GLSL ES code and converts it to HLSL which is the shader language used in DirectX. So ANGLE allows us to essentially run the Qt Scene Graph on top of DirectX without modifying any of our code. Friedemann has already done most of the hard work by adding support for GLES2 and EGL into the Windows platform plugin and as a result it has been possible to use Qt 5 with ANGLE for quite some time now. However, to make this experience more painless, we are including ANGLE in Qt’s 3rdparty directory and making it the default OpenGL configuration on Windows.
For QML applications and lightweight OpenGL apps, you can use this new configuration to deploy your apps without requiring your end users to install new graphics drivers. On the other hand if your application requires full desktop OpenGL, then it’s simply a matter of configuring Qt with “-opengl desktop” and you get the same behavior as before.
One additional benefit of using ANGLE on Windows is that our graphics pipeline and multimedia pipeline are now based on the same underlying technology (DirectX) so we can take some shortcuts to get video frames into the Scene Graph more efficiently. Taking this one step further, Windows Vista introduced a new driver model called WDDM and one of the features here is that DirectX surfaces can now be shared across processes. This little feature will come in handy for our WebKit2 work which has seperate processes for the web renderer and the ui. All of this goodness might not make it into the 5.0 release, but it’s all in progress so hopefully it makes an appearance soon!
- Qt Graphics and Performance – OpenGL
- QGLWidget in Windows CE Land?
- Braindump, Graphics View and the Joys of off-screen rendering
- 4.3.0 beta binaries
- Using hardware acceleration for graphics