-
Notifications
You must be signed in to change notification settings - Fork 15
/
egui.rs
60 lines (52 loc) · 1.74 KB
/
egui.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
52
53
54
55
56
57
58
59
60
mod profile_with_puffin;
use {
screen_13::prelude::*, screen_13_egui::prelude::*, screen_13_window::Window,
winit::dpi::LogicalSize,
};
fn main() -> anyhow::Result<()> {
pretty_env_logger::init();
profile_with_puffin::init();
let window = Window::builder()
.v_sync(false)
.window(|window| window.with_inner_size(LogicalSize::new(1024, 768)))
.build()?;
let mut egui = Egui::new(&window.device, window.as_ref());
let mut cache = LazyPool::new(&window.device);
window.run(|frame| {
let img = frame.render_graph.bind_node(
cache
.lease(ImageInfo::image_2d(
100,
100,
vk::Format::R8G8B8A8_UNORM,
vk::ImageUsageFlags::SAMPLED | vk::ImageUsageFlags::TRANSFER_DST,
))
.unwrap(),
);
frame
.render_graph
.clear_color_image_value(img, [0., 1., 0., 1.]);
frame
.render_graph
.clear_color_image_value(frame.swapchain_image, [0., 0., 0., 1.]);
let id = egui.register_texture(img);
egui.run(
frame.window,
frame.events,
frame.swapchain_image,
frame.render_graph,
|ui| {
egui::Window::new("Test")
.resizable(true)
.vscroll(true)
.default_size([400., 400.])
.show(ui, |ui| {
ui.add(egui::Button::new("Test"));
ui.add(egui::Link::new("Test"));
ui.add(egui::Image::new((id, egui::Vec2::new(50., 50.))));
});
},
);
})?;
Ok(())
}