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 miniproject 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 *window); void initialize(); void paint(); protected: void initializeObjectData(); ...