Working with shaders
The most important part of the abstraction layer is the Shader
class. To draw something, you must bind a shader and attach some attributes and uniforms to it. The shader describes how the thing being drawn should be transformed and shaded, while attributes define what is being drawn.
In this section, you will implement a Shader
class that can compile vertex and fragment shaders. The Shader
class will also return uniform and attribute indices.
The Shader class declaration
When implementing the Shader
class, you will need to declare several protected helper functions. These functions will keep the public API of the class clean; they are used for things such as reading a file into a string or calling an OpenGL code to compile the shader:
- Create a new file to declare the
Shader
class in; call itShader.h
. TheShader
class should have a handle to the OpenGL shader object and maps for attribute and uniform indices. These dictionaries have a string for...