window opens again but a lot of panicking D:
This commit is contained in:
parent
01ff7d39b1
commit
4b2d2a9dc4
3 changed files with 36 additions and 21 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use std::cell::RefCell;
|
||||
use std::fs::read_to_string;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ impl GamePlugin for PlaygroundGame {
|
|||
|
||||
}
|
||||
fn render(&mut self, target: &mut Frame) {
|
||||
|
||||
|
||||
target.clear_color(
|
||||
0.0,
|
||||
0.0,
|
||||
|
|
@ -57,20 +58,23 @@ impl GamePlugin for PlaygroundGame {
|
|||
&uniforms,
|
||||
&Default::default()
|
||||
).unwrap();
|
||||
|
||||
target.finish().unwrap();
|
||||
}
|
||||
fn cleanup(&mut self) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn main() {
|
||||
|
||||
let game = RefCell::new(Game::new());
|
||||
let mut a = game.borrow_mut();
|
||||
a.init();
|
||||
|
||||
let binding = game.borrow();
|
||||
let g = binding.get_display();
|
||||
let binding = Some(a.display.clone()).unwrap().unwrap();
|
||||
// todo: unwraps on none
|
||||
let g = binding;
|
||||
|
||||
let shape = Vertex::define_shape(
|
||||
Vertex { position: [-0.5, -0.5], color: [1.0, 0.0, 0.0] },
|
||||
|
|
@ -78,10 +82,11 @@ fn main() {
|
|||
Vertex { position: [ 0.5, -0.25], color: [0.0, 0.0, 1.0] }
|
||||
);
|
||||
|
||||
|
||||
// "Upload" shape to the memory of the GPU (Vertex Buffer)
|
||||
// Isn't strictly necessary but, makes tge drawing operation faster
|
||||
|
||||
let vertex_buffer: VertexBuffer<Vertex> = VertexBuffer::new(g, &shape).unwrap();
|
||||
let vertex_buffer: VertexBuffer<Vertex> = VertexBuffer::new(&g, &shape).unwrap();
|
||||
|
||||
|
||||
// Complex shapes consist of hundreds/thousands of vertices -> need to have a list of vertices and tell OpenGL how to link these
|
||||
|
|
@ -98,12 +103,12 @@ fn main() {
|
|||
// Important to write matrix * vertex -> Matrix operations produce different results depending on the order
|
||||
// out: defines a variable that is going to be passed along to the fragment shader
|
||||
|
||||
let vertex_shader_src = read_to_string("./shaders/vertex_shader.glsl").unwrap();
|
||||
let fragment_shader_src = read_to_string("./shaders/fragment_shader.glsl").unwrap();
|
||||
let vertex_shader_src = read_to_string("playground/src/shaders/vertex_shader.glsl").unwrap();
|
||||
let fragment_shader_src = read_to_string("playground/src/shaders/fragment_shader.glsl").unwrap();
|
||||
|
||||
// send shader source code to glium
|
||||
let program = glium::Program::from_source(
|
||||
g,
|
||||
&g,
|
||||
&vertex_shader_src,
|
||||
&fragment_shader_src,
|
||||
None
|
||||
|
|
@ -118,7 +123,7 @@ fn main() {
|
|||
program: program,
|
||||
};
|
||||
|
||||
let mut a = game.borrow_mut();
|
||||
//let mut a = game.borrow_mut();
|
||||
a.register_plugin(Box::new(pg_game));
|
||||
|
||||
a.run();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue