Added render

This commit is contained in:
Thomas Forgione 2018-02-23 15:22:48 +01:00
parent ac010c0530
commit 180ac6b7cb
No known key found for this signature in database
GPG Key ID: C75CD416BD1FFCE1
2 changed files with 57 additions and 0 deletions

View File

@ -5,4 +5,9 @@ authors = ["Thomas Forgione <thomas@tforgione.fr>"]
[dependencies]
num = "*"
glium = "*"
verbose-log = { git = "https://gitea.tforgione.fr/dash-3d/verbose-log" }
[[bin]]
name = "3d-viewer"
path = "src/programs/viewer.rs"

52
src/programs/viewer.rs Normal file
View File

@ -0,0 +1,52 @@
extern crate glium;
use glium::Display;
use glium::glutin;
use glium::glutin::{
EventsLoop,
WindowBuilder,
ContextBuilder,
};
use glium::glutin::Event;
use glium::glutin::WindowEvent;
use glium::glutin::VirtualKeyCode;
fn main() {
let mut events_loop = EventsLoop::new();
let window = WindowBuilder::new();
let context = ContextBuilder::new();
let display = Display::new(window, context, &events_loop).unwrap();
let mut closed = false;
while !closed {
let mut target = display.draw();
use glium::Surface;
target.clear_color(0.0, 0.0, 1.0, 1.0);
target.finish().unwrap();
events_loop.poll_events(|ev| {
match ev {
// Close window
Event::WindowEvent {
event: WindowEvent::Closed, ..
} => closed = true,
// Escape key
Event::WindowEvent {
event: WindowEvent::KeyboardInput {
input: glutin::KeyboardInput {
virtual_keycode: Some(VirtualKeyCode::Escape), ..
}, ..
}, ..
} => closed = true,
_ => (),
}
});
}
}