mirror of https://github.com/Leinnan/doppler.git
Working build without input
This commit is contained in:
parent
965f7dc96c
commit
d6d50fb445
File diff suppressed because it is too large
Load Diff
|
|
@ -21,11 +21,12 @@ 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"] }
|
||||||
|
glutin = "0.24.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["imgui_inspect"]
|
default = []
|
||||||
imgui_inspect = ["imgui-inspect-derive", "imgui-inspect", "imgui-glfw-rs"]
|
imgui_inspect = ["imgui-inspect-derive", "imgui-inspect", "imgui-glfw-rs"]
|
||||||
no_imgui = ["glfw"]
|
glfw_obsolete = ["glfw"]
|
||||||
|
|
||||||
[profile.dev.package."*"]
|
[profile.dev.package."*"]
|
||||||
opt-level = 2
|
opt-level = 2
|
||||||
|
|
@ -9,7 +9,7 @@ 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")]
|
#[cfg(feature = "glfw_obsolete")]
|
||||||
use glfw;
|
use glfw;
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
use imgui_glfw_rs::glfw;
|
use imgui_glfw_rs::glfw;
|
||||||
|
|
@ -27,7 +27,7 @@ pub struct ExampleClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExampleClient {
|
impl ExampleClient {
|
||||||
pub fn create(_window: &glfw::Window) -> ExampleClient {
|
pub fn create() -> ExampleClient {
|
||||||
let sky = unsafe { Sky::new() };
|
let sky = unsafe { Sky::new() };
|
||||||
ExampleClient {
|
ExampleClient {
|
||||||
models: vec![],
|
models: vec![],
|
||||||
|
|
@ -128,6 +128,8 @@ impl Client for ExampleClient {
|
||||||
}
|
}
|
||||||
fn update(&mut self, _engine: &mut Engine) {}
|
fn update(&mut self, _engine: &mut Engine) {}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(feature="glfw_obsolete")]
|
||||||
fn process_input(&mut self, window: &glfw::Window, delta: f32) {
|
fn process_input(&mut self, window: &glfw::Window, delta: f32) {
|
||||||
use glfw::{Action, Key};
|
use glfw::{Action, Key};
|
||||||
if window.get_key(Key::W) == Action::Press {
|
if window.get_key(Key::W) == Action::Press {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
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")]
|
#[cfg(feature = "glfw_obsolete")]
|
||||||
use glfw;
|
use glfw;
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
use imgui_glfw_rs::glfw;
|
use imgui_glfw_rs::glfw;
|
||||||
|
|
@ -8,6 +8,7 @@ use imgui_glfw_rs::glfw;
|
||||||
pub trait Client {
|
pub trait Client {
|
||||||
fn load_assets(&mut self, cache: &mut AssetsCache);
|
fn load_assets(&mut self, cache: &mut AssetsCache);
|
||||||
fn update(&mut self, engine: &mut Engine);
|
fn update(&mut self, engine: &mut Engine);
|
||||||
|
#[cfg(feature="glfw_obsolete")]
|
||||||
fn process_input(&mut self, window: &glfw::Window, delta: f32);
|
fn process_input(&mut self, window: &glfw::Window, delta: f32);
|
||||||
fn on_mouse_scroll(&mut self, yoffset: f32);
|
fn on_mouse_scroll(&mut self, yoffset: f32);
|
||||||
fn on_mouse_move(&mut self, x: f32, y: f32);
|
fn on_mouse_move(&mut self, x: f32, y: f32);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ 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")]
|
#[cfg(feature = "glfw_obsolete")]
|
||||||
use glfw;
|
use glfw;
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
use imgui_glfw_rs::glfw;
|
use imgui_glfw_rs::glfw;
|
||||||
|
|
@ -14,15 +14,95 @@ use imgui_glfw_rs::imgui;
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
use imgui_glfw_rs::ImguiGLFW;
|
use imgui_glfw_rs::ImguiGLFW;
|
||||||
|
|
||||||
use glfw::{Action, Context, Key};
|
|
||||||
use log::{info, trace, warn};
|
use log::{info, trace, warn};
|
||||||
|
|
||||||
|
#[cfg(not(feature="glfw_obsolete"))]
|
||||||
|
pub struct Engine {
|
||||||
|
title: String,
|
||||||
|
size: (i32,i32),
|
||||||
|
debug_layer: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature="glfw_obsolete"))]
|
||||||
|
impl Default for Engine {
|
||||||
|
fn default() -> Self {
|
||||||
|
Engine{
|
||||||
|
title: String::from("Doppler demo"),
|
||||||
|
size: (1280, 720),
|
||||||
|
debug_layer: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature="glfw_obsolete"))]
|
||||||
|
impl Engine {
|
||||||
|
pub fn run(&self) {
|
||||||
|
let event_loop = glutin::event_loop::EventLoop::new();
|
||||||
|
let window = glutin::window::WindowBuilder::new().with_title(&self.title)
|
||||||
|
.with_inner_size(glutin::dpi::LogicalSize::new(self.size.0 as f32, self.size.1 as f32));
|
||||||
|
let gl_window = glutin::ContextBuilder::new()
|
||||||
|
.build_windowed(window, &event_loop)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let gl_window = unsafe { gl_window.make_current().unwrap() };
|
||||||
|
gl::load_with(|symbol| gl_window.get_proc_address(symbol));
|
||||||
|
// configure global opengl state
|
||||||
|
// -----------------------------
|
||||||
|
unsafe {
|
||||||
|
gl::Enable(gl::DEPTH_TEST);
|
||||||
|
}
|
||||||
|
let mut client = ExampleClient::create();
|
||||||
|
let mut framebuffer = unsafe { FramebufferSystem::generate(1024, 768) };
|
||||||
|
let mut camera = Camera {
|
||||||
|
position: Point3::new(0.0, 0.0, 3.0),
|
||||||
|
..Camera::default()
|
||||||
|
};
|
||||||
|
let mut assets_cache = AssetsCache::default();
|
||||||
|
client.load_assets(&mut assets_cache);
|
||||||
|
let mut first_mouse = true;
|
||||||
|
let mut last_x: f32 = consts::SCR_WIDTH as f32 / 2.0;
|
||||||
|
let mut last_y: f32 = consts::SCR_HEIGHT as f32 / 2.0;
|
||||||
|
|
||||||
|
// timing
|
||||||
|
let mut delta_time: f32; // time between current frame and last frame
|
||||||
|
let mut last_frame: f32 = 0.0;
|
||||||
|
|
||||||
|
|
||||||
|
event_loop.run(move |event, _, control_flow| {
|
||||||
|
use glutin::event::{Event, WindowEvent};
|
||||||
|
use glutin::event_loop::ControlFlow;
|
||||||
|
*control_flow = ControlFlow::Poll;
|
||||||
|
match event {
|
||||||
|
Event::LoopDestroyed => return,
|
||||||
|
Event::WindowEvent { event, .. } => match event {
|
||||||
|
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
|
||||||
|
WindowEvent::Resized(size) => {
|
||||||
|
info!("Resizing!");
|
||||||
|
unsafe { gl::Viewport(0, 0, size.width as i32, size.height as i32) }
|
||||||
|
let window_size = (size.width as f32, size.height as f32);
|
||||||
|
framebuffer = unsafe { FramebufferSystem::generate(size.width as i32, size.height as i32) };
|
||||||
|
},
|
||||||
|
_ => (),
|
||||||
|
},
|
||||||
|
Event::RedrawRequested(_) => {
|
||||||
|
unsafe {
|
||||||
|
framebuffer.clear();
|
||||||
|
client.draw();
|
||||||
|
framebuffer.draw();
|
||||||
|
}
|
||||||
|
gl_window.swap_buffers().unwrap();
|
||||||
|
},
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature="glfw_obsolete")]
|
||||||
pub struct Engine {
|
pub struct Engine {
|
||||||
pub camera: Camera,
|
pub camera: Camera,
|
||||||
pub window: glfw::Window,
|
pub ctx_wrapper: glutin::ContextWrapper<glutin::PossiblyCurrent, glutin::window::Window>,
|
||||||
pub window_size: (f32, f32),
|
pub window_size: (f32, f32),
|
||||||
pub events: std::sync::mpsc::Receiver<(f64, glfw::WindowEvent)>,
|
|
||||||
pub glfw: glfw::Glfw,
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
pub imgui: imgui::Context,
|
pub imgui: imgui::Context,
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
|
|
@ -33,6 +113,7 @@ pub struct Engine {
|
||||||
framebuffer: FramebufferSystem,
|
framebuffer: FramebufferSystem,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature="glfw_obsolete")]
|
||||||
impl Engine {
|
impl Engine {
|
||||||
pub fn run(&mut self) {
|
pub fn run(&mut self) {
|
||||||
self.client.load_assets(&mut self.assets_cache);
|
self.client.load_assets(&mut self.assets_cache);
|
||||||
|
|
@ -57,7 +138,7 @@ impl Engine {
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[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")]
|
#[cfg(not(feature = "imgui_inspect"))]
|
||||||
let skip_input = false;
|
let skip_input = false;
|
||||||
if !skip_input {
|
if !skip_input {
|
||||||
self.process_input(delta_time);
|
self.process_input(delta_time);
|
||||||
|
|
@ -202,40 +283,41 @@ impl Engine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature="glfw_obsolete")]
|
||||||
impl Default for Engine {
|
impl Default for Engine {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
// glfw: initialize and configure
|
// // glfw: initialize and configure
|
||||||
// ------------------------------
|
// // ------------------------------
|
||||||
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
|
// let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
|
||||||
glfw.window_hint(glfw::WindowHint::ContextVersion(3, 3));
|
// glfw.window_hint(glfw::WindowHint::ContextVersion(3, 3));
|
||||||
glfw.window_hint(glfw::WindowHint::OpenGlProfile(
|
// glfw.window_hint(glfw::WindowHint::OpenGlProfile(
|
||||||
glfw::OpenGlProfileHint::Core,
|
// glfw::OpenGlProfileHint::Core,
|
||||||
));
|
// ));
|
||||||
#[cfg(target_os = "macos")]
|
// #[cfg(target_os = "macos")]
|
||||||
glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true));
|
// glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true));
|
||||||
|
|
||||||
// glfw window creation
|
// glfw window creation
|
||||||
// --------------------
|
// --------------------
|
||||||
let (mut window, events) = glfw
|
// let (mut window, events) = glfw
|
||||||
.create_window(
|
// .create_window(
|
||||||
consts::SCR_WIDTH,
|
// consts::SCR_WIDTH,
|
||||||
consts::SCR_HEIGHT,
|
// consts::SCR_HEIGHT,
|
||||||
"chRustedGL",
|
// "chRustedGL",
|
||||||
glfw::WindowMode::Windowed,
|
// glfw::WindowMode::Windowed,
|
||||||
)
|
// )
|
||||||
.expect("Failed to create GLFW window");
|
// .expect("Failed to create GLFW window");
|
||||||
|
|
||||||
window.make_current();
|
// window.make_current();
|
||||||
window.set_all_polling(true);
|
// window.set_all_polling(true);
|
||||||
window.set_framebuffer_size_polling(true);
|
// window.set_framebuffer_size_polling(true);
|
||||||
window.set_cursor_pos_polling(true);
|
// window.set_cursor_pos_polling(true);
|
||||||
window.set_scroll_polling(true);
|
// window.set_scroll_polling(true);
|
||||||
|
|
||||||
// tell GLFW to capture our mouse
|
// // tell GLFW to capture our mouse
|
||||||
window.set_cursor_mode(glfw::CursorMode::Disabled);
|
// window.set_cursor_mode(glfw::CursorMode::Disabled);
|
||||||
// gl: load all OpenGL function pointers
|
// // gl: load all OpenGL function pointers
|
||||||
// ---------------------------------------
|
// // ---------------------------------------
|
||||||
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")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
let mut imgui = imgui::Context::create();
|
let mut imgui = imgui::Context::create();
|
||||||
|
|
@ -311,15 +393,13 @@ impl Default for Engine {
|
||||||
unsafe {
|
unsafe {
|
||||||
gl::Enable(gl::DEPTH_TEST);
|
gl::Enable(gl::DEPTH_TEST);
|
||||||
}
|
}
|
||||||
let client = ExampleClient::create(&window);
|
let client = ExampleClient::create();
|
||||||
let (scr_width, scr_height) = window.get_framebuffer_size();
|
let fb = unsafe { FramebufferSystem::generate(1024, 768) };
|
||||||
let fb = unsafe { FramebufferSystem::generate(scr_width, scr_height) };
|
|
||||||
|
|
||||||
Engine {
|
Engine {
|
||||||
window: window,
|
ctx_wrapper: gl_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: event_loop,
|
||||||
glfw: glfw,
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
imgui: imgui,
|
imgui: imgui,
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
extern crate gl;
|
extern crate gl;
|
||||||
|
extern crate glutin;
|
||||||
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
extern crate imgui_glfw_rs;
|
extern crate imgui_glfw_rs;
|
||||||
|
|
@ -12,12 +13,10 @@ mod gaia;
|
||||||
mod example_client;
|
mod example_client;
|
||||||
|
|
||||||
use crate::gaia::engine::Engine;
|
use crate::gaia::engine::Engine;
|
||||||
// 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!();
|
|
||||||
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();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue