Create no_imgui version of engine, make build 2.63 times faster

This commit is contained in:
Piotr 2020-09-27 20:35:46 +02:00
parent 8b6a15b466
commit cfcd1bf243
11 changed files with 141 additions and 352 deletions

247
Cargo.lock generated
View File

@ -1,29 +1,5 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
[[package]]
name = "addr2line"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"
dependencies = [
"gimli",
]
[[package]]
name = "adler"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
[[package]]
name = "aho-corasick"
version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "approx" name = "approx"
version = "0.3.2" version = "0.3.2"
@ -45,20 +21,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "backtrace"
version = "0.3.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293"
dependencies = [
"addr2line",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.2.1" version = "1.2.1"
@ -85,7 +47,7 @@ checksum = "283944cdecc44bf0b8dd010ec9af888d3b4f142844fdbe026c20ef68148d6fe7"
dependencies = [ dependencies = [
"approx", "approx",
"num-traits", "num-traits",
"rand 0.6.5", "rand",
] ]
[[package]] [[package]]
@ -147,7 +109,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"cgmath", "cgmath",
"gl", "gl",
"human-panic", "glfw",
"image2", "image2",
"imgui-glfw-rs", "imgui-glfw-rs",
"imgui-inspect", "imgui-inspect",
@ -170,23 +132,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]]
name = "getrandom"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "gimli"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
[[package]] [[package]]
name = "gl" name = "gl"
version = "0.14.0" version = "0.14.0"
@ -242,21 +187,6 @@ dependencies = [
"cmake", "cmake",
] ]
[[package]]
name = "human-panic"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39f357a500abcbd7c5f967c1d45c8838585b36743823b9d43488f24850534e36"
dependencies = [
"backtrace",
"os_type",
"serde",
"serde_derive",
"termcolor",
"toml",
"uuid",
]
[[package]] [[package]]
name = "ident_case" name = "ident_case"
version = "1.0.1" version = "1.0.1"
@ -396,21 +326,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "memchr"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
[[package]]
name = "miniz_oxide"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f"
dependencies = [
"adler",
]
[[package]] [[package]]
name = "num" name = "num"
version = "0.3.0" version = "0.3.0"
@ -496,21 +411,6 @@ dependencies = [
"malloc_buf", "malloc_buf",
] ]
[[package]]
name = "object"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
[[package]]
name = "os_type"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7edc011af0ae98b7f88cf7e4a83b70a54a75d2b8cb013d6efd02e5956207e9eb"
dependencies = [
"regex",
]
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.10.2" version = "0.10.2"
@ -535,12 +435,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "ppv-lite86"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.19" version = "1.0.19"
@ -567,9 +461,9 @@ checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
dependencies = [ dependencies = [
"autocfg 0.1.7", "autocfg 0.1.7",
"libc", "libc",
"rand_chacha 0.1.1", "rand_chacha",
"rand_core 0.4.2", "rand_core 0.4.2",
"rand_hc 0.1.0", "rand_hc",
"rand_isaac", "rand_isaac",
"rand_jitter", "rand_jitter",
"rand_os", "rand_os",
@ -578,19 +472,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "rand"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
"getrandom",
"libc",
"rand_chacha 0.2.2",
"rand_core 0.5.1",
"rand_hc 0.2.0",
]
[[package]] [[package]]
name = "rand_chacha" name = "rand_chacha"
version = "0.1.1" version = "0.1.1"
@ -601,16 +482,6 @@ dependencies = [
"rand_core 0.3.1", "rand_core 0.3.1",
] ]
[[package]]
name = "rand_chacha"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [
"ppv-lite86",
"rand_core 0.5.1",
]
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.3.1" version = "0.3.1"
@ -626,15 +497,6 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rand_core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
"getrandom",
]
[[package]] [[package]]
name = "rand_hc" name = "rand_hc"
version = "0.1.0" version = "0.1.0"
@ -644,15 +506,6 @@ dependencies = [
"rand_core 0.3.1", "rand_core 0.3.1",
] ]
[[package]]
name = "rand_hc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
dependencies = [
"rand_core 0.5.1",
]
[[package]] [[package]]
name = "rand_isaac" name = "rand_isaac"
version = "0.1.1" version = "0.1.1"
@ -730,30 +583,6 @@ version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
[[package]]
name = "regex"
version = "1.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"thread_local",
]
[[package]]
name = "regex-syntax"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
[[package]]
name = "rustc-demangle"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.1.0" version = "1.1.0"
@ -775,23 +604,6 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "serde"
version = "1.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5"
[[package]]
name = "serde_derive"
version = "1.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "simple-logging" name = "simple-logging"
version = "2.0.2" version = "2.0.2"
@ -826,15 +638,6 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "termcolor"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f"
dependencies = [
"winapi-util",
]
[[package]] [[package]]
name = "thread-id" name = "thread-id"
version = "3.3.0" version = "3.3.0"
@ -846,51 +649,18 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "thread_local"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
dependencies = [
"lazy_static",
]
[[package]] [[package]]
name = "tobj" name = "tobj"
version = "2.0.2" version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6172100cd5b17cdd085c94f261e31101ca31886c86a2337a6687dac6d2fb3cf1" checksum = "6172100cd5b17cdd085c94f261e31101ca31886c86a2337a6687dac6d2fb3cf1"
[[package]]
name = "toml"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.1" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "uuid"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11"
dependencies = [
"rand 0.7.3",
]
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@ -907,15 +677,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "winapi-x86_64-pc-windows-gnu" name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"

View File

@ -11,16 +11,21 @@ lto = true
[dependencies] [dependencies]
gl = "0.14.0" gl = "0.14.0"
imgui-glfw-rs = { git = "https://github.com/Leinnan/imgui-glfw-rs" } imgui-glfw-rs = { git = "https://github.com/Leinnan/imgui-glfw-rs", optional = true }
glfw = {version="0.40.0", optional = true}
cgmath = "0.17.0" cgmath = "0.17.0"
imgui-inspect = "0.5.0" imgui-inspect = {version="0.5.0", optional = true}
imgui-inspect-derive = "0.5.0" imgui-inspect-derive = {version="0.5.0", optional= true}
tobj = "2.0.2" tobj = "2.0.2"
human-panic = "1.0.3"
inline_tweak = "1.0.8" inline_tweak = "1.0.8"
log = "0.4.11" log = "0.4.11"
simple-logging = "2.0.2" simple-logging = "2.0.2"
image2 = { git = "https://github.com/Leinnan/image2-rs", branch="legacy", default-features = false, features=["io"] } image2 = { git = "https://github.com/Leinnan/image2-rs", branch="legacy", default-features = false, features=["io"] }
[features]
default = ["no_imgui"]
imgui_inspect = ["imgui-inspect-derive", "imgui-inspect", "imgui-glfw-rs"]
no_imgui = ["glfw"]
[profile.dev.package."*"] [profile.dev.package."*"]
opt-level = 2 opt-level = 2

View File

