From 9bcab9f90c75fce2713ced7fa712f932cc36fa18 Mon Sep 17 00:00:00 2001 From: Piotr Date: Thu, 15 Oct 2020 20:03:16 +0200 Subject: [PATCH] Optional icon, UV fix --- Cargo.toml | 6 +++--- doppler/src/engine.rs | 15 ++++++++++++++- doppler/src/model.rs | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 64f0875..dc5d1bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,8 @@ opt-level = 'z' panic = 'abort' lto = true +[profile.dev.package."*"] +opt-level = 2 + [dependencies] doppler = {path="doppler"} - -[profile.dev.package."*"] -opt-level = 2 \ No newline at end of file diff --git a/doppler/src/engine.rs b/doppler/src/engine.rs index 0e20866..db8d778 100644 --- a/doppler/src/engine.rs +++ b/doppler/src/engine.rs @@ -89,6 +89,7 @@ impl Default for Engine { impl Engine { pub fn run(self) { + use crate::utils; let _ = simple_logging::log_to_file("log.log", LevelFilter::Info); info!("Starting engine!"); let event_loop = glutin::event_loop::EventLoop::new(); @@ -99,11 +100,24 @@ impl Engine { self.size.1 as f32, )) .with_resizable(true); + let gl_window = glutin::ContextBuilder::new() .build_windowed(window, &event_loop) .unwrap(); let gl_window = unsafe { gl_window.make_current().unwrap() }; + + if utils::path_exists(std::path::Path::new("resources/icon.png")) { + use image2::image::Image; + use image2::{io, ImagePtr, Rgba}; + let img: ImagePtr = io::read_u8(std::path::Path::new("resources/icon.png")).unwrap(); + let img_data = img.data().to_vec(); + let (x, y, _) = img.shape(); + let icon = glutin::window::Icon::from_rgba(img_data, x as u32, y as u32); + if icon.is_ok() { + gl_window.window().set_window_icon(Some(icon.unwrap())); + } + } info!( "Pixel format of the window's GL context: {:?}", gl_window.get_pixel_format() @@ -181,7 +195,6 @@ impl Engine { size_pixels: 19.0, config: None, }]); - info!("Fonts amount int imgui: {}", imgui.fonts().fonts().len()); let mut platform = WinitPlatform::init(&mut imgui); // step 1 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| { diff --git a/doppler/src/model.rs b/doppler/src/model.rs index 1817782..558ad3e 100644 --- a/doppler/src/model.rs +++ b/doppler/src/model.rs @@ -81,7 +81,7 @@ impl Model { vertices.push(Vertex { position: vec3(p[i * 3], p[i * 3 + 1], p[i * 3 + 2]), normal: vec3(n[i * 3], n[i * 3 + 1], n[i * 3 + 2]), - text_coords: vec2(t[i * 2], t[i * 2 + 1]), + text_coords: vec2(t[i * 2], 1.0 - t[i * 2 + 1]), ..Vertex::default() }) }