mirror of https://github.com/Leinnan/doppler.git
Remove glfw
This commit is contained in:
parent
e17f957009
commit
d19a021cf6
|
|
@ -117,15 +117,6 @@ dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cmake"
|
|
||||||
version = "0.1.44"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0e56268c17a6248366d66d4a47a3381369d068cce8409bb1716ed77ea32163bb"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cocoa"
|
name = "cocoa"
|
||||||
version = "0.20.2"
|
version = "0.20.2"
|
||||||
|
|
@ -249,7 +240,6 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cgmath",
|
"cgmath",
|
||||||
"gl",
|
"gl",
|
||||||
"glfw",
|
|
||||||
"glutin",
|
"glutin",
|
||||||
"image2",
|
"image2",
|
||||||
"imgui",
|
"imgui",
|
||||||
|
|
@ -343,30 +333,6 @@ dependencies = [
|
||||||
"xml-rs 0.8.3",
|
"xml-rs 0.8.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glfw"
|
|
||||||
version = "0.40.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "985f851b0d032911e199f308689d25c71f79d12c44625c3a31b683ad4e4f5dd9"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"glfw-sys",
|
|
||||||
"log",
|
|
||||||
"objc",
|
|
||||||
"raw-window-handle",
|
|
||||||
"semver",
|
|
||||||
"winapi 0.3.9",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "glfw-sys"
|
|
||||||
version = "3.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0b567b13b593ec58ea912b2658ee6230ffe20a069fa5b771800acc69bb3a157e"
|
|
||||||
dependencies = [
|
|
||||||
"cmake",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glutin"
|
name = "glutin"
|
||||||
version = "0.24.1"
|
version = "0.24.1"
|
||||||
|
|
@ -1132,21 +1098,6 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
|
||||||
dependencies = [
|
|
||||||
"semver-parser",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver-parser"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.116"
|
version = "1.0.116"
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,6 @@ gl = "0.14.0"
|
||||||
imgui="0.4"
|
imgui="0.4"
|
||||||
imgui-winit-support = {version="0.4.0", optional=true}
|
imgui-winit-support = {version="0.4.0", optional=true}
|
||||||
imgui-opengl-renderer = {version="0.8", optional = true}
|
imgui-opengl-renderer = {version="0.8", optional = true}
|
||||||
# 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 = {version="0.5.0", optional = true}
|
imgui-inspect = {version="0.5.0", optional = true}
|
||||||
imgui-inspect-derive = {version="0.5.0", optional= true}
|
imgui-inspect-derive = {version="0.5.0", optional= true}
|
||||||
|
|
@ -29,7 +27,6 @@ glutin = "0.24.1"
|
||||||
[features]
|
[features]
|
||||||
default = ["imgui_inspect"]
|
default = ["imgui_inspect"]
|
||||||
imgui_inspect = ["imgui-inspect-derive","imgui-opengl-renderer", "imgui-inspect", "imgui-winit-support"]
|
imgui_inspect = ["imgui-inspect-derive","imgui-opengl-renderer", "imgui-inspect", "imgui-winit-support"]
|
||||||
glfw_obsolete = ["glfw"]
|
|
||||||
|
|
||||||
[profile.dev.package."*"]
|
[profile.dev.package."*"]
|
||||||
opt-level = 2
|
opt-level = 2
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
use crate::gaia::mesh::Texture;
|
use crate::gaia::mesh::Texture;
|
||||||
use crate::gaia::model::Model;
|
use crate::gaia::model::Model;
|
||||||
use crate::gaia::utils::load_texture_from_dir;
|
use crate::gaia::utils::load_texture_from_dir;
|
||||||
use log::{info, trace, warn};
|
use log::info;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct AssetsCache {
|
pub struct AssetsCache {
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
use glutin::event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent};
|
use glutin::event::{ElementState, VirtualKeyCode};
|
||||||
|
|
||||||
pub trait Client {
|
pub trait Client {
|
||||||
fn load_assets(&mut self, cache: &mut AssetsCache);
|
fn load_assets(&mut self, cache: &mut AssetsCache);
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,16 @@
|
||||||
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::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 glutin::event::{Event, KeyboardInput, VirtualKeyCode, WindowEvent};
|
||||||
use glutin::event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent};
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
use imgui::Context;
|
use imgui::Context;
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
use imgui_winit_support::{HiDpiMode, WinitPlatform};
|
use imgui_winit_support::{HiDpiMode, WinitPlatform};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use log::{info, trace, warn};
|
use log::info;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TimeStep {
|
pub struct TimeStep {
|
||||||
|
|
@ -56,14 +54,12 @@ impl TimeStep {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "glfw_obsolete"))]
|
|
||||||
pub struct Engine {
|
pub struct Engine {
|
||||||
title: String,
|
title: String,
|
||||||
size: (i32, i32),
|
size: (i32, i32),
|
||||||
debug_layer: bool,
|
debug_layer: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "glfw_obsolete"))]
|
|
||||||
impl Default for Engine {
|
impl Default for Engine {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Engine {
|
Engine {
|
||||||
|
|
@ -74,7 +70,6 @@ impl Default for Engine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "glfw_obsolete"))]
|
|
||||||
impl Engine {
|
impl Engine {
|
||||||
pub fn run(self) {
|
pub fn run(self) {
|
||||||
let event_loop = glutin::event_loop::EventLoop::new();
|
let event_loop = glutin::event_loop::EventLoop::new();
|
||||||
|
|
@ -209,8 +204,10 @@ impl Engine {
|
||||||
WindowEvent::MouseWheel { delta, .. } => {
|
WindowEvent::MouseWheel { delta, .. } => {
|
||||||
use glutin::event::MouseScrollDelta;
|
use glutin::event::MouseScrollDelta;
|
||||||
match delta {
|
match delta {
|
||||||
MouseScrollDelta::LineDelta(x, y) => client.on_mouse_scroll(y),
|
MouseScrollDelta::LineDelta(_, y) => client.on_mouse_scroll(y),
|
||||||
MouseScrollDelta::PixelDelta(pos) => client.on_mouse_scroll(pos.y as f32),
|
MouseScrollDelta::PixelDelta(pos) => {
|
||||||
|
client.on_mouse_scroll(pos.y as f32)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WindowEvent::CursorMoved { position, .. } => {
|
WindowEvent::CursorMoved { position, .. } => {
|
||||||
|
|
@ -325,7 +322,6 @@ impl Engine {
|
||||||
});
|
});
|
||||||
platform.prepare_render(&ui, &gl_window.window());
|
platform.prepare_render(&ui, &gl_window.window());
|
||||||
renderer.render(ui);
|
renderer.render(ui);
|
||||||
// let draw_data = ui.render();
|
|
||||||
}
|
}
|
||||||
gl_window.swap_buffers().unwrap();
|
gl_window.swap_buffers().unwrap();
|
||||||
}
|
}
|
||||||
|
|
@ -334,321 +330,3 @@ impl Engine {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "glfw_obsolete")]
|
|
||||||
pub struct Engine {
|
|
||||||
pub camera: Camera,
|
|
||||||
pub ctx_wrapper: glutin::ContextWrapper<glutin::PossiblyCurrent, glutin::window::Window>,
|
|
||||||
pub window_size: (f32, f32),
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
|
||||||
pub imgui: imgui::Context,
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
|
||||||
pub imgui_glfw: ImguiGLFW,
|
|
||||||
pub client: Box<dyn Client>,
|
|
||||||
enable_debug_layer: bool,
|
|
||||||
assets_cache: AssetsCache,
|
|
||||||
framebuffer: FramebufferSystem,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "glfw_obsolete")]
|
|
||||||
impl Engine {
|
|
||||||
pub fn run(&mut self) {
|
|
||||||
self.client.load_assets(&mut self.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;
|
|
||||||
// render loop
|
|
||||||
// -----------
|
|
||||||
while !self.window.should_close() {
|
|
||||||
// per-frame time logic
|
|
||||||
// --------------------
|
|
||||||
let cur_frame = self.glfw.get_time() as f32;
|
|
||||||
delta_time = cur_frame - last_frame;
|
|
||||||
last_frame = cur_frame;
|
|
||||||
|
|
||||||
// input
|
|
||||||
// -----
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
|
||||||
let skip_input =
|
|
||||||
self.imgui.io().want_capture_mouse || self.imgui.io().want_capture_keyboard;
|
|
||||||
#[cfg(not(feature = "imgui_inspect"))]
|
|
||||||
let skip_input = false;
|
|
||||||
if !skip_input {
|
|
||||||
self.process_input(delta_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
// render
|
|
||||||
// ------
|
|
||||||
unsafe {
|
|
||||||
self.framebuffer.clear();
|
|
||||||
self.client.draw();
|
|
||||||
self.framebuffer.draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
|
|
||||||
// -------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
|
||||||
if self.enable_debug_layer {
|
|
||||||
let ui = self.imgui_glfw.frame(&mut self.window, &mut self.imgui);
|
|
||||||
self.client.debug_draw(&ui);
|
|
||||||
use imgui::*;
|
|
||||||
let fps = 1.0 / delta_time;
|
|
||||||
let size = [250.0, 110.0];
|
|
||||||
let offset = 20.0;
|
|
||||||
Window::new(im_str!("EngineInfo"))
|
|
||||||
.size(size, Condition::Always)
|
|
||||||
.position(
|
|
||||||
[
|
|
||||||
self.window_size.0 - size[0] - offset,
|
|
||||||
self.window_size.1 - size[1] - offset,
|
|
||||||
],
|
|
||||||
Condition::Always,
|
|
||||||
)
|
|
||||||
.no_decoration()
|
|
||||||
.no_inputs()
|
|
||||||
.bg_alpha(0.8)
|
|
||||||
.save_settings(false)
|
|
||||||
.build(&ui, || {
|
|
||||||
ui.text("Welcome in doppler world!");
|
|
||||||
ui.text(format!("FPS: {:.0}", fps));
|
|
||||||
ui.separator();
|
|
||||||
ui.text(format!("Mouse position: ({:4.1},{:4.1})", last_x, last_y));
|
|
||||||
});
|
|
||||||
Window::new(im_str!("Logs"))
|
|
||||||
.size([670.0, 215.0], Condition::Always)
|
|
||||||
.bg_alpha(0.8)
|
|
||||||
.position(
|
|
||||||
[offset, self.window_size.1 - 215.0 - offset],
|
|
||||||
Condition::Always,
|
|
||||||
)
|
|
||||||
.no_decoration()
|
|
||||||
.no_inputs()
|
|
||||||
.bg_alpha(0.8)
|
|
||||||
.save_settings(false)
|
|
||||||
.build(&ui, || {
|
|
||||||
use std::fs;
|
|
||||||
use std::io::prelude::*;
|
|
||||||
use std::io::BufReader;
|
|
||||||
let buf = BufReader::new(fs::File::open("log.log").expect("no such file"));
|
|
||||||
let lines: Vec<String> = buf
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.expect("Could not parse line"))
|
|
||||||
.collect();
|
|
||||||
let mut output = String::new();
|
|
||||||
lines.iter().rev().take(10).rev().for_each(|line| {
|
|
||||||
output.push_str(&line);
|
|
||||||
output.push('\n');
|
|
||||||
});
|
|
||||||
|
|
||||||
ui.text(output);
|
|
||||||
});
|
|
||||||
self.imgui_glfw.draw(ui, &mut self.window);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.window.swap_buffers();
|
|
||||||
self.glfw.poll_events();
|
|
||||||
// events
|
|
||||||
// -----
|
|
||||||
self.process_events(&mut first_mouse, &mut last_x, &mut last_y, skip_input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn process_input(&mut self, delta_time: f32) {
|
|
||||||
if self.window.get_key(Key::Escape) == Action::Press {
|
|
||||||
self.window.set_should_close(true)
|
|
||||||
}
|
|
||||||
if self.window.get_key(Key::P) == Action::Press
|
|
||||||
&& self.window.get_key(Key::LeftShift) == Action::Press
|
|
||||||
{
|
|
||||||
self.enable_debug_layer = !self.enable_debug_layer;
|
|
||||||
}
|
|
||||||
self.client.process_input(&self.window, delta_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn process_events(
|
|
||||||
&mut self,
|
|
||||||
first_mouse: &mut bool,
|
|
||||||
last_x: &mut f32,
|
|
||||||
last_y: &mut f32,
|
|
||||||
skip_input: bool,
|
|
||||||
) {
|
|
||||||
for (_, event) in glfw::flush_messages(&self.events) {
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
|
||||||
self.imgui_glfw.handle_event(&mut self.imgui, &event);
|
|
||||||
|
|
||||||
match event {
|
|
||||||
glfw::WindowEvent::FramebufferSize(width, height) => {
|
|
||||||
// make sure the viewport matches the new window dimensions; note that width and
|
|
||||||
// height will be significantly larger than specified on retina displays.
|
|
||||||
unsafe { gl::Viewport(0, 0, width, height) }
|
|
||||||
self.window_size = (width as f32, height as f32);
|
|
||||||
self.framebuffer = unsafe { FramebufferSystem::generate(width, height) };
|
|
||||||
}
|
|
||||||
glfw::WindowEvent::CursorPos(xpos, ypos) => {
|
|
||||||
if skip_input {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let (xpos, ypos) = (xpos as f32, ypos as f32);
|
|
||||||
if *first_mouse {
|
|
||||||
*last_x = xpos;
|
|
||||||
*last_y = ypos;
|
|
||||||
*first_mouse = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let xoffset = xpos - *last_x;
|
|
||||||
let yoffset = *last_y - ypos; // reversed since y-coordinates go from bottom to top
|
|
||||||
|
|
||||||
*last_x = xpos;
|
|
||||||
*last_y = ypos;
|
|
||||||
|
|
||||||
self.client.on_mouse_move(xoffset, yoffset);
|
|
||||||
}
|
|
||||||
glfw::WindowEvent::Scroll(_xoffset, yoffset) => {
|
|
||||||
if skip_input {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.client.on_mouse_scroll(yoffset as f32);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "glfw_obsolete")]
|
|
||||||
impl Default for Engine {
|
|
||||||
fn default() -> Self {
|
|
||||||
// // glfw: initialize and configure
|
|
||||||
// // ------------------------------
|
|
||||||
// let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
|
|
||||||
// glfw.window_hint(glfw::WindowHint::ContextVersion(3, 3));
|
|
||||||
// glfw.window_hint(glfw::WindowHint::OpenGlProfile(
|
|
||||||
// glfw::OpenGlProfileHint::Core,
|
|
||||||
// ));
|
|
||||||
// #[cfg(target_os = "macos")]
|
|
||||||
// glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true));
|
|
||||||
|
|
||||||
// glfw window creation
|
|
||||||
// --------------------
|
|
||||||
// let (mut window, events) = glfw
|
|
||||||
// .create_window(
|
|
||||||
// consts::SCR_WIDTH,
|
|
||||||
// consts::SCR_HEIGHT,
|
|
||||||
// "chRustedGL",
|
|
||||||
// glfw::WindowMode::Windowed,
|
|
||||||
// )
|
|
||||||
// .expect("Failed to create GLFW window");
|
|
||||||
|
|
||||||
// window.make_current();
|
|
||||||
// window.set_all_polling(true);
|
|
||||||
// window.set_framebuffer_size_polling(true);
|
|
||||||
// window.set_cursor_pos_polling(true);
|
|
||||||
// window.set_scroll_polling(true);
|
|
||||||
|
|
||||||
// // tell GLFW to capture our mouse
|
|
||||||
// window.set_cursor_mode(glfw::CursorMode::Disabled);
|
|
||||||
// // gl: load all OpenGL function pointers
|
|
||||||
// // ---------------------------------------
|
|
||||||
// gl::load_with(|symbol| window.get_proc_address(symbol) as *const _);
|
|
||||||
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
|
||||||
let mut imgui = imgui::Context::create();
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
|
||||||
{
|
|
||||||
use imgui_glfw_rs::imgui::FontSource;
|
|
||||||
use imgui_glfw_rs::imgui::StyleColor;
|
|
||||||
let mut style = imgui.style_mut();
|
|
||||||
style.scale_all_sizes(1.5);
|
|
||||||
style[StyleColor::Text] = [1.0, 1.0, 1.0, 1.0];
|
|
||||||
style[StyleColor::TextDisabled] = [0.5, 0.5, 0.5, 1.0];
|
|
||||||
style[StyleColor::WindowBg] = [0.13, 0.14, 0.15, 1.0];
|
|
||||||
style[StyleColor::ChildBg] = [0.13, 0.14, 0.15, 1.0];
|
|
||||||
style[StyleColor::PopupBg] = [0.13, 0.14, 0.15, 1.0];
|
|
||||||
style[StyleColor::Border] = [0.43, 0.43, 0.50, 0.50];
|
|
||||||
style[StyleColor::BorderShadow] = [0.00, 0.00, 0.00, 0.00];
|
|
||||||
style[StyleColor::FrameBg] = [0.25, 0.25, 0.25, 1.00];
|
|
||||||
style[StyleColor::FrameBgHovered] = [0.38, 0.38, 0.38, 1.00];
|
|
||||||
style[StyleColor::FrameBgActive] = [0.67, 0.67, 0.67, 0.39];
|
|
||||||
style[StyleColor::TitleBg] = [0.08, 0.08, 0.09, 1.00];
|
|
||||||
style[StyleColor::TitleBgActive] = [0.08, 0.08, 0.09, 1.00];
|
|
||||||
style[StyleColor::TitleBgCollapsed] = [0.00, 0.00, 0.00, 0.51];
|
|
||||||
style[StyleColor::MenuBarBg] = [0.14, 0.14, 0.14, 1.00];
|
|
||||||
style[StyleColor::ScrollbarBg] = [0.02, 0.02, 0.02, 0.53];
|
|
||||||
style[StyleColor::ScrollbarGrab] = [0.31, 0.31, 0.31, 1.00];
|
|
||||||
style[StyleColor::ScrollbarGrabHovered] = [0.41, 0.41, 0.41, 1.00];
|
|
||||||
style[StyleColor::ScrollbarGrabActive] = [0.51, 0.51, 0.51, 1.00];
|
|
||||||
style[StyleColor::CheckMark] = [0.11, 0.64, 0.92, 1.00];
|
|
||||||
style[StyleColor::SliderGrab] = [0.11, 0.64, 0.92, 1.00];
|
|
||||||
style[StyleColor::SliderGrabActive] = [0.08, 0.50, 0.72, 1.00];
|
|
||||||
style[StyleColor::Button] = [0.25, 0.25, 0.25, 1.00];
|
|
||||||
style[StyleColor::ButtonHovered] = [0.38, 0.38, 0.38, 1.00];
|
|
||||||
style[StyleColor::ButtonActive] = [0.67, 0.67, 0.67, 0.39];
|
|
||||||
style[StyleColor::Header] = [0.22, 0.22, 0.22, 1.00];
|
|
||||||
style[StyleColor::HeaderHovered] = [0.25, 0.25, 0.25, 1.00];
|
|
||||||
style[StyleColor::HeaderActive] = [0.67, 0.67, 0.67, 0.39];
|
|
||||||
style[StyleColor::Separator] = style[StyleColor::Border];
|
|
||||||
style[StyleColor::SeparatorHovered] = [0.41, 0.42, 0.44, 1.00];
|
|
||||||
style[StyleColor::SeparatorActive] = [0.26, 0.59, 0.98, 0.95];
|
|
||||||
style[StyleColor::ResizeGrip] = [0.00, 0.00, 0.00, 0.00];
|
|
||||||
style[StyleColor::ResizeGripHovered] = [0.29, 0.30, 0.31, 0.67];
|
|
||||||
style[StyleColor::ResizeGripActive] = [0.26, 0.59, 0.98, 0.95];
|
|
||||||
style[StyleColor::Tab] = [0.08, 0.08, 0.09, 0.83];
|
|
||||||
style[StyleColor::TabHovered] = [0.33, 0.34, 0.36, 0.83];
|
|
||||||
style[StyleColor::TabActive] = [0.23, 0.23, 0.24, 1.00];
|
|
||||||
style[StyleColor::TabUnfocused] = [0.08, 0.08, 0.09, 1.00];
|
|
||||||
style[StyleColor::TabUnfocusedActive] = [0.13, 0.14, 0.15, 1.00];
|
|
||||||
// style[StyleColor::DockingPreview] = [0.26, 0.59, 0.98, 0.70];
|
|
||||||
// style[StyleColor::DockingEmptyBg] = [0.20, 0.20, 0.20, 1.00];
|
|
||||||
style[StyleColor::PlotLines] = [0.61, 0.61, 0.61, 1.00];
|
|
||||||
style[StyleColor::PlotLinesHovered] = [1.00, 0.43, 0.35, 1.00];
|
|
||||||
style[StyleColor::PlotHistogram] = [0.90, 0.70, 0.00, 1.00];
|
|
||||||
style[StyleColor::PlotHistogramHovered] = [1.00, 0.60, 0.00, 1.00];
|
|
||||||
style[StyleColor::TextSelectedBg] = [0.26, 0.59, 0.98, 0.35];
|
|
||||||
style[StyleColor::DragDropTarget] = [0.11, 0.64, 0.92, 1.00];
|
|
||||||
style[StyleColor::NavHighlight] = [0.26, 0.59, 0.98, 1.00];
|
|
||||||
style[StyleColor::NavWindowingHighlight] = [1.00, 1.00, 1.00, 0.70];
|
|
||||||
style[StyleColor::NavWindowingDimBg] = [0.80, 0.80, 0.80, 0.20];
|
|
||||||
style[StyleColor::ModalWindowDimBg] = [0.80, 0.80, 0.80, 0.35];
|
|
||||||
style.grab_rounding = 2.3;
|
|
||||||
style.frame_rounding = style.grab_rounding;
|
|
||||||
imgui.fonts().clear();
|
|
||||||
imgui.fonts().add_font(&[FontSource::TtfData {
|
|
||||||
data: include_bytes!("../../resources/FiraSans-SemiBold.ttf"),
|
|
||||||
size_pixels: 19.0,
|
|
||||||
config: None,
|
|
||||||
}]);
|
|
||||||
}
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
|
||||||
let imgui_glfw = ImguiGLFW::new(&mut imgui, &mut window);
|
|
||||||
// configure global opengl state
|
|
||||||
// -----------------------------
|
|
||||||
unsafe {
|
|
||||||
gl::Enable(gl::DEPTH_TEST);
|
|
||||||
}
|
|
||||||
let client = ExampleClient::create();
|
|
||||||
let fb = unsafe { FramebufferSystem::generate(1024, 768) };
|
|
||||||
|
|
||||||
Engine {
|
|
||||||
ctx_wrapper: gl_window,
|
|
||||||
window_size: (consts::SCR_WIDTH as f32, consts::SCR_HEIGHT as f32),
|
|
||||||
events: event_loop,
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
|
||||||
imgui: imgui,
|
|
||||||
#[cfg(feature = "imgui_inspect")]
|
|
||||||
imgui_glfw: imgui_glfw,
|
|
||||||
framebuffer: fb,
|
|
||||||
camera: Camera {
|
|
||||||
position: Point3::new(0.0, 0.0, 3.0),
|
|
||||||
..Camera::default()
|
|
||||||
},
|
|
||||||
enable_debug_layer: true,
|
|
||||||
client: Box::new(client),
|
|
||||||
assets_cache: AssetsCache::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::gaia::shader::*;
|
use crate::gaia::shader::*;
|
||||||
use gl::types::*;
|
use gl::types::*;
|
||||||
use log::{info, trace, warn};
|
use log::{info, warn};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
@ -100,9 +100,9 @@ impl FramebufferSystem {
|
||||||
gl::GenFramebuffers(1, &mut framebuffer);
|
gl::GenFramebuffers(1, &mut framebuffer);
|
||||||
gl::BindFramebuffer(gl::FRAMEBUFFER, framebuffer);
|
gl::BindFramebuffer(gl::FRAMEBUFFER, framebuffer);
|
||||||
// create a color attachment texture
|
// create a color attachment texture
|
||||||
let mut textureColorbuffer = 0;
|
let mut texture_color_buffer = 0;
|
||||||
gl::GenTextures(1, &mut textureColorbuffer);
|
gl::GenTextures(1, &mut texture_color_buffer);
|
||||||
gl::BindTexture(gl::TEXTURE_2D, textureColorbuffer);
|
gl::BindTexture(gl::TEXTURE_2D, texture_color_buffer);
|
||||||
gl::TexImage2D(
|
gl::TexImage2D(
|
||||||
gl::TEXTURE_2D,
|
gl::TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
|
|
@ -120,7 +120,7 @@ impl FramebufferSystem {
|
||||||
gl::FRAMEBUFFER,
|
gl::FRAMEBUFFER,
|
||||||
gl::COLOR_ATTACHMENT0,
|
gl::COLOR_ATTACHMENT0,
|
||||||
gl::TEXTURE_2D,
|
gl::TEXTURE_2D,
|
||||||
textureColorbuffer,
|
texture_color_buffer,
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
// create a renderbuffer object for depth and stencil attachment (we won't be sampling these)
|
// create a renderbuffer object for depth and stencil attachment (we won't be sampling these)
|
||||||
|
|
@ -148,7 +148,7 @@ impl FramebufferSystem {
|
||||||
info!("New framebuffer generated");
|
info!("New framebuffer generated");
|
||||||
|
|
||||||
FramebufferSystem {
|
FramebufferSystem {
|
||||||
texture_color_buffer: textureColorbuffer,
|
texture_color_buffer: texture_color_buffer,
|
||||||
shader: shader,
|
shader: shader,
|
||||||
vao: quad_vao,
|
vao: quad_vao,
|
||||||
vbo: quad_vbo,
|
vbo: quad_vbo,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[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::{vec3, Matrix4, Vector3};
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
use imgui;
|
use imgui;
|
||||||
#[cfg(feature = "imgui_inspect")]
|
#[cfg(feature = "imgui_inspect")]
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,8 @@
|
||||||
use crate::gaia::assets_cache::AssetsCache;
|
use crate::gaia::assets_cache::AssetsCache;
|
||||||
use crate::gaia::mesh::{Mesh, Texture, Vertex};
|
use crate::gaia::mesh::{Mesh, Texture, Vertex};
|
||||||
use crate::gaia::shader::Shader;
|
use crate::gaia::shader::Shader;
|
||||||
use crate::gaia::utils::*;
|
|
||||||
use cgmath::{vec2, vec3};
|
use cgmath::{vec2, vec3};
|
||||||
use log::{info, trace, warn};
|
use log::{info, warn};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use tobj;
|
use tobj;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use gl;
|
use gl;
|
||||||
use image2::image::Image;
|
use image2::image::Image;
|
||||||
use image2::{io, ImagePtr, Rgb, Rgba};
|
use image2::{io, ImagePtr, Rgb, Rgba};
|
||||||
use log::{info, trace, warn};
|
use log::info;
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
pub unsafe fn load_texture(path: &str, file_format: &str) -> u32 {
|
pub unsafe fn load_texture(path: &str, file_format: &str) -> u32 {
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@ mod gaia;
|
||||||
mod example_client;
|
mod example_client;
|
||||||
|
|
||||||
use crate::gaia::engine::Engine;
|
use crate::gaia::engine::Engine;
|
||||||
|
use log::info;
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use log::{info, trace, warn};
|
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
simple_logging::log_to_file("log.log", LevelFilter::Info);
|
let _ = simple_logging::log_to_file("log.log", LevelFilter::Info);
|
||||||
info!("Starting engine!");
|
info!("Starting engine!");
|
||||||
let mut engine = Engine::default();
|
let engine = Engine::default();
|
||||||
|
|
||||||
engine.run();
|
engine.run();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue