mirror of https://github.com/Leinnan/doppler.git
Update deps
This commit is contained in:
parent
7b31a7eff1
commit
1cf71cec32
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
12
Cargo.toml
|
|
@ -6,23 +6,13 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gl = "0.14.0"
|
gl = "0.14.0"
|
||||||
imgui={version="0.7.0", optional=true}
|
|
||||||
imgui-winit-support = {version="0.7.0", optional=true}
|
|
||||||
imgui-opengl-renderer = {version="0.11.0", optional = true}
|
|
||||||
cgmath = {version="0.18.0", features=["serde"]}
|
cgmath = {version="0.18.0", features=["serde"]}
|
||||||
imgui-inspect = {version="0.8.0", optional = true}
|
|
||||||
imgui-inspect-derive = {version="0.8.0", optional= true}
|
|
||||||
tobj = "2.0.2"
|
tobj = "2.0.2"
|
||||||
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"] }
|
||||||
glutin = "0.26.0"
|
glutin = "0.28.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde_yaml = "0.8"
|
serde_yaml = "0.8"
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["imgui_inspect"]
|
|
||||||
imgui_inspect = ["imgui","imgui-inspect-derive","imgui-opengl-renderer", "imgui-inspect", "imgui-winit-support"]
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
use doppler::assets_cache::AssetsCache;
|
use doppler::assets_cache::AssetsCache;
|
||||||
use doppler::client::Client;
|
use doppler::client::Client;
|
||||||
|
use doppler::components::*;
|
||||||
use doppler::glutin::event::{ElementState, VirtualKeyCode};
|
use doppler::glutin::event::{ElementState, VirtualKeyCode};
|
||||||
use doppler::shader::Shader;
|
use doppler::shader::Shader;
|
||||||
use doppler::components::*;
|
|
||||||
|
|
||||||
pub struct Client2D {
|
pub struct Client2D {
|
||||||
delta: f32,
|
delta: f32,
|
||||||
models_2d: ModelComponent,
|
models_2d: ModelComponent,
|
||||||
shader: Shader
|
shader: Shader,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Client2D {
|
impl Default for Client2D {
|
||||||
|
|
@ -18,12 +18,11 @@ impl Default for Client2D {
|
||||||
shader: Shader::from_file(
|
shader: Shader::from_file(
|
||||||
"resources/shaders/multiple_lights.vs",
|
"resources/shaders/multiple_lights.vs",
|
||||||
"resources/shaders/multiple_lights.fs",
|
"resources/shaders/multiple_lights.fs",
|
||||||
)
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Client for Client2D {
|
impl Client for Client2D {
|
||||||
fn on_keyboard(&mut self, code: &VirtualKeyCode, state: &ElementState) {
|
fn on_keyboard(&mut self, code: &VirtualKeyCode, state: &ElementState) {
|
||||||
match (code, state) {
|
match (code, state) {
|
||||||
|
|
@ -55,14 +54,9 @@ impl Client for Client2D {
|
||||||
self.delta = delta;
|
self.delta = delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_draw(&mut self, _ui: &doppler::imgui::Ui) {
|
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) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
use doppler::assets_cache::AssetsCache;
|
use doppler::assets_cache::AssetsCache;
|
||||||
use doppler::camera::*;
|
use doppler::camera::*;
|
||||||
use doppler::client::Client;
|
use doppler::client::Client;
|
||||||
use doppler::components::Transform;
|
|
||||||
use doppler::glutin::event::{ElementState, VirtualKeyCode};
|
use doppler::glutin::event::{ElementState, VirtualKeyCode};
|
||||||
use doppler::imgui::*;
|
|
||||||
use doppler::light::*;
|
|
||||||
use doppler::map::*;
|
use doppler::map::*;
|
||||||
|
|
||||||
pub struct ExampleClient {
|
pub struct ExampleClient {
|
||||||
map: Map,
|
map: Map,
|
||||||
delta: f32,
|
delta: f32,
|
||||||
show_object_info: bool,
|
|
||||||
show_camera_info: bool,
|
|
||||||
imgui_grabs_input: bool,
|
|
||||||
object_info_id: i32,
|
|
||||||
show_light_info: bool,
|
|
||||||
light_info_id: i32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ExampleClient {
|
impl Default for ExampleClient {
|
||||||
|
|
@ -23,12 +14,6 @@ impl Default for ExampleClient {
|
||||||
ExampleClient {
|
ExampleClient {
|
||||||
delta: 0.0,
|
delta: 0.0,
|
||||||
map: Map::default(),
|
map: Map::default(),
|
||||||
object_info_id: 0,
|
|
||||||
show_camera_info: false,
|
|
||||||
show_object_info: false,
|
|
||||||
show_light_info: false,
|
|
||||||
imgui_grabs_input: false,
|
|
||||||
light_info_id: 0,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -72,140 +57,10 @@ impl Client for ExampleClient {
|
||||||
self.delta = delta;
|
self.delta = delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_draw(&mut self, ui: &doppler::imgui::Ui) {
|
|
||||||
if let Some(menu_bar) = ui.begin_main_menu_bar() {
|
|
||||||
if let Some(menu) = ui.begin_menu(im_str!("Basic"), true) {
|
|
||||||
if MenuItem::new(im_str!("Show Object info"))
|
|
||||||
.selected(self.show_object_info)
|
|
||||||
.build(ui)
|
|
||||||
{
|
|
||||||
self.show_object_info = !self.show_object_info;
|
|
||||||
}
|
|
||||||
if MenuItem::new(im_str!("Show lights info"))
|
|
||||||
.selected(self.show_light_info)
|
|
||||||
.build(ui)
|
|
||||||
{
|
|
||||||
self.show_light_info = !self.show_light_info;
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
if self.show_camera_info {
|
|
||||||
Window::new(im_str!("CameraInfo"))
|
|
||||||
.size([260.0, 430.0], Condition::Always)
|
|
||||||
.position([20.0, 40.0], Condition::Always)
|
|
||||||
.title_bar(false)
|
|
||||||
.scroll_bar(false)
|
|
||||||
.no_inputs()
|
|
||||||
.bg_alpha(0.8)
|
|
||||||
.collapsible(false)
|
|
||||||
.build(&ui, || {
|
|
||||||
ui.text(im_str!("Camera info"));
|
|
||||||
ui.separator();
|
|
||||||
<Camera as imgui_inspect::InspectRenderDefault<Camera>>::render(
|
|
||||||
&[&self.map.camera],
|
|
||||||
&"CameraInfo",
|
|
||||||
ui,
|
|
||||||
&imgui_inspect::InspectArgsDefault {
|
|
||||||
header: Some(false),
|
|
||||||
..imgui_inspect::InspectArgsDefault::default()
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if self.show_object_info {
|
|
||||||
let mut id = self.object_info_id;
|
|
||||||
let max: i32 = self.map.models.len() as i32 - 1;
|
|
||||||
let mut show_window = self.show_object_info;
|
|
||||||
|
|
||||||
Window::new(im_str!("Object info"))
|
|
||||||
.size([250.0, 250.0], Condition::FirstUseEver)
|
|
||||||
.opened(&mut show_window)
|
|
||||||
.build(&ui, || {
|
|
||||||
ui.input_int(im_str!("id"), &mut id).build();
|
|
||||||
id = if id < 0 {
|
|
||||||
0
|
|
||||||
} else if id > max {
|
|
||||||
max
|
|
||||||
} else {
|
|
||||||
id
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut selected_mut = vec![&mut self.map.models[id as usize].transform];
|
|
||||||
<Transform as imgui_inspect::InspectRenderStruct<Transform>>::render_mut(
|
|
||||||
&mut selected_mut,
|
|
||||||
"Object info",
|
|
||||||
&ui,
|
|
||||||
&imgui_inspect::InspectArgsStruct::default(),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
self.object_info_id = id;
|
|
||||||
self.show_object_info = show_window;
|
|
||||||
}
|
|
||||||
if self.show_light_info {
|
|
||||||
let mut id = self.light_info_id;
|
|
||||||
let max: i32 = self.map.lighting_system.point_lights.len() as i32 - 1;
|
|
||||||
let mut show_window = self.show_light_info;
|
|
||||||
|
|
||||||
Window::new(im_str!("Lights info"))
|
|
||||||
.size([250.0, 250.0], Condition::FirstUseEver)
|
|
||||||
.opened(&mut show_window)
|
|
||||||
.build(&ui, || {
|
|
||||||
{
|
|
||||||
let mut selected_mut = vec![&mut self.map.lighting_system.directional_light];
|
|
||||||
<DirectionalLight as imgui_inspect::InspectRenderStruct<
|
|
||||||
DirectionalLight,
|
|
||||||
>>::render_mut(
|
|
||||||
&mut selected_mut,
|
|
||||||
"DirectionalLightInfo",
|
|
||||||
&ui,
|
|
||||||
&imgui_inspect::InspectArgsStruct::default(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
ui.separator();
|
|
||||||
ui.input_int(im_str!("Light ID"), &mut id)
|
|
||||||
.build();
|
|
||||||
id = if id < 0 { 0 } else if id > max { max } else { id };
|
|
||||||
{
|
|
||||||
let mut selected_mut =
|
|
||||||
vec![&mut self.map.lighting_system.point_lights[id as usize]];
|
|
||||||
<PointLight as imgui_inspect::InspectRenderStruct<PointLight>>::render_mut(
|
|
||||||
&mut selected_mut,
|
|
||||||
"PointLightInfo",
|
|
||||||
&ui,
|
|
||||||
&imgui_inspect::InspectArgsStruct::default(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
self.light_info_id = id;
|
|
||||||
self.show_light_info = show_window;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.imgui_grabs_input = ui.is_any_item_hovered() || ui.is_any_item_focused();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_mouse_scroll(&mut self, yoffset: f32) {
|
fn on_mouse_scroll(&mut self, yoffset: f32) {
|
||||||
if self.imgui_grabs_input {
|
self.map.camera.process_mouse_scroll(yoffset);
|
||||||
println!("DD");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.map.camera.process_mouse_scroll(yoffset as f32);
|
|
||||||
}
|
}
|
||||||
fn on_mouse_move(&mut self, x: f32, y: f32) {
|
fn on_mouse_move(&mut self, x: f32, y: f32) {
|
||||||
if self.imgui_grabs_input {
|
|
||||||
println!("DD");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
self.map.camera.process_mouse_movement(x, y, true);
|
self.map.camera.process_mouse_movement(x, y, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,9 @@ pub struct AssetsCache {
|
||||||
impl AssetsCache {
|
impl AssetsCache {
|
||||||
pub fn load_2d(&mut self, path: &str) -> Model {
|
pub fn load_2d(&mut self, path: &str) -> Model {
|
||||||
let fullpath = Path::new(&path);
|
let fullpath = Path::new(&path);
|
||||||
let dir = fullpath
|
let dir = fullpath.parent().unwrap().to_str().unwrap().to_string();
|
||||||
.parent()
|
|
||||||
.unwrap()
|
|
||||||
.to_str()
|
|
||||||
.unwrap()
|
|
||||||
.to_string();
|
|
||||||
let filename = fullpath.file_name().unwrap().to_str().unwrap();
|
let filename = fullpath.file_name().unwrap().to_str().unwrap();
|
||||||
let texture = self.get_material_texture(&dir, &filename, "texture_diffuse");
|
let texture = self.get_material_texture(&dir, filename, "texture_diffuse");
|
||||||
let mut model = Model::new_2d(self);
|
let mut model = Model::new_2d(self);
|
||||||
for ele in &mut model.meshes {
|
for ele in &mut model.meshes {
|
||||||
ele.textures.push(texture.clone())
|
ele.textures.push(texture.clone())
|
||||||
|
|
@ -34,7 +29,7 @@ impl AssetsCache {
|
||||||
pub fn load_all_from_file(&mut self, path: &str) {
|
pub fn load_all_from_file(&mut self, path: &str) {
|
||||||
let path = std::path::Path::new(path);
|
let path = std::path::Path::new(path);
|
||||||
let meta = std::fs::metadata(path);
|
let meta = std::fs::metadata(path);
|
||||||
if !meta.is_ok() {
|
if meta.is_err() {
|
||||||
error!("There is no assets file");
|
error!("There is no assets file");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +45,7 @@ impl AssetsCache {
|
||||||
for line in lines {
|
for line in lines {
|
||||||
let mut splitted = line.split_whitespace();
|
let mut splitted = line.split_whitespace();
|
||||||
let path = splitted.next();
|
let path = splitted.next();
|
||||||
if path.is_none() || self.has_model(&path.unwrap()) {
|
if path.is_none() || self.has_model(path.unwrap()) {
|
||||||
error!("Skip wrong line: {}", line);
|
error!("Skip wrong line: {}", line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -79,10 +74,7 @@ impl AssetsCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_model_by_hash(&mut self, hash: &u64) -> Option<Model> {
|
pub fn get_model_by_hash(&mut self, hash: &u64) -> Option<Model> {
|
||||||
match self.models.get(hash) {
|
self.models.get(hash).cloned()
|
||||||
Some(model) => Some(model.clone()),
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_model_ext(&mut self, path: &str, diff_texture: Option<&str>) {
|
fn load_model_ext(&mut self, path: &str, diff_texture: Option<&str>) {
|
||||||
|
|
|
||||||
|
|
@ -41,27 +41,20 @@ impl Transform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct ModelComponent {
|
pub struct ModelComponent {
|
||||||
pub model: Model,
|
pub model: Model,
|
||||||
pub hash: u64,
|
pub hash: u64,
|
||||||
pub transform: Transform,
|
pub transform: Transform,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ModelComponent {
|
|
||||||
fn default() -> Self {
|
|
||||||
ModelComponent {
|
|
||||||
model: Model::default(),
|
|
||||||
hash: u64::default(),
|
|
||||||
transform: Transform::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ModelComponent {
|
impl ModelComponent {
|
||||||
pub unsafe fn draw(&self, shader: &Shader) {
|
pub unsafe fn draw(&self, shader: &Shader) {
|
||||||
let matrix = self.transform.get_matrix();
|
let matrix = self.transform.get_matrix();
|
||||||
|
|
||||||
shader.set_mat4(c_str!("model"), &matrix);
|
shader.set_mat4(c_str!("model"), &matrix);
|
||||||
self.model.Draw(&shader);
|
self.model.Draw(shader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,12 @@ pub struct TimeStep {
|
||||||
frames: VecDeque<f32>,
|
frames: VecDeque<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for TimeStep {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl TimeStep {
|
impl TimeStep {
|
||||||
pub fn frames(&self) -> Vec<f32> {
|
pub fn frames(&self) -> Vec<f32> {
|
||||||
self.frames.clone().into()
|
self.frames.clone().into()
|
||||||
|
|
@ -207,7 +213,7 @@ impl Engine {
|
||||||
info!("Creating AssetCache");
|
info!("Creating AssetCache");
|
||||||
let mut assets_cache = AssetsCache::default();
|
let mut assets_cache = AssetsCache::default();
|
||||||
info!("Creating client");
|
info!("Creating client");
|
||||||
let mut client = Box::new(T::default());
|
let mut client = Box::<T>::default();
|
||||||
client.load_assets(&mut assets_cache);
|
client.load_assets(&mut assets_cache);
|
||||||
let mut first_mouse = true;
|
let mut first_mouse = true;
|
||||||
let mut last_x: f32 = consts::SCR_WIDTH as f32 / 2.0;
|
let mut last_x: f32 = consts::SCR_WIDTH as f32 / 2.0;
|
||||||
|
|
@ -215,7 +221,7 @@ impl Engine {
|
||||||
|
|
||||||
// timing
|
// timing
|
||||||
let mut timestep = TimeStep::new();
|
let mut timestep = TimeStep::new();
|
||||||
let mut last_frame = std::time::Instant::now();
|
let _last_frame = std::time::Instant::now();
|
||||||
|
|
||||||
let mut screensize = self.size;
|
let mut screensize = self.size;
|
||||||
info!("Assets loaded");
|
info!("Assets loaded");
|
||||||
|
|
@ -245,7 +251,7 @@ impl Engine {
|
||||||
.expect("Failed to prepare frame");
|
.expect("Failed to prepare frame");
|
||||||
gl_window.window().request_redraw();
|
gl_window.window().request_redraw();
|
||||||
}
|
}
|
||||||
Event::LoopDestroyed => return,
|
Event::LoopDestroyed => (),
|
||||||
Event::WindowEvent { event, .. } => match event {
|
Event::WindowEvent { event, .. } => match event {
|
||||||
WindowEvent::MouseWheel { delta, .. } => {
|
WindowEvent::MouseWheel { delta, .. } => {
|
||||||
use glutin::event::MouseScrollDelta;
|
use glutin::event::MouseScrollDelta;
|
||||||
|
|
@ -372,7 +378,7 @@ impl Engine {
|
||||||
|
|
||||||
ui.text(output);
|
ui.text(output);
|
||||||
});
|
});
|
||||||
platform.prepare_render(&ui, &gl_window.window());
|
platform.prepare_render(&ui, gl_window.window());
|
||||||
renderer.render(ui);
|
renderer.render(ui);
|
||||||
}
|
}
|
||||||
gl_window.swap_buffers().unwrap();
|
gl_window.swap_buffers().unwrap();
|
||||||
|
|
|
||||||
|
|
@ -148,11 +148,11 @@ impl FramebufferSystem {
|
||||||
info!("New framebuffer generated");
|
info!("New framebuffer generated");
|
||||||
|
|
||||||
FramebufferSystem {
|
FramebufferSystem {
|
||||||
texture_color_buffer: texture_color_buffer,
|
texture_color_buffer,
|
||||||
shader: shader,
|
shader,
|
||||||
vao: quad_vao,
|
vao: quad_vao,
|
||||||
vbo: quad_vbo,
|
vbo: quad_vbo,
|
||||||
framebuffer: framebuffer,
|
framebuffer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
pub extern crate gl;
|
pub extern crate gl;
|
||||||
|
#[cfg(feature = "imgui_inspect")]
|
||||||
pub extern crate imgui;
|
pub extern crate imgui;
|
||||||
pub extern crate log;
|
pub extern crate log;
|
||||||
pub extern crate simple_logging;
|
pub extern crate simple_logging;
|
||||||
|
|
||||||
pub use cgmath as math;
|
pub use cgmath as math;
|
||||||
pub use glutin;
|
pub use glutin;
|
||||||
|
#[cfg(feature = "imgui_inspect")]
|
||||||
pub use imgui_inspect;
|
pub use imgui_inspect;
|
||||||
pub use serde;
|
pub use serde;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ impl MapSave {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let ms = MapSave {
|
let ms = MapSave {
|
||||||
camera: map.camera.clone(),
|
camera: map.camera,
|
||||||
objects: objects,
|
objects,
|
||||||
};
|
};
|
||||||
match serde_yaml::to_string(&ms) {
|
match serde_yaml::to_string(&ms) {
|
||||||
Ok(result) => println!("{}", result),
|
Ok(result) => println!("{}", result),
|
||||||
|
|
@ -96,7 +96,7 @@ impl Default for Map {
|
||||||
..Camera::default()
|
..Camera::default()
|
||||||
},
|
},
|
||||||
lighting_system: LightingSystem::default(),
|
lighting_system: LightingSystem::default(),
|
||||||
sky: sky,
|
sky,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ impl Model {
|
||||||
} else if diffuse_path.is_some() {
|
} else if diffuse_path.is_some() {
|
||||||
let path = diffuse_path.unwrap();
|
let path = diffuse_path.unwrap();
|
||||||
println!("Loading {}", path);
|
println!("Loading {}", path);
|
||||||
let dir: String = if path.contains("/") {
|
let dir: String = if path.contains('/') {
|
||||||
Path::new(&path)
|
Path::new(&path)
|
||||||
.parent()
|
.parent()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
@ -159,11 +159,8 @@ impl Model {
|
||||||
} else {
|
} else {
|
||||||
self.directory.to_string()
|
self.directory.to_string()
|
||||||
};
|
};
|
||||||
let texture = cache.get_material_texture(
|
let texture =
|
||||||
&dir,
|
cache.get_material_texture(&dir, diffuse_path.unwrap(), "texture_diffuse");
|
||||||
&diffuse_path.unwrap(),
|
|
||||||
"texture_diffuse",
|
|
||||||
);
|
|
||||||
textures.push(texture);
|
textures.push(texture);
|
||||||
} else {
|
} else {
|
||||||
warn!("There are no materials for: {}", path.display());
|
warn!("There are no materials for: {}", path.display());
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ impl Sky {
|
||||||
shader.setInt(c_str!("skybox"), 0);
|
shader.setInt(c_str!("skybox"), 0);
|
||||||
|
|
||||||
Sky {
|
Sky {
|
||||||
shader: shader,
|
shader,
|
||||||
texture_id: cubemap_texture,
|
texture_id: cubemap_texture,
|
||||||
vao: skybox_vao,
|
vao: skybox_vao,
|
||||||
vbo: skybox_vbo,
|
vbo: skybox_vbo,
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ pub unsafe fn load_texture(path: &str, file_format: &str) -> u32 {
|
||||||
gl::TEXTURE_2D,
|
gl::TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
format as i32,
|
format as i32,
|
||||||
dim.0 as i32,
|
dim.0,
|
||||||
dim.1 as i32,
|
dim.1,
|
||||||
0,
|
0,
|
||||||
format,
|
format,
|
||||||
gl::UNSIGNED_BYTE,
|
gl::UNSIGNED_BYTE,
|
||||||
|
|
@ -69,10 +69,10 @@ pub unsafe fn load_texture_from_dir(filename: &str, directory: &str) -> u32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn load_texture_from_fullpath(fullpath: &str) -> u32 {
|
pub unsafe fn load_texture_from_fullpath(fullpath: &str) -> u32 {
|
||||||
let dot = fullpath.find(".").unwrap_or_default() + 1usize;
|
let dot = fullpath.find('.').unwrap_or_default() + 1usize;
|
||||||
let (_, format) = fullpath.split_at(dot);
|
let (_, format) = fullpath.split_at(dot);
|
||||||
|
|
||||||
load_texture(&fullpath, format)
|
load_texture(fullpath, format)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// loads a cubemap texture from 6 individual texture faces
|
/// loads a cubemap texture from 6 individual texture faces
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue