forked from bwasty/vulkan-tutorial-rs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path00_base_code.rs
51 lines (43 loc) · 1.19 KB
/
00_base_code.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
extern crate vulkano;
extern crate winit;
use winit::{EventsLoop, WindowBuilder, dpi::LogicalSize, Event, WindowEvent};
const WIDTH: u32 = 800;
const HEIGHT: u32 = 600;
#[allow(unused)]
struct HelloTriangleApplication {
events_loop: EventsLoop,
}
impl HelloTriangleApplication {
pub fn initialize() -> Self {
let events_loop = Self::init_window();
Self {
events_loop,
}
}
fn init_window() -> EventsLoop {
let events_loop = EventsLoop::new();
let _window = WindowBuilder::new()
.with_title("Vulkan")
.with_dimensions(LogicalSize::new(f64::from(WIDTH), f64::from(HEIGHT)))
.build(&events_loop);
events_loop
}
fn main_loop(&mut self) {
loop {
let mut done = false;
self.events_loop.poll_events(|ev| {
match ev {
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => done = true,
_ => ()
}
});
if done {
return;
}
}
}
}
fn main() {
let mut app = HelloTriangleApplication::initialize();
app.main_loop();
}