@ -9,6 +9,9 @@ use crate::gaia::sky::Sky;
use crate::gaia::*; use crate::gaia::*;
use cgmath::prelude::*; use cgmath::prelude::*;
use cgmath::{perspective, vec3, Deg, Matrix4, Point3, Vector3}; use cgmath::{perspective, vec3, Deg, Matrix4, Point3, Vector3};
#[cfg(feature = "no_imgui")]
use glfw;
#[cfg(feature = "imgui_inspect")]
use imgui_glfw_rs::glfw; use imgui_glfw_rs::glfw;
pub struct ExampleClient { pub struct ExampleClient {
@ -126,7 +129,7 @@ impl Client for ExampleClient {
fn update(&mut self, _engine: &mut Engine) {} fn update(&mut self, _engine: &mut Engine) {}
fn process_input(&mut self, window: &glfw::Window, delta: f32) { fn process_input(&mut self, window: &glfw::Window, delta: f32) {
use imgui_glfw_rs::glfw::{Action, Key}; use glfw::{Action, Key};
if window.get_key(Key::W) == Action::Press { if window.get_key(Key::W) == Action::Press {
self.camera.process_keyboard(CameraMovement::FORWARD, delta); self.camera.process_keyboard(CameraMovement::FORWARD, delta);
} }
@ -147,9 +150,9 @@ impl Client for ExampleClient {
} }
} }
#[cfg(feature = "imgui_inspect")]
fn debug_draw(&mut self, ui: &imgui_glfw_rs::imgui::Ui) { fn debug_draw(&mut self, ui: &imgui_glfw_rs::imgui::Ui) {
use imgui_glfw_rs::imgui::*; use imgui_glfw_rs::imgui::*;
use imgui_inspect::InspectArgsStruct;
if let Some(menu_bar) = ui.begin_main_menu_bar() { if let Some(menu_bar) = ui.begin_main_menu_bar() {
if let Some(menu) = ui.begin_menu(im_str!("Basic"), true) { if let Some(menu) = ui.begin_menu(im_str!("Basic"), true) {
if MenuItem::new(im_str!("Show Object info")) if MenuItem::new(im_str!("Show Object info"))
@ -174,6 +177,10 @@ impl Client for ExampleClient {
} }
menu_bar.end(ui); menu_bar.end(ui);
} }
{
use imgui_inspect::InspectArgsStruct;
if self.show_camera_info { if self.show_camera_info {
Window::new(im_str!("CameraInfo")) Window::new(im_str!("CameraInfo"))
.size([260.0, 430.0], Condition::Always) .size([260.0, 430.0], Condition::Always)
@ -255,10 +262,12 @@ impl Client for ExampleClient {
); );
} }
}); });
self.light_info_id = id; self.light_info_id = id;
self.show_light_info = show_window; self.show_light_info = show_window;
} }
} }
}
fn on_mouse_scroll(&mut self, yoffset: f32) { fn on_mouse_scroll(&mut self, yoffset: f32) {
self.camera.process_mouse_scroll(yoffset as f32); self.camera.process_mouse_scroll(yoffset as f32);

View File

@ -1,22 +0,0 @@
use imgui_glfw_rs::imgui;
use imgui_inspect_derive::Inspect;
#[derive(Inspect, Clone, Copy)]
pub struct BgInfo {
#[inspect_slider(min_value = 0.0, max_value = 1.0)]
pub r: f32,
#[inspect_slider(min_value = 0.0, max_value = 1.0)]
pub g: f32,
#[inspect_slider(min_value = 0.0, max_value = 1.0)]
pub b: f32,
}
impl Default for BgInfo {
fn default() -> Self {
BgInfo {
r: 0.1,
g: 0.2,
b: 0.4,
}
}
}

View File

@ -1,10 +1,13 @@
#![allow(dead_code)] #![allow(dead_code)]
#[cfg(feature = "imgui_inspect")]
use crate::gaia::imgui_helper::*; use crate::gaia::imgui_helper::*;
use cgmath; use cgmath;
use cgmath::prelude::*; use cgmath::prelude::*;
use cgmath::vec3; use cgmath::vec3;
#[cfg(feature = "imgui_inspect")]
use imgui_glfw_rs::imgui; use imgui_glfw_rs::imgui;
#[cfg(feature = "imgui_inspect")]
use imgui_inspect_derive::Inspect; use imgui_inspect_derive::Inspect;
type Point3 = cgmath::Point3<f32>; type Point3 = cgmath::Point3<f32>;
@ -28,18 +31,19 @@ const SPEED: f32 = 4.5;
const SENSITIVTY: f32 = 0.1; const SENSITIVTY: f32 = 0.1;
const ZOOM: f32 = 45.0; const ZOOM: f32 = 45.0;
#[derive(Inspect, Debug, Clone, Copy)] #[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "imgui_inspect", derive(Inspect))]
pub struct Camera { pub struct Camera {
// Camera Attributes // Camera Attributes
#[inspect(proxy_type = "CgmathPoint3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathPoint3f32"))]
pub position: Point3, pub position: Point3,
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub front: Vector3, pub front: Vector3,
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub up: Vector3, pub up: Vector3,
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub right: Vector3, pub right: Vector3,
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub worldup: Vector3, pub worldup: Vector3,
// Euler Angles // Euler Angles
pub yaw: f32, pub yaw: f32,

View File

@ -1,5 +1,8 @@
use crate::gaia::assets_cache::AssetsCache; use crate::gaia::assets_cache::AssetsCache;
use crate::gaia::engine::Engine; use crate::gaia::engine::Engine;
#[cfg(feature = "no_imgui")]
use glfw;
#[cfg(feature = "imgui_inspect")]
use imgui_glfw_rs::glfw; use imgui_glfw_rs::glfw;
pub trait Client { pub trait Client {
@ -10,5 +13,6 @@ pub trait Client {
fn on_mouse_move(&mut self, x: f32, y: f32); fn on_mouse_move(&mut self, x: f32, y: f32);
// fn draw<T>(&mut self, engine: &mut Engine<T>) where T: Client; // fn draw<T>(&mut self, engine: &mut Engine<T>) where T: Client;
unsafe fn draw(&mut self); unsafe fn draw(&mut self);
#[cfg(feature = "imgui_inspect")]
fn debug_draw(&mut self, ui: &imgui_glfw_rs::imgui::Ui); fn debug_draw(&mut self, ui: &imgui_glfw_rs::imgui::Ui);
} }

View File

@ -1,15 +1,19 @@
#[cfg(feature = "imgui_inspect")]
use crate::gaia::imgui_helper::*; use crate::gaia::imgui_helper::*;
use crate::gaia::model::Model; use crate::gaia::model::Model;
use crate::gaia::shader::Shader; use crate::gaia::shader::Shader;
use cgmath::{vec3, Matrix4, Rad, Vector3}; use cgmath::{vec3, Matrix4, Rad, Vector3};
#[cfg(feature = "imgui_inspect")]
use imgui_glfw_rs::imgui; use imgui_glfw_rs::imgui;
#[cfg(feature = "imgui_inspect")]
use imgui_inspect_derive::Inspect; use imgui_inspect_derive::Inspect;
#[derive(Inspect, Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "imgui_inspect", derive(Inspect))]
pub struct Transform { pub struct Transform {
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub position: Vector3<f32>, pub position: Vector3<f32>,
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub rotation: Vector3<f32>, pub rotation: Vector3<f32>,
pub scale: f32, pub scale: f32,
} }

View File

@ -1,25 +1,32 @@
use crate::example_client::ExampleClient; use crate::example_client::ExampleClient;
use crate::gaia::assets_cache::AssetsCache; use crate::gaia::assets_cache::AssetsCache;
use crate::gaia::bg_info::BgInfo;
use crate::gaia::camera::*; use crate::gaia::camera::*;
use crate::gaia::client::Client; use crate::gaia::client::Client;
use crate::gaia::consts; use crate::gaia::consts;
use crate::gaia::framebuffer::FramebufferSystem; use crate::gaia::framebuffer::FramebufferSystem;
use cgmath::Point3; use cgmath::Point3;
#[cfg(feature = "no_imgui")]
use glfw;
use glfw::{Action, Context, Key};
#[cfg(feature = "imgui_inspect")]
use imgui_glfw_rs::glfw; use imgui_glfw_rs::glfw;
use imgui_glfw_rs::glfw::{Action, Context, Key}; #[cfg(feature = "imgui_inspect")]
use imgui_glfw_rs::glfw;
#[cfg(feature = "imgui_inspect")]
use imgui_glfw_rs::imgui; use imgui_glfw_rs::imgui;
#[cfg(feature = "imgui_inspect")]
use imgui_glfw_rs::ImguiGLFW; use imgui_glfw_rs::ImguiGLFW;
use log::{info, trace, warn}; use log::{info, trace, warn};
pub struct Engine { pub struct Engine {
pub camera: Camera, pub camera: Camera,
pub bg_info: BgInfo, pub window: glfw::Window,
pub window: imgui_glfw_rs::glfw::Window,
pub window_size: (f32, f32), pub window_size: (f32, f32),
pub events: std::sync::mpsc::Receiver<(f64, imgui_glfw_rs::glfw::WindowEvent)>, pub events: std::sync::mpsc::Receiver<(f64, glfw::WindowEvent)>,
pub glfw: imgui_glfw_rs::glfw::Glfw, pub glfw: glfw::Glfw,
#[cfg(feature = "imgui_inspect")]
pub imgui: imgui::Context, pub imgui: imgui::Context,
#[cfg(feature = "imgui_inspect")]
pub imgui_glfw: ImguiGLFW, pub imgui_glfw: ImguiGLFW,
pub client: Box<dyn Client>, pub client: Box<dyn Client>,
enable_debug_layer: bool, enable_debug_layer: bool,
@ -48,8 +55,11 @@ impl Engine {
// input // input
// ----- // -----
#[cfg(feature = "imgui_inspect")]
let skip_input = let skip_input =
self.imgui.io().want_capture_mouse || self.imgui.io().want_capture_keyboard; self.imgui.io().want_capture_mouse || self.imgui.io().want_capture_keyboard;
#[cfg(feature = "no_imgui")]
let skip_input = false;
if !skip_input { if !skip_input {
self.process_input(delta_time); self.process_input(delta_time);
} }
@ -65,6 +75,7 @@ impl Engine {
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.) // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
#[cfg(feature = "imgui_inspect")]
if self.enable_debug_layer { if self.enable_debug_layer {
let ui = self.imgui_glfw.frame(&mut self.window, &mut self.imgui); let ui = self.imgui_glfw.frame(&mut self.window, &mut self.imgui);
self.client.debug_draw(&ui); self.client.debug_draw(&ui);
@ -150,7 +161,9 @@ impl Engine {
skip_input: bool, skip_input: bool,
) { ) {
for (_, event) in glfw::flush_messages(&self.events) { for (_, event) in glfw::flush_messages(&self.events) {
#[cfg(feature = "imgui_inspect")]
self.imgui_glfw.handle_event(&mut self.imgui, &event); self.imgui_glfw.handle_event(&mut self.imgui, &event);
match event { match event {
glfw::WindowEvent::FramebufferSize(width, height) => { glfw::WindowEvent::FramebufferSize(width, height) => {
// make sure the viewport matches the new window dimensions; note that width and // make sure the viewport matches the new window dimensions; note that width and
@ -225,7 +238,9 @@ impl Default for Engine {
// --------------------------------------- // ---------------------------------------
gl::load_with(|symbol| window.get_proc_address(symbol) as *const _); gl::load_with(|symbol| window.get_proc_address(symbol) as *const _);
#[cfg(feature = "imgui_inspect")]
let mut imgui = imgui::Context::create(); let mut imgui = imgui::Context::create();
#[cfg(feature = "imgui_inspect")]
{ {
use imgui_glfw_rs::imgui::FontSource; use imgui_glfw_rs::imgui::FontSource;
use imgui_glfw_rs::imgui::StyleColor; use imgui_glfw_rs::imgui::StyleColor;
@ -290,6 +305,7 @@ impl Default for Engine {
config: None, config: None,
}]); }]);
} }
#[cfg(feature = "imgui_inspect")]
let imgui_glfw = ImguiGLFW::new(&mut imgui, &mut window); let imgui_glfw = ImguiGLFW::new(&mut imgui, &mut window);
// configure global opengl state // configure global opengl state
// ----------------------------- // -----------------------------
@ -301,12 +317,13 @@ impl Default for Engine {
let fb = unsafe { FramebufferSystem::generate(scr_width, scr_height) }; let fb = unsafe { FramebufferSystem::generate(scr_width, scr_height) };
Engine { Engine {
bg_info: BgInfo::default(),
window: window, window: window,
window_size: (consts::SCR_WIDTH as f32, consts::SCR_HEIGHT as f32), window_size: (consts::SCR_WIDTH as f32, consts::SCR_HEIGHT as f32),
events: events, events: events,
glfw: glfw, glfw: glfw,
#[cfg(feature = "imgui_inspect")]
imgui: imgui, imgui: imgui,
#[cfg(feature = "imgui_inspect")]
imgui_glfw: imgui_glfw, imgui_glfw: imgui_glfw,
framebuffer: fb, framebuffer: fb,
camera: Camera { camera: Camera {

View File

@ -1,18 +1,22 @@
#[cfg(feature = "imgui_inspect")]
use crate::gaia::imgui_helper::*; use crate::gaia::imgui_helper::*;
use crate::gaia::shader::Shader; use crate::gaia::shader::Shader;
use cgmath::{perspective, vec3, Deg, Matrix4, Point3, Vector3}; use cgmath::{perspective, vec3, Deg, Matrix4, Point3, Vector3};
#[cfg(feature = "imgui_inspect")]
use imgui_glfw_rs::imgui; use imgui_glfw_rs::imgui;
#[cfg(feature = "imgui_inspect")]
use imgui_inspect_derive::Inspect; use imgui_inspect_derive::Inspect;
#[derive(Inspect, Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "imgui_inspect", derive(Inspect))]
pub struct PointLight { pub struct PointLight {
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub pos: Vector3<f32>, pub pos: Vector3<f32>,
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub ambient: Vector3<f32>, pub ambient: Vector3<f32>,
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub diffuse: Vector3<f32>, pub diffuse: Vector3<f32>,
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub specular: Vector3<f32>, pub specular: Vector3<f32>,
pub constant: f32, pub constant: f32,
pub linear: f32, pub linear: f32,
@ -79,15 +83,16 @@ impl Default for PointLight {
} }
} }
#[derive(Inspect, Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "imgui_inspect", derive(Inspect))]
pub struct DirectionalLight { pub struct DirectionalLight {
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub direction: Vector3<f32>, pub direction: Vector3<f32>,
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub ambient: Vector3<f32>, pub ambient: Vector3<f32>,
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub diffuse: Vector3<f32>, pub diffuse: Vector3<f32>,
#[inspect(proxy_type = "CgmathVec3f32")] #[cfg_attr(feature = "imgui_inspect", inspect(proxy_type = "CgmathVec3f32"))]
pub specular: Vector3<f32>, pub specular: Vector3<f32>,
} }

View File

@ -1,13 +1,13 @@
pub mod macros; pub mod macros;
pub mod assets_cache; pub mod assets_cache;
pub mod bg_info;
pub mod camera; pub mod camera;
pub mod client; pub mod client;
pub mod components; pub mod components;
pub mod consts; pub mod consts;
pub mod engine; pub mod engine;
pub mod framebuffer; pub mod framebuffer;
#[cfg(feature = "imgui_inspect")]
pub mod imgui_helper; pub mod imgui_helper;
pub mod light; pub mod light;
pub mod mesh; pub mod mesh;

View File

@ -1,6 +1,8 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
extern crate gl; extern crate gl;
#[cfg(feature = "imgui_inspect")]
extern crate imgui_glfw_rs; extern crate imgui_glfw_rs;
extern crate log; extern crate log;
extern crate simple_logging; extern crate simple_logging;
@ -10,12 +12,12 @@ mod gaia;
mod example_client; mod example_client;
use crate::gaia::engine::Engine; use crate::gaia::engine::Engine;
use human_panic::setup_panic; // use human_panic::setup_panic;
use log::LevelFilter; use log::LevelFilter;
use log::{info, trace, warn}; use log::{info, trace, warn};
pub fn main() { pub fn main() {
setup_panic!(); // setup_panic!();
simple_logging::log_to_file("log.log", LevelFilter::Info); simple_logging::log_to_file("log.log", LevelFilter::Info);
info!("Starting engine!"); info!("Starting engine!");
let mut engine = Engine::default(); let mut engine = Engine::default();