tirbofish/dropbear · diff
russimp is a pain to deal with smh
Signature present but could not be verified.
Unverified
@@ -40,14 +40,13 @@ pollster = "0.4" rfd = "0.15.4" rhai = "1.22" ron = "0.10.1" -russimp = { version = "3.2", features = ["prebuilt"] } serde = { version = "1.0.219", features = ["derive"] } spin_sleep = "1.3" tokio = { version = "1", features = ["full"] } transform-gizmo-egui = { git = "https://github.com/4tkbytes/transform-gizmo"} wgpu = "25" winit = { version = "0.30", features = [] } -zip = "0.6" +zip = "4.3" walkdir = "2.3" [workspace.dependencies.image] @@ -55,8 +54,10 @@ version = "0.25" default-features = false features = ["png"] -# [patch.crates-io] -# russimp-sys = { git = "https://github.com/4tkbytes/russimp-sys" } +[patch.crates-io] +dropbear-engine = { path = "dropbear-engine" } +eucalyptus = { path = "eucalyptus" } +russimp-sys = { git = "https://github.com/skillissuedev/russimp-sys" } [profile.dev] opt-level = 0 @@ -18,7 +18,7 @@ With Unix systems (macOS not tested), you will have to download a couple depende ```bash # ubuntu, adapt to your own OS -sudo apt install libudev-dev pkg-config libssl-dev clang +sudo apt install libudev-dev pkg-config libssl-dev clang cmake meson # if on arm devices where russimp cannot compile sudo apt install assimp-utils @@ -55,4 +55,4 @@ To be fair, I do not plan on supporting web, android or iOS yet (as it isnt even ## Contributions -Yeah yeah, go ahead and contribute. Make sure it works, and its not spam, and any tests pass. +Yeah yeah, go ahead and contribute. Make sure it works, and its not spam, and any tests pass. @@ -24,6 +24,7 @@ Just a list of stuff i need to work on/a list of items i need to implement - [ ] attaching texture onto model - [ ] user defined keybinds - [ ] console tab +- [ ] android build (in progress, unfinished) ## fixing @@ -20,13 +20,19 @@ gilrs.workspace = true glam.workspace = true log.workspace = true # nalgebra.workspace = true -russimp.workspace = true +# russimp.workspace = true pollster.workspace = true serde.workspace = true spin_sleep.workspace = true wgpu.workspace = true winit.workspace = true +[target.'cfg(target_os = "windows")'.dependencies] +russimp = { version = "3.2", features = ["prebuilt", "static-link"] } + +[target.'cfg(not(target_os = "windows"))'.dependencies] +russimp = { version = "3.2", features = ["static-link"] } + [dependencies.image] version = "0.25" default-features = false @@ -20,7 +20,7 @@ use std::{ u32, }; use wgpu::{ - BindGroupLayout, Device, Instance, Queue, Surface, SurfaceConfiguration, TextureFormat, + BindGroupLayout, Device, Instance, Queue, Surface, SurfaceConfiguration, SurfaceError, TextureFormat }; use winit::{ application::ApplicationHandler, @@ -90,7 +90,7 @@ impl State { let info = adapter.get_info(); println!( - "==================== BACKEND INFO ==================== +"==================== BACKEND INFO ==================== Backend: {} Hardware: @@ -100,7 +100,7 @@ Hardware: Type: {:?} Driver: {} Driver Info: {} - +======================================================= ", info.backend.to_string(), info.name, @@ -129,6 +129,8 @@ Hardware: desired_maximum_frame_latency: 2, }; + surface.configure(&device, &config); + let depth_texture = Texture::create_depth_texture(&config, &device, Some("depth texture")); let viewport_texture = Texture::create_viewport_texture(&config, &device, Some("viewport texture")); @@ -169,7 +171,7 @@ Hardware: device, queue, config, - is_surface_configured: false, + is_surface_configured: true, depth_texture, texture_bind_layout: texture_bind_group_layout, window, @@ -213,12 +215,33 @@ Hardware: return Ok(()); } + let output = match self.surface.get_current_texture() { + Ok(val) => val, + Err(e) => { + match e { + SurfaceError::Lost | SurfaceError::Outdated => { + self.surface.configure(&self.device, &self.config); + return Ok(()); + } + SurfaceError::Timeout | SurfaceError::OutOfMemory => { + return Err(anyhow::anyhow!("Surface error: {:?}", e)); + } + SurfaceError::Other => { + log::warn!("Encountered SurfaceError::Other: {:?}. Attempting to reconfigure and skip this frame.", e); + let _ = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + self.surface.configure(&self.device, &self.config); + })); + return Ok(()); + }, + } + } + }; + let screen_descriptor = ScreenDescriptor { size_in_pixels: [self.config.width, self.config.height], pixels_per_point: self.window.scale_factor() as f32, }; - let output = self.surface.get_current_texture()?; let view = output .texture .create_view(&wgpu::TextureViewDescriptor::default()); @@ -333,11 +356,12 @@ impl App { { if cfg!(debug_assertions) { log::info!("Running in dev mode"); - // let package_name = std::env::var("CARGO_BIN_NAME").unwrap(); - let log_config = format!("dropbear_engine=trace,{}=debug,warn", app_name); + let app_target = app_name.replace('-', "_"); + let log_config = format!("dropbear_engine=trace,{}=debug,warn", app_target); unsafe { std::env::set_var("RUST_LOG", log_config) }; } + #[cfg(not(target_os = "android"))] let _ = env_logger::try_init(); // log::debug!("OUT_DIR: {}", std::env!("OUT_DIR")); @@ -393,6 +417,11 @@ impl ApplicationHandler for App { self.state = Some(pollster::block_on(State::new(window)).unwrap()); + if let Some(state) = &mut self.state { + let size = state.window.inner_size(); + state.resize(size.width, size.height); + } + self.next_frame_time = Some(Instant::now()); } @@ -1,6 +1,7 @@ use std::{collections::HashMap, fs, path::PathBuf, process::Command}; use clap::ArgMatches; +use zip::write::SimpleFileOptions; use crate::states::{ProjectConfig, RuntimeData, SCENES, SOURCE}; @@ -53,14 +54,17 @@ pub fn package(project_path: PathBuf, _sub_matches: &ArgMatches) -> anyhow::Resu } println!("Building {} for release", project_name); - let cargo_build = Command::new("cargo") + let mut cargo_build = Command::new("cargo") .args(&["build", "--release"]) .current_dir(&runtime_dir) - .output()?; + .stdout(std::process::Stdio::inherit()) + .stderr(std::process::Stdio::inherit()) + .spawn()?; - if !cargo_build.status.success() { - let stderr = String::from_utf8_lossy(&cargo_build.stderr); - return Err(anyhow::anyhow!("Failed to build {}:\n{}", project_name, stderr)); + let exit_status = cargo_build.wait()?; + + if !exit_status.success() { + return Err(anyhow::anyhow!("Failed to build {}", project_name)); } println!("{} built successfully!", project_name); @@ -77,7 +81,7 @@ pub fn package(project_path: PathBuf, _sub_matches: &ArgMatches) -> anyhow::Resu } println!("Building project data (.eupak file)"); - build(project_path.clone(), _sub_matches)?; + build(project_path.clone())?; let output_dir = project_path.parent().ok_or(anyhow::anyhow!("Unable to get parent"))?.join("build").join("package"); std::fs::create_dir_all(&output_dir)?; @@ -260,7 +264,8 @@ fn create_zip_package(source_dir: &PathBuf, zip_path: &PathBuf) -> anyhow::Resul let relative_path = path.strip_prefix(source_dir)?; let name = relative_path.to_string_lossy(); - zip.start_file(name, zip::write::FileOptions::default())?; + let options: SimpleFileOptions = Default::default(); + zip.start_file(name, options.into())?; let mut file = std::fs::File::open(path)?; std::io::copy(&mut file, &mut zip)?; } @@ -278,7 +283,10 @@ pub fn read_from_eupak(eupak_path: PathBuf) -> anyhow::Result<()> { Ok(()) } -pub fn build(project_path: PathBuf, _sub_matches: &ArgMatches) -> anyhow::Result<()> { +pub fn build( + project_path: PathBuf, + // _sub_matches: &ArgMatches + ) -> anyhow::Result<PathBuf> { if !project_path.exists() { return Err(anyhow::anyhow!("Unable to locate project config file")); } @@ -330,7 +338,7 @@ pub fn build(project_path: PathBuf, _sub_matches: &ArgMatches) -> anyhow::Result std::fs::write(&runtime_file, serialized)?; println!("Build completed successfully. Output at {:?}", runtime_file.display()); - Ok(()) + Ok(runtime_file) } pub fn health() -> anyhow::Result<()> { @@ -28,12 +28,9 @@ use wgpu::{Color, Extent3d, RenderPipeline}; use winit::{keyboard::KeyCode, window::Window}; use crate::{ - camera::{ + build::build, camera::{ CameraAction, CameraManager, CameraType, DebugCameraController, PlayerCameraController, - }, - scripting::{input::InputState, ScriptAction, ScriptManager}, - states::{EntityNode, ModelProperties, SceneEntity, ScriptComponent, PROJECT, SCENES}, - utils::ViewportMode, + }, scripting::{input::InputState, ScriptAction, ScriptManager}, states::{EntityNode, ModelProperties, SceneEntity, ScriptComponent, PROJECT, SCENES}, utils::ViewportMode }; pub struct Editor { @@ -432,6 +429,22 @@ impl Editor { self.signal = Signal::Play; } } + ui.menu_button("Export", |ui| { + // todo: create a window for better build menu + if ui.button("Build").clicked() { + { + if let Ok(proj) = PROJECT.read() { + match build(proj.project_path.clone()) { + Ok(thingy) => crate::success!("Project output at {}", thingy.display()), + Err(e) => { + crate::fatal!("Unable to build project [{}]: {}", proj.project_path.clone().display(), e); + }, + } + } + } + } + ui.label("Package"); // todo: create a window for label + }); ui.separator(); if ui.button("Quit").clicked() { match self.save_project_config() { @@ -59,7 +59,7 @@ async fn main() -> anyhow::Result<()> { }, }; - eucalyptus::build::build(project_path, sub_matches)?; + eucalyptus::build::build(project_path)?; } Some(("package", sub_matches)) => { let project_path = match sub_matches.get_one::<String>("project") { @@ -1 +1 @@ -Subproject commit 222faed4a45d3aafef7ccd955dd42ad7c2cf49c9 +Subproject commit 82bf5df4a2c7d8c020b5c8b6d028360b12468467