Pass uniform for elapsed
@@ -40,3 +40,6 @@ OpenGL does a simple interpolation between the vertex colors, and assigns a colo
|
||||

|
||||
|
||||
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)
|
||||
|
||||
|
||||
BIN
gloom-rs/report/images/a_0.5.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
gloom-rs/report/images/b_0.5.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
gloom-rs/report/images/c_0.5.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
gloom-rs/report/images/d_0.5.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
gloom-rs/report/images/e_0.5.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
gloom-rs/report/images/f_0.5.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||