mirror of https://github.com/Leinnan/doppler.git
Fix compile without imgui
This commit is contained in:
parent
d19a021cf6
commit
31cf464ce4
|
|
@ -57,6 +57,7 @@ impl TimeStep {
|
||||||
pub struct Engine {
|
pub struct Engine {
|
||||||
title: String,
|
title: String,
|
||||||
size: (i32, i32),
|
size: (i32, i32),
|
||||||
|
#[cfg(feature = "imgui_inspect")]
|
||||||
debug_layer: bool,
|
debug_layer: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,6 +66,7 @@ impl Default for Engine {
|
||||||
Engine {
|
Engine {
|
||||||
title: String::from("Doppler demo"),
|
title: String::from("Doppler demo"),
|
||||||
size: (1280, 720),
|
size: (1280, 720),
|
||||||
|
#[cfg(feature = "imgui_inspect")]
|
||||||
debug_layer: true,
|
debug_layer: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -99,11 +101,12 @@ impl Engine {
|
||||||
info!("DPI: {}", gl_window.window().scale_factor());
|
info!("DPI: {}", gl_window.window().scale_factor());
|
||||||
let mut client = ExampleClient::create();
|
let mut client = ExampleClient::create();
|
||||||
let mut framebuffer = unsafe { FramebufferSystem::generate(self.size.0, self.size.1) };
|
let mut framebuffer = unsafe { FramebufferSystem::generate(self.size.0, self.size.1) };
|
||||||
|
#[cfg(feature = "imgui_inspect")]
|
||||||
|
let (mut imgui, mut platform, renderer) = {
|
||||||
let mut imgui = Context::create();
|
let mut imgui = Context::create();
|
||||||
{
|
|
||||||
use imgui::{FontSource, StyleColor};
|
use imgui::{FontSource, StyleColor};
|
||||||
let mut style = imgui.style_mut();
|
let mut style = imgui.style_mut();
|
||||||
// style.scale_all_sizes(1.5);
|
style.scale_all_sizes(1.5);
|
||||||
style[StyleColor::Text] = [1.0, 1.0, 1.0, 1.0];
|
style[StyleColor::Text] = [1.0, 1.0, 1.0, 1.0];
|
||||||
style[StyleColor::TextDisabled] = [0.5, 0.5, 0.5, 1.0];
|
style[StyleColor::TextDisabled] = [0.5, 0.5, 0.5, 1.0];
|
||||||
style[StyleColor::WindowBg] = [0.13, 0.14, 0.15, 1.0];
|
style[StyleColor::WindowBg] = [0.13, 0.14, 0.15, 1.0];
|
||||||
|
|
@ -163,12 +166,13 @@ impl Engine {
|
||||||
config: None,
|
config: None,
|
||||||
}]);
|
}]);
|
||||||
info!("Fonts amount int imgui: {}", imgui.fonts().fonts().len());
|
info!("Fonts amount int imgui: {}", imgui.fonts().fonts().len());
|
||||||
}
|
|
||||||
let mut platform = WinitPlatform::init(&mut imgui); // step 1
|
let mut platform = WinitPlatform::init(&mut imgui); // step 1
|
||||||
platform.attach_window(imgui.io_mut(), &gl_window.window(), HiDpiMode::Locked(1.0)); // step 2
|
platform.attach_window(imgui.io_mut(), &gl_window.window(), HiDpiMode::Locked(1.0)); // step 2
|
||||||
let renderer = imgui_opengl_renderer::Renderer::new(&mut imgui, |s| {
|
let renderer = imgui_opengl_renderer::Renderer::new(&mut imgui, |s| {
|
||||||
gl_window.get_proc_address(s) as _
|
gl_window.get_proc_address(s) as _
|
||||||
});
|
});
|
||||||
|
(imgui, platform, renderer)
|
||||||
|
};
|
||||||
let mut assets_cache = AssetsCache::default();
|
let mut assets_cache = AssetsCache::default();
|
||||||
client.load_assets(&mut assets_cache);
|
client.load_assets(&mut assets_cache);
|
||||||
let mut first_mouse = true;
|
let mut first_mouse = true;
|
||||||
|
|
@ -184,16 +188,21 @@ impl Engine {
|
||||||
event_loop.run(move |event, _, control_flow| {
|
event_loop.run(move |event, _, control_flow| {
|
||||||
use glutin::event_loop::ControlFlow;
|
use glutin::event_loop::ControlFlow;
|
||||||
*control_flow = ControlFlow::Poll;
|
*control_flow = ControlFlow::Poll;
|
||||||
|
#[cfg(feature = "imgui_inspect")]
|
||||||
platform.handle_event(imgui.io_mut(), &gl_window.window(), &event);
|
platform.handle_event(imgui.io_mut(), &gl_window.window(), &event);
|
||||||
match event {
|
match event {
|
||||||
Event::NewEvents(_) => {
|
Event::NewEvents(_) => {
|
||||||
// other application-specific logic
|
// other application-specific logic
|
||||||
|
#[cfg(feature = "imgui_inspect")]
|
||||||
|
{
|
||||||
last_frame = imgui.io_mut().update_delta_time(last_frame);
|
last_frame = imgui.io_mut().update_delta_time(last_frame);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Event::MainEventsCleared => {
|
Event::MainEventsCleared => {
|
||||||
let delta = timestep.delta();
|
let delta = timestep.delta();
|
||||||
client.update(&self, delta);
|
client.update(&self, delta);
|
||||||
// other application-specific logic
|
// other application-specific logic
|
||||||
|
#[cfg(feature = "imgui_inspect")]
|
||||||
platform
|
platform
|
||||||
.prepare_frame(imgui.io_mut(), &gl_window.window()) // step 4
|
.prepare_frame(imgui.io_mut(), &gl_window.window()) // step 4
|
||||||
.expect("Failed to prepare frame");
|
.expect("Failed to prepare frame");
|
||||||
|
|
@ -248,11 +257,12 @@ impl Engine {
|
||||||
FramebufferSystem::generate(size.width as i32, size.height as i32)
|
FramebufferSystem::generate(size.width as i32, size.height as i32)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "imgui_inspect")]
|
||||||
platform.attach_window(
|
platform.attach_window(
|
||||||
imgui.io_mut(),
|
imgui.io_mut(),
|
||||||
&gl_window.window(),
|
&gl_window.window(),
|
||||||
HiDpiMode::Locked(1.0),
|
HiDpiMode::Locked(1.0),
|
||||||
); // step 2
|
);
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
},
|
},
|
||||||
|
|
@ -262,6 +272,8 @@ impl Engine {
|
||||||
client.draw();
|
client.draw();
|
||||||
framebuffer.draw();
|
framebuffer.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "imgui_inspect")]
|
||||||
if self.debug_layer {
|
if self.debug_layer {
|
||||||
imgui.io_mut().display_size = [screensize.0 as f32, screensize.1 as f32];
|
imgui.io_mut().display_size = [screensize.0 as f32, screensize.1 as f32];
|
||||||
let imgui_size = imgui.io().display_size;
|
let imgui_size = imgui.io().display_size;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue