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
|
use egui_overlay::{EguiOverlay, OverlayApp};
use egui_render_three_d::ThreeDBackend;
use egui_window_glfw_passthrough::glfw::Context;
use egui_window_glfw_passthrough::{GlfwBackend, GlfwConfig};
use crate::Core_Bringup;
// struct CustomEguiOverlay {
// backend:
// }
fn init() {
let mut glfw_backend = GlfwBackend::new(GlfwConfig::default());
let mut glfw_window_ptr = glfw_backend.window.window_ptr();
unsafe {
// Cast the window pointer to the expected type
let window_ptr = glfw_window_ptr as *mut crate::GLFWwindow;
Core_Bringup(window_ptr);
};
}
/// After implementing [`EguiOverlay`], just call this function with your app data
pub fn start<T: EguiOverlay + 'static>(user_data: T) {
let mut glfw_backend = GlfwBackend::new(GlfwConfig {
// this closure will be called before creating a window
glfw_callback: Box::new(|gtx| {
// some defualt hints. it is empty atm, but in future we might add some convenience hints to it.
(egui_window_glfw_passthrough::GlfwConfig::default().glfw_callback)(gtx);
// scale the window size based on monitor scale. as 800x600 looks too small on a 4k screen, compared to a hd screen in absolute pixel sizes.
gtx.window_hint(egui_window_glfw_passthrough::glfw::WindowHint::ScaleToMonitor(true));
}),
opengl_window: Some(true), // macos doesn't support opengl.
transparent_window: Some(false),
window_title: "Celeritas egui".into(),
..Default::default()
});
// always on top
// glfw_backend.window.set_floating(true);
// disable borders/titlebar
// glfw_backend.window.set_decorated(false);
let latest_size = glfw_backend.window.get_framebuffer_size();
let latest_size = [latest_size.0 as _, latest_size.1 as _];
let default_gfx_backend = {
ThreeDBackend::new(
egui_render_three_d::ThreeDConfig {
..Default::default()
},
|s| glfw_backend.get_proc_address(s),
latest_size,
)
};
let glfw_window_ptr = glfw_backend.window.window_ptr();
unsafe {
// Cast the window pointer to the expected type
let window_ptr = glfw_window_ptr as *mut crate::GLFWwindow;
Core_Bringup(window_ptr);
};
let overlap_app = OverlayApp {
user_data,
egui_context: Default::default(),
default_gfx_backend,
glfw_backend,
};
overlap_app.enter_event_loop();
}
|