tirbofish/dropbear · commit
c4de60122013eeb014ea300b404da448d47ce76e
wip: this is a tomorrow problem Unverified
@@ -106,7 +106,7 @@ impl SharedGraphicsContext { module: &shader.module, entry_point: Some("fs_main"), targets: &[Some(wgpu::ColorTargetState { - format: wgpu::TextureFormat::Rgba16Float, + format: Texture::TEXTURE_FORMAT, blend: Some(wgpu::BlendState::REPLACE), write_mask: wgpu::ColorWrites::ALL, })], @@ -192,16 +192,16 @@ Hardware: let surface_caps = surface.get_capabilities(&adapter); - let surface_format = surface_caps - .formats - .iter() - .find(|f| f.is_srgb()) - .copied() - .unwrap_or(TextureFormat::Rgba16Float); + // let surface_format = surface_caps + // .formats + // .iter() + // .find(|f| f.is_srgb()) + // .copied() + // .unwrap_or(TextureFormat::Rgba16Float); let config = SurfaceConfiguration { usage: wgpu::TextureUsages::RENDER_ATTACHMENT, - format: surface_format, + format: Texture::TEXTURE_FORMAT, width: initial_width, height: initial_height, present_mode: surface_caps.present_modes[0], @@ -246,7 +246,7 @@ Hardware: let result = Self { surface: Arc::new(surface), - surface_format, + surface_format: Texture::TEXTURE_FORMAT, device: Arc::new(device), queue: Arc::new(queue), config, @@ -2,6 +2,7 @@ use crate::attenuation::{Attenuation, RANGE_50}; use crate::buffer::{ResizableBuffer, StorageBuffer, UniformBuffer}; use crate::graphics::SharedGraphicsContext; use crate::shader::Shader; +use crate::texture::Texture; use crate::{ entity::{EntityTransform, Transform}, model::{self, Model, Vertex}, @@ -540,7 +541,7 @@ impl LightManager { module: &shader.module, entry_point: Some("fs_main"), targets: &[Some(wgpu::ColorTargetState { - format: wgpu::TextureFormat::Rgba16Float, + format: Texture::TEXTURE_FORMAT, blend: Some(wgpu::BlendState { alpha: wgpu::BlendComponent::REPLACE, color: wgpu::BlendComponent::REPLACE, @@ -72,6 +72,7 @@ pub struct Texture { impl Texture { /// Describes the depth format for all Texture related functions in WGPU to use. Makes life easier pub const DEPTH_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Depth32Float; + pub const TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb; /// Creates a new depth texture. This is an internal function. pub fn depth_texture( @@ -139,7 +140,7 @@ impl Texture { mip_level_count: 1, // leave me alone sample_count: 1, dimension: wgpu::TextureDimension::D2, - format: wgpu::TextureFormat::Rgba16Float, + format: Texture::TEXTURE_FORMAT, usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING, view_formats: &[], }; @@ -209,7 +210,7 @@ impl Texture { mip_level_count: 1, sample_count: 1, dimension: wgpu::TextureDimension::D2, - format: wgpu::TextureFormat::Rgba8UnormSrgb, + format: Texture::TEXTURE_FORMAT, usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST | wgpu::TextureUsages::RENDER_ATTACHMENT, view_formats: &[], } @@ -129,9 +129,10 @@ impl ProjectConfig { if io_err.kind() == std::io::ErrorKind::NotFound { log::warn!("resources.eucc not found, creating default."); let default = ResourceConfig { - path: project_root.join("../../../resources"), + path: project_root.join("/resources"), nodes: vec![], }; + log::debug!("Writing to {}", default.path.display()); default.write_to(&project_root)?; { let mut cfg = RESOURCES.write(); @@ -3,7 +3,7 @@ use std::mem::size_of; use std::sync::Arc; -use dropbear_engine::entity::Transform; +use dropbear_engine::{entity::Transform, texture::Texture}; use dropbear_engine::graphics::SharedGraphicsContext; use dropbear_engine::shader::Shader; use dropbear_engine::wgpu::*; @@ -59,7 +59,7 @@ impl ColliderWireframePipeline { module: &shader.module, entry_point: Some("fs_main"), targets: &[Some(ColorTargetState { - format: TextureFormat::Rgba16Float, + format: Texture::TEXTURE_FORMAT, blend: Some(BlendState::ALPHA_BLENDING), write_mask: ColorWrites::ALL, })], @@ -75,7 +75,7 @@ impl ColliderWireframePipeline { conservative: false, }, depth_stencil: Some(DepthStencilState { - format: TextureFormat::Depth32Float, + format: Texture::DEPTH_FORMAT, depth_write_enabled: false, depth_compare: CompareFunction::Always, stencil: StencilState::default(), @@ -1167,9 +1167,9 @@ impl<'a> EditorTabViewer<'a> { let entries = match Self::sorted_entries(current_path) { Ok(entries) => entries, Err(err) => { - log::warn!( + log_once::warn_once!( "Unable to enumerate resources at '{}': {}", - current_path.display(), + current_path.parent().unwrap_or(current_path).display(), err ); return; @@ -1332,6 +1332,8 @@ impl Editor { let collider_pipeline = ColliderWireframePipeline::new(graphics.clone()); self.collider_wireframe_pipeline = Some(collider_pipeline); + self.texture_id = Some((*graphics.texture_id).clone()); + self.window = Some(graphics.window.clone()); self.is_world_loaded.mark_rendering_loaded(); } @@ -349,6 +349,16 @@ impl Scene for Editor { fn render<'a>(&mut self, graphics: Arc<SharedGraphicsContext>, frame_ctx: FrameGraphicsContext<'a>) { self.show_ui(&graphics.get_egui_context()); + let clear_color = Color { + r: 100.0 / 255.0, + g: 149.0 / 255.0, + b: 237.0 / 255.0, + a: 1.0, + }; + self.color = clear_color; + self.size = graphics.viewport_texture.size; + self.texture_id = Some(*graphics.texture_id.clone()); + self.window = Some(graphics.window.clone()); eucalyptus_core::logging::render(&graphics.get_egui_context()); let cam = { @@ -375,13 +385,6 @@ impl Scene for Editor { }; log_once::debug_once!("Pipeline ready"); - let clear_color = Color { - r: 100.0 / 255.0, - g: 149.0 / 255.0, - b: 237.0 / 255.0, - a: 1.0, - }; - let lights = { let mut lights = Vec::new(); let mut query = self.world.query::<(&Light, &LightComponent)>(); @@ -362,6 +362,7 @@ impl Scene for MainMenu { .add_filter("Eucalyptus Configuration Files", &["eucp"]) .pick_file() { + log::debug!("Reading from {}", path.display()); match ProjectConfig::read_from(&path) { Ok(config) => { log::info!("Loaded project: {:?}", path);