From 978fc568990dc5cebd6680ae4a917560898a8abc Mon Sep 17 00:00:00 2001 From: imrn99 <95699343+imrn99@users.noreply.github.com> Date: Fri, 3 May 2024 11:41:46 +0200 Subject: [PATCH] feat: add new basic structures based on https://github.com/rust-windowing/winit/issues/3626#issuecomment-2081794856 --- honeycomb-core/src/attributes/collections.rs | 2 +- honeycomb-render/src/runner.rs | 2 +- honeycomb-render/src/state/app.rs | 12 +++++++++++ honeycomb-render/src/state/gfx.rs | 21 +++++++++++++++++++ .../src/{state.rs => state/mod.rs} | 3 +++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 honeycomb-render/src/state/app.rs create mode 100644 honeycomb-render/src/state/gfx.rs rename honeycomb-render/src/{state.rs => state/mod.rs} (99%) diff --git a/honeycomb-core/src/attributes/collections.rs b/honeycomb-core/src/attributes/collections.rs index b7b52251..a79aab1e 100644 --- a/honeycomb-core/src/attributes/collections.rs +++ b/honeycomb-core/src/attributes/collections.rs @@ -484,7 +484,7 @@ mod tests { } #[test] - #[should_panic(expected = "assertion failed: tmp.is_none()")] + #[should_panic(expected = "assertion failed: state.is_none()")] fn sparse_vec_insert_already_existing() { generate_sparse!(storage); assert_eq!(storage.get(&3), &Some(Temperature::from(279.0))); diff --git a/honeycomb-render/src/runner.rs b/honeycomb-render/src/runner.rs index 98187e86..7d8de5b0 100644 --- a/honeycomb-render/src/runner.rs +++ b/honeycomb-render/src/runner.rs @@ -8,7 +8,7 @@ use winit::event::{Event, WindowEvent}; use winit::event_loop::EventLoop; use winit::window::{Window, WindowAttributes}; -use crate::state::State; +use crate::tmp::State; use crate::RenderParameters; use honeycomb_core::{CMap2, CoordsFloat}; diff --git a/honeycomb-render/src/state/app.rs b/honeycomb-render/src/state/app.rs new file mode 100644 index 00000000..c093fe0b --- /dev/null +++ b/honeycomb-render/src/state/app.rs @@ -0,0 +1,12 @@ +//! mod doc + +use crate::handle::CMap2RenderHandle; +use crate::state::gfx::GfxState; +use honeycomb_core::CoordsFloat; +use winit::window::Window; + +pub struct App<'a, T: CoordsFloat> { + pub(crate) window: Option, + pub(crate) gfx: Option, + pub(crate) map_handle: Option>, +} diff --git a/honeycomb-render/src/state/gfx.rs b/honeycomb-render/src/state/gfx.rs new file mode 100644 index 00000000..5930c98d --- /dev/null +++ b/honeycomb-render/src/state/gfx.rs @@ -0,0 +1,21 @@ +//! mod doc + +use crate::camera::{Camera, CameraController, CameraUniform}; +use winit::dpi::PhysicalSize; + +pub struct GfxState { + surface: wgpu::Surface<'static>, + device: wgpu::Device, + queue: wgpu::Queue, + config: wgpu::SurfaceConfiguration, + size: PhysicalSize, + render_pipeline: wgpu::RenderPipeline, + vertex_buffer: wgpu::Buffer, + num_vertices: u32, + camera: Camera, + camera_uniform: CameraUniform, + camera_buffer: wgpu::Buffer, + camera_bind_group: wgpu::BindGroup, + camera_controller: CameraController, + smaa_target: smaa::SmaaTarget, +} diff --git a/honeycomb-render/src/state.rs b/honeycomb-render/src/state/mod.rs similarity index 99% rename from honeycomb-render/src/state.rs rename to honeycomb-render/src/state/mod.rs index cb41cfc6..5c79c30a 100644 --- a/honeycomb-render/src/state.rs +++ b/honeycomb-render/src/state/mod.rs @@ -4,6 +4,9 @@ // ------ IMPORTS +mod app; +mod gfx; + // intern use crate::camera::{Camera, CameraController, CameraUniform, SPEED_FACTOR}; use crate::handle::CMap2RenderHandle;