-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy path01_instance_creation.rs.diff
80 lines (72 loc) · 2.37 KB
/
01_instance_creation.rs.diff
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
--- a/00_base_code.rs
+++ b/01_instance_creation.rs
@@ -1,34 +1,65 @@
extern crate vulkano;
+extern crate vulkano_win;
extern crate winit;
+use std::sync::Arc;
+
use winit::{EventsLoop, WindowBuilder, dpi::LogicalSize, Event, WindowEvent};
+use vulkano::instance::{
+ Instance,
+ InstanceExtensions,
+ ApplicationInfo,
+ Version,
+};
+
const WIDTH: u32 = 800;
const HEIGHT: u32 = 600;
#[allow(unused)]
struct HelloTriangleApplication {
+ instance: Arc<Instance>,
events_loop: EventsLoop,
}
impl HelloTriangleApplication {
pub fn initialize() -> Self {
+ let instance = Self::create_instance();
let events_loop = Self::init_window();
Self {
+ instance,
events_loop,
}
}
fn init_window() -> EventsLoop {
let events_loop = EventsLoop::new();
- let _window = WindowBuilder::new()
+ let _window_builder = WindowBuilder::new()
.with_title("Vulkan")
- .with_dimensions(LogicalSize::new(f64::from(WIDTH), f64::from(HEIGHT)))
- .build(&events_loop);
+ .with_dimensions(LogicalSize::new(f64::from(WIDTH), f64::from(HEIGHT)));
+ // .build(&self.events_loop.as_ref().unwrap());
events_loop
}
+ fn create_instance() -> Arc<Instance> {
+ let supported_extensions = InstanceExtensions::supported_by_core()
+ .expect("failed to retrieve supported extensions");
+ println!("Supported extensions: {:?}", supported_extensions);
+
+ let app_info = ApplicationInfo {
+ application_name: Some("Hello Triangle".into()),
+ application_version: Some(Version { major: 1, minor: 0, patch: 0 }),
+ engine_name: Some("No Engine".into()),
+ engine_version: Some(Version { major: 1, minor: 0, patch: 0 }),
+ };
+
+ let required_extensions = vulkano_win::required_extensions();
+ Instance::new(Some(&app_info), &required_extensions, None)
+ .expect("failed to create Vulkan instance")
+ }
+
+ #[allow(unused)]
fn main_loop(&mut self) {
loop {
let mut done = false;
@@ -45,6 +76,6 @@ impl HelloTriangleApplication {
}
fn main() {
- let mut app = HelloTriangleApplication::initialize();
- app.main_loop();
+ let mut _app = HelloTriangleApplication::initialize();
+ // app.main_loop();
}