14192
|
1 |
use glutin::{
|
|
2 |
dpi::LogicalSize,
|
|
3 |
Event,
|
|
4 |
WindowEvent,
|
|
5 |
EventsLoop,
|
|
6 |
GlWindow,
|
14193
|
7 |
GlContext
|
14192
|
8 |
};
|
|
9 |
|
14193
|
10 |
use gfx::{
|
|
11 |
texture,
|
|
12 |
format,
|
14339
|
13 |
Encoder,
|
|
14 |
Device
|
14193
|
15 |
};
|
|
16 |
|
|
17 |
use gfx_window_glutin::init_existing;
|
|
18 |
|
14298
|
19 |
use hedgewars_engine::instance::EngineInstance;
|
14193
|
20 |
|
14192
|
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 |
|
14193
|
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 |
|
14192
|
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 |
}
|
14193
|
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();
|
14339
|
66 |
device.cleanup();
|
14192
|
67 |
}
|
|
68 |
}
|