12/21
3.2. Uniform parameters and animation
The following code send a rotation matrix as uniform to model a rotating triangle.
-
Compile and execute this code and make sure you can observe the rotation of the triangle.

Exercise
-
Change the speed of the rotation in modifying the computation of the variable t.
-
Create a new Uniform variable color used to defined the color of fragments in the fragment shader.
Consider the following position data
const std::vector<GLfloat> position = {
-0.5f, -0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
0.0f, 0.5f, 0.0f,
0.2f, 0.2f, 0.0f,
0.8f, 0.2f, 0.0f,
0.8f, 0.8f, 0.0f
};
We suppose that the first three positions correspond to a red triangle, and the last three correspond to a green triangle.
-
Using your previous uniform variable color, implement the display of these two triangles (both will follow the same rotation).

Hints
The display procedure can be the following
-
Send Rotation matrix as uniform
-
Send the red color as uniform
-
Display the first three vertices
-
Send the green color as uniform
-
Display the next three vertices