Time for action – Drawing a triangle using Qt and OpenGL

For the first exercise, we will create a subclass of QOpenGLWindow that renders a triangle using simple OpenGL calls. Create a new project, starting with Empty qmake Project from the Other Project group as the template. In the project file, put the following content:

QT = core gui
TARGET = triangle
TEMPLATE = app 
Note that our project does not include Qt Widgets module. Using the QOpenGLWindow approach allows us to remove this unnecessary dependency and make our application more lightweight.

Note that Qt Core and Qt GUI modules are enabled by default, so you don't have to add them to the QT variable, but we prefer to explicitly show that we are using them in our project.

Having the ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.