mirror of https://github.com/Leinnan/doppler.git
Refactor
This commit is contained in:
parent
a051b6d6ce
commit
f30d198463
|
|
@ -0,0 +1,22 @@
|
||||||
|
use imgui_glfw_rs::imgui;
|
||||||
|
use imgui_inspect_derive::Inspect;
|
||||||
|
|
||||||
|
#[derive(Inspect)]
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -138,4 +138,8 @@ impl Camera {
|
||||||
self.Right = self.Front.cross(self.WorldUp).normalize(); // Normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement.
|
self.Right = self.Front.cross(self.WorldUp).normalize(); // Normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement.
|
||||||
self.Up = self.Right.cross(self.Front).normalize();
|
self.Up = self.Right.cross(self.Front).normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn enable_mouse_movement(&mut self, enable: bool) {
|
||||||
|
self.MouseSensitivity = if enable { SENSITIVTY } else { 0.0 };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
#![macro_use]
|
|
||||||
|
|
||||||
/// Macro to get c strings from literals without runtime overhead
|
/// Macro to get c strings from literals without runtime overhead
|
||||||
/// Literal must not contain any interior nul bytes!
|
/// Literal must not contain any interior nul bytes!
|
||||||
macro_rules! c_str {
|
macro_rules! c_str {
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
pub mod camera;
|
||||||
|
pub mod consts;
|
||||||
|
pub mod utils;
|
||||||
|
#[macro_use]
|
||||||
|
pub mod macros;
|
||||||
|
pub mod shader;
|
||||||
|
pub mod model;
|
||||||
|
pub mod mesh;
|
||||||
|
pub mod bg_info;
|
||||||
|
|
@ -13,7 +13,7 @@ use tobj;
|
||||||
|
|
||||||
use crate::mesh::{ Mesh, Texture, Vertex };
|
use crate::mesh::{ Mesh, Texture, Vertex };
|
||||||
use crate::shader::Shader;
|
use crate::shader::Shader;
|
||||||
use crate::engine::*;
|
use crate::utils::*;
|
||||||
|
|
||||||
// #[derive(Default)]
|
// #[derive(Default)]
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
|
|
@ -10,11 +10,21 @@ use gl::types::*;
|
||||||
|
|
||||||
use cgmath::prelude::*;
|
use cgmath::prelude::*;
|
||||||
use cgmath::{Matrix, Matrix4, Vector3};
|
use cgmath::{Matrix, Matrix4, Vector3};
|
||||||
|
use crate::gaia::consts;
|
||||||
|
|
||||||
pub struct Shader {
|
pub struct Shader {
|
||||||
pub ID: u32,
|
pub ID: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Shader {
|
||||||
|
fn default() -> Self {
|
||||||
|
let vShaderCode = CString::new(consts::VERTEX_SHADER_SRC.as_bytes()).unwrap();
|
||||||
|
let fShaderCode = CString::new(consts::FRAGMENT_SHADER_SRC.as_bytes()).unwrap();
|
||||||
|
|
||||||
|
Shader::new(vShaderCode, fShaderCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// NOTE: mixture of `shader_s.h` and `shader_m.h` (the latter just contains
|
/// NOTE: mixture of `shader_s.h` and `shader_m.h` (the latter just contains
|
||||||
/// a few more setters for uniforms)
|
/// a few more setters for uniforms)
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
37
src/main.rs
37
src/main.rs
|
|
@ -5,44 +5,20 @@ extern crate image;
|
||||||
use imgui_glfw_rs::glfw;
|
use imgui_glfw_rs::glfw;
|
||||||
// Use the reexported imgui crate to avoid version conflicts.
|
// Use the reexported imgui crate to avoid version conflicts.
|
||||||
use imgui_glfw_rs::imgui;
|
use imgui_glfw_rs::imgui;
|
||||||
use imgui_inspect_derive::Inspect;
|
|
||||||
use imgui_inspect::InspectArgsStruct;
|
|
||||||
use imgui_inspect::InspectArgsSlider;
|
|
||||||
|
|
||||||
use imgui_glfw_rs::ImguiGLFW;
|
use imgui_glfw_rs::ImguiGLFW;
|
||||||
use self::camera::*;
|
use imgui_inspect::InspectArgsStruct;
|
||||||
use self::gl::types::*;
|
use self::gl::types::*;
|
||||||
use imgui_glfw_rs::glfw::{Action, Context, Key};
|
use imgui_glfw_rs::glfw::{Action, Context, Key};
|
||||||
use cgmath::prelude::*;
|
use cgmath::prelude::*;
|
||||||
use cgmath::{perspective, vec3, Deg, Matrix4, Point3, Rad, Vector3};
|
use cgmath::{perspective, vec3, Deg, Matrix4, Point3, Rad, Vector3};
|
||||||
use human_panic::setup_panic;
|
use human_panic::setup_panic;
|
||||||
mod camera;
|
|
||||||
mod consts;
|
|
||||||
mod engine;
|
|
||||||
mod macros;
|
|
||||||
mod shader;
|
|
||||||
mod model;
|
|
||||||
mod mesh;
|
|
||||||
|
|
||||||
#[derive(Inspect)]
|
#[macro_use]
|
||||||
pub struct BgInfo {
|
mod gaia;
|
||||||
#[inspect_slider(min_value = 0.0, max_value = 1.0)]
|
use crate::gaia::camera::*;
|
||||||
pub r : f32,
|
use crate::gaia::*;
|
||||||
#[inspect_slider(min_value = 0.0, max_value = 1.0)]
|
use crate::gaia::bg_info::BgInfo;
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
setup_panic!();
|
setup_panic!();
|
||||||
|
|
@ -275,4 +251,5 @@ pub fn process_input(window: &mut glfw::Window, delta_time: f32, camera: &mut Ca
|
||||||
if window.get_key(Key::D) == Action::Press {
|
if window.get_key(Key::D) == Action::Press {
|
||||||
camera.process_keyboard(Camera_Movement::RIGHT, delta_time);
|
camera.process_keyboard(Camera_Movement::RIGHT, delta_time);
|
||||||
}
|
}
|
||||||
|
camera.enable_mouse_movement(window.get_key(Key::LeftControl) != Action::Press);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue