Added assets

This commit is contained in:
Thomas Forgione 2018-02-23 17:35:39 +01:00
parent 180ac6b7cb
commit 037b38c704
No known key found for this signature in database
GPG Key ID: C75CD416BD1FFCE1
7 changed files with 52 additions and 2 deletions

View File

@ -0,0 +1,22 @@
varying vec3 fNormal;
varying vec4 fFrontColor;
vec3 ambientLight = vec3(0.2,0.2,0.2);
vec3 directionnalLight = normalize(vec3(10,5,7));
vec3 directionnalLightFactor = vec3(0.5,0.5,0.5);
uniform sampler2D tex;
void main() {
vec3 ambientFactor = ambientLight;
vec3 lambertFactor = max(vec3(0.0,0.0,0.0), dot(directionnalLight, fNormal) * directionnalLightFactor);
vec4 noTexColor = vec4(ambientFactor + lambertFactor, 1.0);
vec4 color = texture2D(tex, gl_TexCoord[0].st);
vec4 fragColor = noTexColor * color;
gl_FragColor = fragColor * fFrontColor;
}

View File

@ -0,0 +1,12 @@
varying vec3 fNormal;
varying vec4 fTexCoord;
varying vec4 fFrontColor;
void main() {
fNormal = gl_Normal;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
fFrontColor = gl_Color;
}

View File

@ -1,9 +1,10 @@
extern crate num;
#[macro_use]
extern crate verbose_log;
#[macro_use] extern crate verbose_log;
#[macro_use] extern crate glium;
pub mod math;
pub mod model;
pub mod renderer;
pub mod parser;
pub mod exporter;

View File

@ -245,6 +245,13 @@ impl Vector3<f64> {
}
}
type Vector2f32 = Vector2<f32>; implement_vertex!(Vector2f32, data);
type Vector2f64 = Vector2<f64>; implement_vertex!(Vector2f64, data);
type Vector3f32 = Vector3<f32>; implement_vertex!(Vector3f32, data);
type Vector3f64 = Vector3<f64>; implement_vertex!(Vector3f64, data);
type Vector4f32 = Vector4<f32>; implement_vertex!(Vector4f32, data);
type Vector4f64 = Vector4<f64>; implement_vertex!(Vector4f64, data);
#[cfg(test)]
mod test {

View File

@ -19,6 +19,13 @@ fn main() {
let context = ContextBuilder::new();
let display = Display::new(window, context, &events_loop).unwrap();
let program = glium::Program::from_source(
&display,
include_str!("../../assets/shaders/shader.vert"),
include_str!("../../assets/shaders/shader.frag"),
None
).unwrap();
let mut closed = false;
while !closed {

1
src/renderer.rs Normal file
View File

@ -0,0 +1 @@
pub struct Renderer;