summaryrefslogtreecommitdiff
path: root/rust/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'rust/opengl')
-rw-r--r--rust/opengl/src/main.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/rust/opengl/src/main.rs b/rust/opengl/src/main.rs
index ff24d1e..d7b3a52 100644
--- a/rust/opengl/src/main.rs
+++ b/rust/opengl/src/main.rs
@@ -11,8 +11,6 @@ fn main() {
.build_glium()
.unwrap();
- // let display = glium::glutin::WindowBuilder::new().build_glium().unwrap();
-
#[derive(Copy, Clone)]
struct Vertex {
position: [f32; 2],
@@ -31,11 +29,9 @@ fn main() {
let vertex_shader_src = r#"
#version 140
in vec2 position;
- uniform float t;
+ uniform mat4 trans;
void main() {
- vec2 p = position;
- p.x += t;
- gl_Position = vec4(p, 0.0, 1.0);
+ gl_Position = trans * vec4(position, 0.0, 1.0);
}
"#;
@@ -56,9 +52,18 @@ fn main() {
t = -0.5;
}
+ let uniforms = uniform! {
+ trans: [
+ [t.cos(), t.sin(), 0.0, 0.0],
+ [-t.sin(), t.cos(), 0.0, 0.0],
+ [1.0, 0.0, 1.0, 0.0],
+ [t, 0.0, 0.0, 1.0f32],
+ ]
+ };
+
let mut target = display.draw();
target.clear_color(0.3, 0.3, 0.2, 1.0);
- target.draw(&vertex_buffer, &indices, &program, &uniform! { t: t },
+ target.draw(&vertex_buffer, &indices, &program, &uniforms,
&Default::default()).unwrap();
target.finish().unwrap();
@@ -69,5 +74,4 @@ fn main() {
}
}
}
-
}