14187
|
1 |
use glutin::{
|
|
2 |
dpi::LogicalSize,
|
|
3 |
Event,
|
|
4 |
WindowEvent,
|
|
5 |
EventsLoop,
|
|
6 |
GlWindow,
|
14188
|
7 |
GlContext
|
14187
|
8 |
};
|
|
9 |
|
14188
|
10 |
use gfx::{
|
|
11 |
texture,
|
|
12 |
format,
|
|
13 |
Encoder
|
|
14 |
};
|
|
15 |
|
|
16 |
use gfx_window_glutin::init_existing;
|
|
17 |
|
14293
|
18 |
use hedgewars_engine::instance::EngineInstance;
|
14188
|
19 |
|
14187
|
20 |
fn init(event_loop: &EventsLoop, size: LogicalSize) -> GlWindow {
|
|
21 |
use glutin::{
|
|
22 |
ContextBuilder,
|
|
23 |
WindowBuilder
|
|
24 |
};
|
|
25 |
|
|
26 |
let window = WindowBuilder::new()
|
|
27 |
.with_title("hwengine")
|
|
28 |
.with_dimensions(size);
|
|
29 |
|
|
30 |
let context = ContextBuilder::new();
|
|
31 |
GlWindow::new(window, context, event_loop).unwrap()
|
|
32 |
}
|
|
33 |
|
|
34 |
fn main() {
|
|
35 |
let mut event_loop = EventsLoop::new();
|
|
36 |
let window = init(&event_loop, LogicalSize::new(1024.0, 768.0));
|
|
37 |
|
14188
|
38 |
let (mut device, mut factory, color_view, depth_view) =
|
|
39 |
init_existing::<format::Rgba8, format::Depth>(&window);
|
|
40 |
|
|
41 |
let mut encoder: Encoder<_, _> = factory.create_command_buffer().into();
|
|
42 |
|
|
43 |
let engine = EngineInstance::new();
|
|
44 |
|
14187
|
45 |
let mut is_running = true;
|
|
46 |
while is_running {
|
|
47 |
event_loop.poll_events(|event| {
|
|
48 |
match event {
|
|
49 |
Event::WindowEvent { event, ..} => match event {
|
|
50 |
WindowEvent::CloseRequested => {
|
|
51 |
is_running = false;
|
|
52 |
},
|
|
53 |
_ => ()
|
|
54 |
},
|
|
55 |
_ => ()
|
|
56 |
}
|
14188
|
57 |
});
|
|
58 |
|
|
59 |
encoder.clear(&color_view, [0.5, 0.0, 0.0, 1.0]);
|
|
60 |
engine.render(&mut encoder, &color_view);
|
|
61 |
|
|
62 |
encoder.flush(&mut device);
|
|
63 |
|
|
64 |
window.swap_buffers().unwrap();
|
14187
|
65 |
}
|
|
66 |
}
|