mirror of https://github.com/Leinnan/doppler.git
Better log system
This commit is contained in:
parent
4ab3fee655
commit
d916cf3c18
|
|
@ -3,3 +3,4 @@
|
||||||
**jpg
|
**jpg
|
||||||
**jpeg
|
**jpeg
|
||||||
imgui.ini
|
imgui.ini
|
||||||
|
log.log
|
||||||
|
|
@ -153,6 +153,8 @@ dependencies = [
|
||||||
"imgui-inspect",
|
"imgui-inspect",
|
||||||
"imgui-inspect-derive",
|
"imgui-inspect-derive",
|
||||||
"inline_tweak",
|
"inline_tweak",
|
||||||
|
"log",
|
||||||
|
"simple-logging",
|
||||||
"tobj",
|
"tobj",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -790,6 +792,17 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "simple-logging"
|
||||||
|
version = "2.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b00d48e85675326bb182a2286ea7c1a0b264333ae10f27a937a72be08628b542"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"log",
|
||||||
|
"thread-id",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smallvec"
|
name = "smallvec"
|
||||||
version = "1.4.2"
|
version = "1.4.2"
|
||||||
|
|
@ -822,6 +835,17 @@ dependencies = [
|
||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thread-id"
|
||||||
|
version = "3.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"redox_syscall",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thread_local"
|
name = "thread_local"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ imgui-inspect-derive = "0.5.0"
|
||||||
tobj = "2.0.2"
|
tobj = "2.0.2"
|
||||||
human-panic = "1.0.3"
|
human-panic = "1.0.3"
|
||||||
inline_tweak = "1.0.8"
|
inline_tweak = "1.0.8"
|
||||||
|
log = "0.4.11"
|
||||||
|
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"] }
|
||||||
|
|
||||||
[profile.dev.package."*"]
|
[profile.dev.package."*"]
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,6 @@ impl ExampleClient {
|
||||||
pub fn create(_window: &glfw::Window) -> ExampleClient {
|
pub fn create(_window: &glfw::Window) -> ExampleClient {
|
||||||
let sky = unsafe { Sky::new() };
|
let sky = unsafe { Sky::new() };
|
||||||
ExampleClient {
|
ExampleClient {
|
||||||
object_info_id: 0,
|
|
||||||
show_camera_info: true,
|
|
||||||
show_object_info: false,
|
|
||||||
models: vec![],
|
models: vec![],
|
||||||
camera: Camera {
|
camera: Camera {
|
||||||
position: Point3::new(0.0, 8.0, 13.0),
|
position: Point3::new(0.0, 8.0, 13.0),
|
||||||
|
|
@ -42,6 +39,9 @@ impl ExampleClient {
|
||||||
},
|
},
|
||||||
lighting_system: LightingSystem::default(),
|
lighting_system: LightingSystem::default(),
|
||||||
sky: sky,
|
sky: sky,
|
||||||
|
object_info_id: 0,
|
||||||
|
show_camera_info: false,
|
||||||
|
show_object_info: false,
|
||||||
show_light_info: false,
|
show_light_info: false,
|
||||||
light_info_id: 0,
|
light_info_id: 0,
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ impl Client for ExampleClient {
|
||||||
fn load_assets(&mut self, cache: &mut AssetsCache) {
|
fn load_assets(&mut self, cache: &mut AssetsCache) {
|
||||||
let ground = ModelComponent {
|
let ground = ModelComponent {
|
||||||
transform: Transform {
|
transform: Transform {
|
||||||
scale: vec3(0.5, 0.5, 0.5),
|
scale: 0.56,
|
||||||
..Transform::default()
|
..Transform::default()
|
||||||
},
|
},
|
||||||
model: cache.get_model("resources/objects/ground/ground.obj"),
|
model: cache.get_model("resources/objects/ground/ground.obj"),
|
||||||
|
|
@ -64,7 +64,7 @@ impl Client for ExampleClient {
|
||||||
let tree = ModelComponent {
|
let tree = ModelComponent {
|
||||||
transform: Transform {
|
transform: Transform {
|
||||||
position: vec3(10.0, 0.0, 26.0),
|
position: vec3(10.0, 0.0, 26.0),
|
||||||
scale: vec3(2.5, 2.5, 2.5),
|
scale: 2.5,
|
||||||
..Transform::default()
|
..Transform::default()
|
||||||
},
|
},
|
||||||
model: cache.get_model_ext("resources/objects/tree/tree_6_d.obj", Some("tree_e.png")),
|
model: cache.get_model_ext("resources/objects/tree/tree_6_d.obj", Some("tree_e.png")),
|
||||||
|
|
@ -72,7 +72,7 @@ impl Client for ExampleClient {
|
||||||
let tree2 = ModelComponent {
|
let tree2 = ModelComponent {
|
||||||
transform: Transform {
|
transform: Transform {
|
||||||
position: vec3(-9.0, 0.0, -15.0),
|
position: vec3(-9.0, 0.0, -15.0),
|
||||||
scale: vec3(2.5, 2.5, 2.5),
|
scale: 2.5,
|
||||||
..Transform::default()
|
..Transform::default()
|
||||||
},
|
},
|
||||||
model: cache.get_model_ext("resources/objects/tree/tree_6_c.obj", Some("tree_e.png")),
|
model: cache.get_model_ext("resources/objects/tree/tree_6_c.obj", Some("tree_e.png")),
|
||||||
|
|
@ -80,7 +80,7 @@ impl Client for ExampleClient {
|
||||||
let tree3 = ModelComponent {
|
let tree3 = ModelComponent {
|
||||||
transform: Transform {
|
transform: Transform {
|
||||||
position: vec3(15.0, 0.0, -7.0),
|
position: vec3(15.0, 0.0, -7.0),
|
||||||
scale: vec3(2.5, 2.5, 2.5),
|
scale: 2.5,
|
||||||
..Transform::default()
|
..Transform::default()
|
||||||
},
|
},
|
||||||
model: cache.get_model_ext("resources/objects/tree/tree_6_c.obj", Some("tree_e.png")),
|
model: cache.get_model_ext("resources/objects/tree/tree_6_c.obj", Some("tree_e.png")),
|
||||||
|
|
@ -151,14 +151,14 @@ impl Client for ExampleClient {
|
||||||
{
|
{
|
||||||
self.show_light_info = !self.show_light_info;
|
self.show_light_info = !self.show_light_info;
|
||||||
}
|
}
|
||||||
if MenuItem::new(im_str!("Show camera info"))
|
|
||||||
.selected(self.show_camera_info)
|
|
||||||
.build(ui)
|
|
||||||
{
|
|
||||||
self.show_camera_info = !self.show_camera_info;
|
|
||||||
}
|
|
||||||
menu.end(ui);
|
menu.end(ui);
|
||||||
}
|
}
|
||||||
|
if MenuItem::new(im_str!("Toggle Camera Info"))
|
||||||
|
.selected(self.show_camera_info)
|
||||||
|
.build(ui)
|
||||||
|
{
|
||||||
|
self.show_camera_info = !self.show_camera_info;
|
||||||
|
}
|
||||||
menu_bar.end(ui);
|
menu_bar.end(ui);
|
||||||
}
|
}
|
||||||
if self.show_camera_info {
|
if self.show_camera_info {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ use crate::gaia::model::Model;
|
||||||
use crate::gaia::utils::load_texture_from_dir;
|
use crate::gaia::utils::load_texture_from_dir;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use log::{info, trace, warn};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct AssetsCache {
|
pub struct AssetsCache {
|
||||||
|
|
@ -15,7 +16,7 @@ impl AssetsCache {
|
||||||
match self.models.get(path) {
|
match self.models.get(path) {
|
||||||
Some(model) => model.clone(),
|
Some(model) => model.clone(),
|
||||||
None => {
|
None => {
|
||||||
println!("Loading model: {}", path);
|
info!("Loading model: {}", path);
|
||||||
let model = Model::new(path, self);
|
let model = Model::new(path, self);
|
||||||
self.models.insert(path.to_string(), model.clone());
|
self.models.insert(path.to_string(), model.clone());
|
||||||
model
|
model
|
||||||
|
|
@ -27,7 +28,7 @@ impl AssetsCache {
|
||||||
match self.models.get(path) {
|
match self.models.get(path) {
|
||||||
Some(model) => model.clone(),
|
Some(model) => model.clone(),
|
||||||
None => {
|
None => {
|
||||||
println!("Loading model: {}", path);
|
info!("Loading model: {}", path);
|
||||||
let model = Model::new_ext(path, diff_texture, self);
|
let model = Model::new_ext(path, diff_texture, self);
|
||||||
self.models.insert(path.to_string(), model.clone());
|
self.models.insert(path.to_string(), model.clone());
|
||||||
model
|
model
|
||||||
|
|
@ -40,7 +41,6 @@ impl AssetsCache {
|
||||||
Some(texture) => texture.clone(),
|
Some(texture) => texture.clone(),
|
||||||
None => {
|
None => {
|
||||||
let directory: String = dir.into();
|
let directory: String = dir.into();
|
||||||
println!("Loading texture: {}", path);
|
|
||||||
let texture = Texture {
|
let texture = Texture {
|
||||||
id: unsafe { load_texture_from_dir(path, &directory) },
|
id: unsafe { load_texture_from_dir(path, &directory) },
|
||||||
type_: type_name.into(),
|
type_: type_name.into(),
|
||||||
|
|
|
||||||
|
|
@ -7,20 +7,19 @@ use imgui_inspect_derive::Inspect;
|
||||||
|
|
||||||
#[derive(Inspect, Clone, Copy, Debug)]
|
#[derive(Inspect, Clone, Copy, Debug)]
|
||||||
pub struct Transform {
|
pub struct Transform {
|
||||||
#[inspect(proxy_type = "CgmathVec3f32")]
|
|
||||||
pub scale: Vector3<f32>,
|
|
||||||
#[inspect(proxy_type = "CgmathVec3f32")]
|
#[inspect(proxy_type = "CgmathVec3f32")]
|
||||||
pub position: Vector3<f32>,
|
pub position: Vector3<f32>,
|
||||||
#[inspect(proxy_type = "CgmathVec3f32")]
|
#[inspect(proxy_type = "CgmathVec3f32")]
|
||||||
pub rotation: Vector3<f32>,
|
pub rotation: Vector3<f32>,
|
||||||
|
pub scale: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Transform {
|
impl Default for Transform {
|
||||||
fn default() -> Transform {
|
fn default() -> Transform {
|
||||||
Transform {
|
Transform {
|
||||||
position: vec3(0.0, 0.0, 0.0),
|
position: vec3(0.0, 0.0, 0.0),
|
||||||
scale: vec3(1.0, 1.0, 1.0),
|
|
||||||
rotation: vec3(0.0, 0.0, 0.0),
|
rotation: vec3(0.0, 0.0, 0.0),
|
||||||
|
scale: 1.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +27,7 @@ impl Default for Transform {
|
||||||
impl Transform {
|
impl Transform {
|
||||||
pub fn get_matrix(&self) -> Matrix4<f32> {
|
pub fn get_matrix(&self) -> Matrix4<f32> {
|
||||||
let mut m = Matrix4::<f32>::from_translation(self.position);
|
let mut m = Matrix4::<f32>::from_translation(self.position);
|
||||||
m = m * Matrix4::from_nonuniform_scale(self.scale.x, self.scale.y, self.scale.z);
|
m = m * Matrix4::from_scale(self.scale);
|
||||||
m = m * Matrix4::<f32>::from_angle_x(Rad(self.rotation.x.to_radians()));
|
m = m * Matrix4::<f32>::from_angle_x(Rad(self.rotation.x.to_radians()));
|
||||||
m = m * Matrix4::<f32>::from_angle_y(Rad(self.rotation.y.to_radians()));
|
m = m * Matrix4::<f32>::from_angle_y(Rad(self.rotation.y.to_radians()));
|
||||||
m = m * Matrix4::<f32>::from_angle_z(Rad(self.rotation.z.to_radians()));
|
m = m * Matrix4::<f32>::from_angle_z(Rad(self.rotation.z.to_radians()));
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ use imgui_glfw_rs::glfw;
|
||||||
use imgui_glfw_rs::glfw::{Action, Context, Key};
|
use imgui_glfw_rs::glfw::{Action, Context, Key};
|
||||||
use imgui_glfw_rs::imgui;
|
use imgui_glfw_rs::imgui;
|
||||||
use imgui_glfw_rs::ImguiGLFW;
|
use imgui_glfw_rs::ImguiGLFW;
|
||||||
|
use log::{info, trace, warn};
|
||||||
|
|
||||||
pub struct Engine {
|
pub struct Engine {
|
||||||
pub camera: Camera,
|
pub camera: Camera,
|
||||||
|
|
@ -270,7 +271,6 @@ impl Default for Engine {
|
||||||
let client = ExampleClient::create(&window);
|
let client = ExampleClient::create(&window);
|
||||||
let (scr_width, scr_height) = window.get_framebuffer_size();
|
let (scr_width, scr_height) = window.get_framebuffer_size();
|
||||||
let fb = unsafe { FramebufferSystem::generate(scr_width, scr_height) };
|
let fb = unsafe { FramebufferSystem::generate(scr_width, scr_height) };
|
||||||
println!("{:?}", fb);
|
|
||||||
|
|
||||||
Engine {
|
Engine {
|
||||||
bg_info: BgInfo::default(),
|
bg_info: BgInfo::default(),
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ use gl::types::*;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use log::{info, trace, warn};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FramebufferSystem {
|
pub struct FramebufferSystem {
|
||||||
|
|
@ -48,6 +49,7 @@ impl FramebufferSystem {
|
||||||
gl::DrawArrays(gl::TRIANGLES, 0, 6);
|
gl::DrawArrays(gl::TRIANGLES, 0, 6);
|
||||||
}
|
}
|
||||||
pub unsafe fn generate(scr_width: i32, scr_height: i32) -> Self {
|
pub unsafe fn generate(scr_width: i32, scr_height: i32) -> Self {
|
||||||
|
info!("Generating new framebuffer with dimensions {}x{}",scr_width,scr_height);
|
||||||
let screenShader = Shader::from_file(
|
let screenShader = Shader::from_file(
|
||||||
"resources/shaders/framebuffers_screen.vs",
|
"resources/shaders/framebuffers_screen.vs",
|
||||||
"resources/shaders/framebuffers_screen.fs",
|
"resources/shaders/framebuffers_screen.fs",
|
||||||
|
|
@ -136,10 +138,12 @@ impl FramebufferSystem {
|
||||||
); // now actually attach it
|
); // now actually attach it
|
||||||
// now that we actually created the framebuffer and added all attachments we want to check if it is actually complete now
|
// now that we actually created the framebuffer and added all attachments we want to check if it is actually complete now
|
||||||
if gl::CheckFramebufferStatus(gl::FRAMEBUFFER) != gl::FRAMEBUFFER_COMPLETE {
|
if gl::CheckFramebufferStatus(gl::FRAMEBUFFER) != gl::FRAMEBUFFER_COMPLETE {
|
||||||
println!("ERROR::FRAMEBUFFER:: Framebuffer is not complete!");
|
warn!("ERROR::FRAMEBUFFER:: Framebuffer is not complete!");
|
||||||
}
|
}
|
||||||
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
|
gl::BindFramebuffer(gl::FRAMEBUFFER, 0);
|
||||||
|
|
||||||
|
info!("New framebuffer generated");
|
||||||
|
|
||||||
FramebufferSystem {
|
FramebufferSystem {
|
||||||
texture_color_buffer: textureColorbuffer,
|
texture_color_buffer: textureColorbuffer,
|
||||||
shader: screenShader,
|
shader: screenShader,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use crate::gaia::utils::*;
|
||||||
use cgmath::{vec2, vec3};
|
use cgmath::{vec2, vec3};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use tobj;
|
use tobj;
|
||||||
|
use log::{info, trace, warn};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
|
|
@ -50,7 +51,7 @@ impl Model {
|
||||||
// loads a model from file and stores the resulting meshes in the meshes vector.
|
// loads a model from file and stores the resulting meshes in the meshes vector.
|
||||||
fn load_model(&mut self, path: &str, diffuse_path: Option<&str>, cache: &mut AssetsCache) {
|
fn load_model(&mut self, path: &str, diffuse_path: Option<&str>, cache: &mut AssetsCache) {
|
||||||
let path = Path::new(path);
|
let path = Path::new(path);
|
||||||
println!("Started loading model from path: {}", path.display());
|
// println!("Started loading model from path: {}", path.display());
|
||||||
|
|
||||||
// retrieve the directory path of the filepath
|
// retrieve the directory path of the filepath
|
||||||
self.directory = path
|
self.directory = path
|
||||||
|
|
@ -114,7 +115,7 @@ impl Model {
|
||||||
}
|
}
|
||||||
// NOTE: no height maps
|
// NOTE: no height maps
|
||||||
} else if diffuse_path.is_some() {
|
} else if diffuse_path.is_some() {
|
||||||
println!("Loading {}", &diffuse_path.unwrap());
|
// println!("Loading {}", &diffuse_path.unwrap());
|
||||||
let texture = cache.get_material_texture(
|
let texture = cache.get_material_texture(
|
||||||
&self.directory,
|
&self.directory,
|
||||||
&diffuse_path.unwrap(),
|
&diffuse_path.unwrap(),
|
||||||
|
|
@ -122,11 +123,11 @@ impl Model {
|
||||||
);
|
);
|
||||||
textures.push(texture);
|
textures.push(texture);
|
||||||
} else {
|
} else {
|
||||||
println!("There are no materials for: {}", path.display());
|
warn!("There are no materials for: {}", path.display());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.meshes.push(Mesh::new(vertices, indices, textures));
|
self.meshes.push(Mesh::new(vertices, indices, textures));
|
||||||
}
|
}
|
||||||
println!("Finished loading model from path: {}", path.display());
|
info!("Finished loading model");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,12 @@ use gl;
|
||||||
use image2::image::Image;
|
use image2::image::Image;
|
||||||
use image2::{io, ImagePtr, Rgb, Rgba};
|
use image2::{io, ImagePtr, Rgb, Rgba};
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
use log::{info, trace, warn};
|
||||||
|
|
||||||
pub unsafe fn load_texture(path: &str, file_format: &str) -> u32 {
|
pub unsafe fn load_texture(path: &str, file_format: &str) -> u32 {
|
||||||
println!(
|
info!(
|
||||||
"[stb]Loading texture from path: {} with format {}",
|
"Loading texture: {}",
|
||||||
path, file_format
|
path
|
||||||
);
|
);
|
||||||
let mut id = 0;
|
let mut id = 0;
|
||||||
|
|
||||||
|
|
|
||||||
10
src/main.rs
10
src/main.rs
|
|
@ -2,14 +2,22 @@
|
||||||
|
|
||||||
extern crate gl;
|
extern crate gl;
|
||||||
extern crate imgui_glfw_rs;
|
extern crate imgui_glfw_rs;
|
||||||
use human_panic::setup_panic;
|
extern crate log;
|
||||||
|
extern crate simple_logging;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod gaia;
|
mod gaia;
|
||||||
mod example_client;
|
mod example_client;
|
||||||
|
|
||||||
|
use log::LevelFilter;
|
||||||
|
use log::{info, trace, warn};
|
||||||
|
use human_panic::setup_panic;
|
||||||
use crate::gaia::engine::Engine;
|
use crate::gaia::engine::Engine;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
setup_panic!();
|
setup_panic!();
|
||||||
|
simple_logging::log_to_file("log.log", LevelFilter::Info);
|
||||||
|
info!("Starting engine!");
|
||||||
let mut engine = Engine::default();
|
let mut engine = Engine::default();
|
||||||
|
|
||||||
engine.run();
|
engine.run();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue