External shaders

This commit is contained in:
Dane Johnson 2022-04-06 17:32:55 -05:00
parent 311eb0227c
commit 74a4a35d5b
3 changed files with 21 additions and 23 deletions

8
src/flat.frag Normal file
View 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
View 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;
}

View File

@ -27,29 +27,8 @@ fn main() {
let vertex_buffer = glium::VertexBuffer::new(&display, &shape).unwrap();
let indices = glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList);
let vertex_shader_src = r#"
#version 330
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 vertex_shader_src = include_str!("flat.vert");
let fragment_shader_src = include_str!("flat.frag");
let program = glium::Program::from_source(&display, vertex_shader_src, fragment_shader_src, None).unwrap();
events_loop.run(move |ev, _, control_flow| {