QGL
← A Painter Application | ● | OpenGL →
QGL is a Qt wrapper for the OpenGL API.
OpenGL is a API for rendering 3D virtual scenes. It utilizes the graphics hardware of a particular platform for high performance rendering. On mobile devices a subset of OpenGL is utilized: OpenGL ES (OpenGL for Embedded Systems).
The main use case for OpenGL in a Qt application is the have a OpenGL rendering context as the 3D rendering area. The QGLWidget class establishes such a context attached to the widget canvas.
So a QGLWidget is a 3D rendering window.
First, we need to check if OpenGL and a proper grafics adaptor is avalable on our platform, so that we can use QGLWidget. Otherwise the application will likely crash.
if (!QGLFormat::hasOpenGL())
{
QMessageBox::warning(0, "NO OPENGL",
"Open GL is not available. Program abort.",
QMessageBox::Ok);
exit(1);
}
Note: If OpenGL is available, it is also utilized as the rendering backend of QPainter.
← A Painter Application | ● | OpenGL →