@@ -79,9 +79,9 @@ void initialize()
|
|
79
79
|
// Define the colors for each of the three vertices of the triangle
|
80
80
|
const float colors[] = {
|
81
81
|
// R G B
|
82
|
-
1.0f, 1.0f,
|
83
|
-
1.0f, 1.0f,
|
84
|
-
1.0f, 1.0f,
|
82
|
+
1.0f, 1.0f, 1.0f, // White
|
83
|
+
1.0f, 1.0f, 1.0f, // White
|
84
|
+
1.0f, 1.0f, 1.0f // White
|
85
85
|
};
|
86
86
|
// Create a handle for the vertex color buffer
|
87
87
|
GLuint colorBuffer;
|
@@ -255,6 +255,7 @@ void display(void)
|
|
255
255
|
glUseProgram(shaderProgram); // Set the shader program to use for this draw call
|
256
256
|
|
257
257
|
// Task 5: Set the `triangleColor` uniform in the shader to `g_triangleColor`
|
258
|
+
labhelper::setUniformSlow(shaderProgram, "triangleColor", g_triangleColor);
|
258
259
|
|
259
260
|
// Bind the vertex array object that contains all the vertex data.
|
260
261
|
glBindVertexArray(vertexArrayObject);
|
@@ -265,6 +266,7 @@ void display(void)
|
|
265
266
|
// Task 4: Render the second VAO
|
266
267
|
// Task 5: Set the `triangleColor` uniform to white
|
267
268
|
glBindVertexArray(vertexArrayObject2);
|
269
|
+
labhelper::setUniformSlow(shaderProgram, "triangleColor", glm::vec3(1, 1, 1));
|
268
270
|
glDrawArrays(GL_TRIANGLES, 0, 6);
|
269
271
|
|
270
272
|
glUseProgram(0); // "unsets" the current shader program. Not really necessary.
|
@@ -280,6 +282,7 @@ void gui()
|
|
280
282
|
ImGui::ColorEdit3("clear color", g_clearColor);
|
281
283
|
|
282
284
|
// Task 5: Add a new ColorEdit3 control to modify the g_triangleColor variable
|
285
|
+
ImGui::ColorEdit3("triangle color", &g_triangleColor.x);
|
283
286
|
|
284
287
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate,
|
285
288
|
ImGui::GetIO().Framerate);
|
@@ -9,9 +9,10 @@ in vec3 color;
|
|
9
9
|
layout(location = 0) out vec4 fragmentColor;
|
10
10
|
|
11
11
|
// Task 5: Add a uniform to tint all the pixels by some color
|
12
|
+
uniform vec3 triangleColor = vec3(1, 1, 1);
|
12
13
|
|
13
14
|
void main()
|
14
15
|
{
|
15
16
|
// Task 3: Set the output color to be the incoming interpolated color received
|
16
|
-
fragmentColor = vec4(color, 1);
|
17
|
+
fragmentColor = vec4(triangleColor * color, 1);
|
17
18
|
}
|