External shaders
This commit is contained in:
parent
311eb0227c
commit
74a4a35d5b
8
src/flat.frag
Normal file
8
src/flat.frag
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#version 330
|
||||||
|
|
||||||
|
in vec3 DIFFUSE;
|
||||||
|
out vec4 color;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
color = vec4(DIFFUSE, 1.0);
|
||||||
|
}
|
11
src/flat.vert
Normal file
11
src/flat.vert
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#version 330
|
||||||
|
|
||||||
|
in vec2 position;
|
||||||
|
in vec3 color;
|
||||||
|
|
||||||
|
out vec3 DIFFUSE;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = vec4(position, 0.0, 1.0);
|
||||||
|
DIFFUSE = color;
|
||||||
|
}
|
25
src/main.rs
25
src/main.rs
@ -27,29 +27,8 @@ fn main() {
|
|||||||
let vertex_buffer = glium::VertexBuffer::new(&display, &shape).unwrap();
|
let vertex_buffer = glium::VertexBuffer::new(&display, &shape).unwrap();
|
||||||
let indices = glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList);
|
let indices = glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList);
|
||||||
|
|
||||||
let vertex_shader_src = r#"
|
let vertex_shader_src = include_str!("flat.vert");
|
||||||
#version 330
|
let fragment_shader_src = include_str!("flat.frag");
|
||||||
|
|
||||||
in vec2 position;
|
|
||||||
in vec3 color;
|
|
||||||
|
|
||||||
out vec3 DIFFUSE;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
gl_Position = vec4(position, 0.0, 1.0);
|
|
||||||
DIFFUSE = color;
|
|
||||||
}
|
|
||||||
"#;
|
|
||||||
let fragment_shader_src = r#"
|
|
||||||
#version 330
|
|
||||||
|
|
||||||
in vec3 DIFFUSE;
|
|
||||||
out vec4 color;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
color = vec4(DIFFUSE, 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();
|
||||||
|
|
||||||
events_loop.run(move |ev, _, control_flow| {
|
events_loop.run(move |ev, _, control_flow| {
|
||||||
|
Loading…
Reference in New Issue
Block a user