Time for action – shaded objects
Let's convert our last program so that it uses shaders. To make the cube better, we will implement a smooth lighting model using the Phong algorithm. At the same time, we will learn to use some helper classes that Qt offers for use with OpenGL.
The basic goals for this mini-project are as follows:
- Use vertex and fragment shaders for rendering a complex object
- Handle model, view, and projection matrices
- Use attribute arrays for faster drawing
Start by creating a new subclass of AbstractGLScene
. Let's give it the following interface:
class ShaderGLScene : public QObject, public AbstractGLScene { Q_OBJECT public: ShaderGLScene(SceneGLWindow *wnd); void initialize(); void paint(); protected: void initializeObjectData(); ...
Get Game Programming Using Qt 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.