diff --git a/gloom-rs/report/exercise2.md b/gloom-rs/report/exercise2.md index 2e904db..2b9954b 100644 --- a/gloom-rs/report/exercise2.md +++ b/gloom-rs/report/exercise2.md @@ -40,3 +40,6 @@ OpenGL does a simple interpolation between the vertex colors, and assigns a colo ![](./images/transparent_triangles.png) Here we have drawn three partially overlapping triangles drawn in the order "red - green - blue" with red having the highest z-index (furthest back), followed by green and finally blue. All triangles are rendered with alpha = 0.4 + +TODO TASK 2B) + diff --git a/gloom-rs/report/images/a_0.5.png b/gloom-rs/report/images/a_0.5.png new file mode 100644 index 0000000..d0ab754 Binary files /dev/null and b/gloom-rs/report/images/a_0.5.png differ diff --git a/gloom-rs/report/images/b_0.5.png b/gloom-rs/report/images/b_0.5.png new file mode 100644 index 0000000..703b383 Binary files /dev/null and b/gloom-rs/report/images/b_0.5.png differ diff --git a/gloom-rs/report/images/c_0.5.png b/gloom-rs/report/images/c_0.5.png new file mode 100644 index 0000000..f7bf121 Binary files /dev/null and b/gloom-rs/report/images/c_0.5.png differ diff --git a/gloom-rs/report/images/d_0.5.png b/gloom-rs/report/images/d_0.5.png new file mode 100644 index 0000000..bae6d3f Binary files /dev/null and b/gloom-rs/report/images/d_0.5.png differ diff --git a/gloom-rs/report/images/e_0.5.png b/gloom-rs/report/images/e_0.5.png new file mode 100644 index 0000000..5da484f Binary files /dev/null and b/gloom-rs/report/images/e_0.5.png differ diff --git a/gloom-rs/report/images/f_0.5.png b/gloom-rs/report/images/f_0.5.png new file mode 100644 index 0000000..5d3af9b Binary files /dev/null and b/gloom-rs/report/images/f_0.5.png differ diff --git a/gloom-rs/report/images/transparent_triangles.png b/gloom-rs/report/images/transparent_triangles.png index 932d14a..608e1a0 100644 Binary files a/gloom-rs/report/images/transparent_triangles.png and b/gloom-rs/report/images/transparent_triangles.png differ diff --git a/gloom-rs/shaders/simple.vert b/gloom-rs/shaders/simple.vert index 564a851..9cf01aa 100644 --- a/gloom-rs/shaders/simple.vert +++ b/gloom-rs/shaders/simple.vert @@ -2,18 +2,19 @@ layout(location=0) in vec3 position; layout(location=1) in vec4 vertex_colors; +uniform float elapsed; out vec4 fragment_colors; -// this matrix mirrors over the x-axis and the y-axis simultaneously -const mat4 flip = mat4( - vec4(-1.0f, 0.0f, 0.0f, 0.0f), // column 0 - vec4( 0.0f, -1.0f, 0.0f, 0.0f), // column 1 - vec4( 0.0f, 0.0f, 1.0f, 0.0f), // column 2 - vec4( 0.0f, 0.0f, 0.0f, 1.0f) // column 3 -); void main() { - gl_Position = flip * vec4(position, 1.0f); + // this matrix mirrors over the x-axis and the y-axis simultaneously + mat4 ID_MAT = mat4( + vec4( 1.0f, 0.0f, 0.0f, 0.0f), // column 0 + vec4( 0.0f, elapsed, 0.0f, 0.0f), // column 1 + vec4( 0.0f, 0.0f, 1.0f, 0.0f), // column 2 + vec4( 0.0f, 0.0f, 0.0f, 1.0f) // column 3 + ); + gl_Position = ID_MAT * vec4(position, 1.0f); fragment_colors = vertex_colors; } diff --git a/gloom-rs/src/main.rs b/gloom-rs/src/main.rs index 2f8506a..e3cdc6b 100644 --- a/gloom-rs/src/main.rs +++ b/gloom-rs/src/main.rs @@ -217,6 +217,7 @@ fn main() { let vao_id = unsafe { create_vao(&vertices, &indices, &colors) }; + // == // Set up your shaders here // Basic usage of shader helper: @@ -296,7 +297,9 @@ fn main() { // Clear the color and depth buffers gl::ClearColor(0.035, 0.046, 0.078, 1.0); // night sky gl::Clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT); - + + let loc = simple_shader.get_uniform_location("elapsed"); + gl::Uniform1f(loc, elapsed.sin()); gl::DrawElements(gl::TRIANGLES, indices.len() as i32, gl::UNSIGNED_INT, ptr::null()); }