@@ -78,9 +78,9 @@ void initialize()
|
|
78
78
|
// Define the colors for each of the three vertices of the triangle
|
79
79
|
const float colors[] = {
|
80
80
|
// R G B
|
81
|
-
1.0f, 1.0f,
|
82
|
-
1.0f, 1.0f,
|
83
|
-
1.0f, 1.0f,
|
81
|
+
1.0f, 1.0f, 0.0f, // Yellow
|
82
|
+
1.0f, 1.0f, 0.0f, // Yellow
|
83
|
+
1.0f, 1.0f, 0.0f // Yellow
|
84
84
|
};
|
85
85
|
// Create a handle for the vertex color buffer
|
86
86
|
GLuint colorBuffer;
|
@@ -4,6 +4,7 @@
|
|
4
4
|
precision highp float;
|
5
5
|
|
6
6
|
// Task 3: Add an input variable for colors from the vertex shader
|
7
|
+
in vec3 color;
|
7
8
|
|
8
9
|
layout(location = 0) out vec4 fragmentColor;
|
9
10
|
|
@@ -12,5 +13,5 @@ layout(location = 0) out vec4 fragmentColor;
|
|
12
13
|
void main()
|
13
14
|
{
|
14
15
|
// Task 3: Set the output color to be the incoming interpolated color received
|
15
|
-
fragmentColor = vec4(
|
16
|
+
fragmentColor = vec4(color, 1);
|
16
17
|
}
|
@@ -4,10 +4,12 @@ layout(location = 0) in vec3 in_position;
|
|
4
4
|
layout(location = 1) in vec3 in_color;
|
5
5
|
|
6
6
|
// Task 3: Add an output variable to pass colors to the fragment shader
|
7
|
+
out vec3 color;
|
7
8
|
|
8
9
|
void main()
|
9
10
|
{
|
10
11
|
gl_Position = vec4(in_position, 1.0);
|
11
12
|
|
12
13
|
// Task 3: Set the color variable to the vertex color
|
14
|
+
color = in_color;
|
13
15
|
}
|