diff options
Diffstat (limited to 'rust/opengl/src')
-rw-r--r-- | rust/opengl/src/main.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/rust/opengl/src/main.rs b/rust/opengl/src/main.rs index d7b3a52..29ee2ec 100644 --- a/rust/opengl/src/main.rs +++ b/rust/opengl/src/main.rs @@ -29,21 +29,25 @@ fn main() { let vertex_shader_src = r#" #version 140 in vec2 position; + out vec2 my_attr; uniform mat4 trans; void main() { + my_attr = position; gl_Position = trans * vec4(position, 0.0, 1.0); } "#; let fragment_shader_src = r#" #version 140 + in vec2 my_attr; out vec4 color; void main() { - color = vec4(0.7, 0.3, 0.2, 1.0); + color = vec4(my_attr, 0.0, 1.0); } "#; - let program = glium::Program::from_source(&display, vertex_shader_src, fragment_shader_src, None).unwrap(); + let program = glium::Program::from_source( + &display, vertex_shader_src, fragment_shader_src, None).unwrap(); let mut t: f32 = -0.5; loop { @@ -62,7 +66,7 @@ fn main() { }; let mut target = display.draw(); - target.clear_color(0.3, 0.3, 0.2, 1.0); + target.clear_color(0.0, 0.0, 0.0, 1.0); target.draw(&vertex_buffer, &indices, &program, &uniforms, &Default::default()).unwrap(); target.finish().unwrap(); |