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