Solution

Files changed (3) hide show
  1. lab1-rasterization/lab1_main.cpp +3 -3
  2. lab1-rasterization/simple.frag +2 -1
  3. lab1-rasterization/simple.vert +2 -0
lab1-rasterization/lab1_main.cpp CHANGED
@@ -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, 1.0f, // White
82
- 1.0f, 1.0f, 1.0f, // White
83
- 1.0f, 1.0f, 1.0f // White
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;
lab1-rasterization/simple.frag CHANGED
@@ -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(1.0, 1.0, 1.0, 1.0);
16
+ fragmentColor = vec4(color, 1);
16
17
  }
lab1-rasterization/simple.vert CHANGED
@@ -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
  }