-
Notifications
You must be signed in to change notification settings - Fork 47
/
15_hello_triangle.rs.diff
51 lines (50 loc) · 1.57 KB
/
15_hello_triangle.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
--- a/14_command_buffers.rs
+++ b/15_hello_triangle.rs
@@ -27,10 +27,11 @@ use vulkano::swapchain::{
PresentMode,
Swapchain,
CompositeAlpha,
+ acquire_next_image,
};
use vulkano::format::Format;
use vulkano::image::{ImageUsage, swapchain::SwapchainImage};
-use vulkano::sync::SharingMode;
+use vulkano::sync::{SharingMode, GpuFuture};
use vulkano::pipeline::{
GraphicsPipeline,
vertex::BufferlessDefinition,
@@ -502,6 +503,8 @@ impl HelloTriangleApplication {
#[allow(unused)]
fn main_loop(&mut self) {
loop {
+ self.draw_frame();
+
let mut done = false;
self.events_loop.poll_events(|ev| {
if let Event::WindowEvent { event: WindowEvent::CloseRequested, .. } = ev {
@@ -513,9 +516,24 @@ impl HelloTriangleApplication {
}
}
}
+
+ fn draw_frame(&mut self) {
+ let (image_index, acquire_future) = acquire_next_image(self.swap_chain.clone(), None).unwrap();
+
+ let command_buffer = self.command_buffers[image_index].clone();
+
+ let future = acquire_future
+ .then_execute(self.graphics_queue.clone(), command_buffer)
+ .unwrap()
+ .then_swapchain_present(self.present_queue.clone(), self.swap_chain.clone(), image_index)
+ .then_signal_fence_and_flush()
+ .unwrap();
+
+ future.wait(None).unwrap();
+ }
}
fn main() {
- let mut _app = HelloTriangleApplication::initialize();
- // app.main_loop();
+ let mut app = HelloTriangleApplication::initialize();
+ app.main_loop();
}