diff --git a/Cargo.toml b/Cargo.toml index a7a36026..ddbbc139 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ edition = "2021" version = "0.1.0" [workspace] -members = ["backends/*", "common", "editor", "macros", "modules/*"] +members = ["crates/*", "backends/*"] [profile.dev.package."*"] opt-level = 3 @@ -31,16 +31,16 @@ bitflags = "2.1.0" [dependencies] # core -common = { package = "surreal-common", path = "./common" } +common = { package = "surreal-common", path = "./crates/common" } editor = { package = "surreal-editor", path = "./editor", optional = true } # framework sdl = { package = "surreal-backend-sdl", path = "./backends/sdl", optional = true } -# modules -audio = { package = "surreal-audio", path = "./modules/audio", optional = true } -graphics = { package = "surreal-graphics", path = "./modules/graphics", optional = true } -input = { package = "surreal-input", path = "./modules/input", optional = true } +# crates +audio = { package = "surreal-audio", path = "./crates/audio", optional = true } +graphics = { package = "surreal-graphics", path = "./crates/graphics", optional = true } +input = { package = "surreal-input", path = "./crates/input", optional = true } [[example]] name = "hello-world" diff --git a/backends/sdl/Cargo.toml b/backends/sdl/Cargo.toml index 7ba5220c..a5d07545 100644 --- a/backends/sdl/Cargo.toml +++ b/backends/sdl/Cargo.toml @@ -5,8 +5,8 @@ authors.workspace = true edition.workspace = true [dependencies] -common = { package = "surreal-common", path = "../../common" } -audio = { package = "surreal-audio", path = "../../modules/audio" } -graphics = { package = "surreal-graphics", path = "../../modules/graphics" } -input = { package = "surreal-input", path = "../../modules/input" } +common = { package = "surreal-common", path = "../../crates/common" } +audio = { package = "surreal-audio", path = "../../crates/audio" } +graphics = { package = "surreal-graphics", path = "../../crates/graphics" } +input = { package = "surreal-input", path = "../../crates/input" } sdl2-sys = { version = "0.36.0", features = ["bundled"] } diff --git a/modules/audio/Cargo.toml b/crates/audio/Cargo.toml similarity index 71% rename from modules/audio/Cargo.toml rename to crates/audio/Cargo.toml index 7caf2a2d..bfc10455 100644 --- a/modules/audio/Cargo.toml +++ b/crates/audio/Cargo.toml @@ -5,5 +5,5 @@ authors.workspace = true edition.workspace = true [dependencies] -common = { package = "surreal-common", path = "../../common" } +common = { package = "surreal-common", path = "../common" } openal-sys = "1.16.0" \ No newline at end of file diff --git a/modules/audio/src/clips.rs b/crates/audio/src/clips.rs similarity index 100% rename from modules/audio/src/clips.rs rename to crates/audio/src/clips.rs diff --git a/modules/audio/src/headless.rs b/crates/audio/src/headless.rs similarity index 100% rename from modules/audio/src/headless.rs rename to crates/audio/src/headless.rs diff --git a/modules/audio/src/lib.rs b/crates/audio/src/lib.rs similarity index 100% rename from modules/audio/src/lib.rs rename to crates/audio/src/lib.rs diff --git a/modules/audio/src/openal.rs b/crates/audio/src/openal.rs similarity index 100% rename from modules/audio/src/openal.rs rename to crates/audio/src/openal.rs diff --git a/modules/audio/src/sampling.rs b/crates/audio/src/sampling.rs similarity index 100% rename from modules/audio/src/sampling.rs rename to crates/audio/src/sampling.rs diff --git a/modules/audio/src/sources.rs b/crates/audio/src/sources.rs similarity index 100% rename from modules/audio/src/sources.rs rename to crates/audio/src/sources.rs diff --git a/common/Cargo.toml b/crates/common/Cargo.toml similarity index 100% rename from common/Cargo.toml rename to crates/common/Cargo.toml diff --git a/common/assets/test.ase b/crates/common/assets/test.ase similarity index 100% rename from common/assets/test.ase rename to crates/common/assets/test.ase diff --git a/common/src/abstractions.rs b/crates/common/src/abstractions.rs similarity index 100% rename from common/src/abstractions.rs rename to crates/common/src/abstractions.rs diff --git a/common/src/abstractions/os.rs b/crates/common/src/abstractions/os.rs similarity index 100% rename from common/src/abstractions/os.rs rename to crates/common/src/abstractions/os.rs diff --git a/common/src/abstractions/variant.rs b/crates/common/src/abstractions/variant.rs similarity index 100% rename from common/src/abstractions/variant.rs rename to crates/common/src/abstractions/variant.rs diff --git a/common/src/collections.rs b/crates/common/src/collections.rs similarity index 100% rename from common/src/collections.rs rename to crates/common/src/collections.rs diff --git a/common/src/collections/anymap.rs b/crates/common/src/collections/anymap.rs similarity index 100% rename from common/src/collections/anymap.rs rename to crates/common/src/collections/anymap.rs diff --git a/common/src/collections/arena.rs b/crates/common/src/collections/arena.rs similarity index 100% rename from common/src/collections/arena.rs rename to crates/common/src/collections/arena.rs diff --git a/common/src/collections/graphs.rs b/crates/common/src/collections/graphs.rs similarity index 100% rename from common/src/collections/graphs.rs rename to crates/common/src/collections/graphs.rs diff --git a/common/src/collections/grid.rs b/crates/common/src/collections/grid.rs similarity index 100% rename from common/src/collections/grid.rs rename to crates/common/src/collections/grid.rs diff --git a/common/src/collections/multimap.rs b/crates/common/src/collections/multimap.rs similarity index 100% rename from common/src/collections/multimap.rs rename to crates/common/src/collections/multimap.rs diff --git a/common/src/collections/priorityqueue.rs b/crates/common/src/collections/priorityqueue.rs similarity index 100% rename from common/src/collections/priorityqueue.rs rename to crates/common/src/collections/priorityqueue.rs diff --git a/common/src/collections/quadtree.rs b/crates/common/src/collections/quadtree.rs similarity index 100% rename from common/src/collections/quadtree.rs rename to crates/common/src/collections/quadtree.rs diff --git a/common/src/collections/ringbuffer.rs b/crates/common/src/collections/ringbuffer.rs similarity index 100% rename from common/src/collections/ringbuffer.rs rename to crates/common/src/collections/ringbuffer.rs diff --git a/common/src/collections/spatialhash.rs b/crates/common/src/collections/spatialhash.rs similarity index 98% rename from common/src/collections/spatialhash.rs rename to crates/common/src/collections/spatialhash.rs index 2540fd7d..c6a7e9ee 100644 --- a/common/src/collections/spatialhash.rs +++ b/crates/common/src/collections/spatialhash.rs @@ -17,7 +17,7 @@ pub enum SpatialShape { impl SpatialShape { /// Determines if this shape intersects the given other shape - pub fn intersects(&self, other: &SpatialShape) -> bool { + pub fn intersects(&self, _other: &SpatialShape) -> bool { todo!() } } diff --git a/common/src/concurrency.rs b/crates/common/src/concurrency.rs similarity index 100% rename from common/src/concurrency.rs rename to crates/common/src/concurrency.rs diff --git a/common/src/concurrency/futures.rs b/crates/common/src/concurrency/futures.rs similarity index 100% rename from common/src/concurrency/futures.rs rename to crates/common/src/concurrency/futures.rs diff --git a/common/src/diagnostics.rs b/crates/common/src/diagnostics.rs similarity index 100% rename from common/src/diagnostics.rs rename to crates/common/src/diagnostics.rs diff --git a/common/src/diagnostics/logging.rs b/crates/common/src/diagnostics/logging.rs similarity index 100% rename from common/src/diagnostics/logging.rs rename to crates/common/src/diagnostics/logging.rs diff --git a/common/src/diagnostics/profiling.rs b/crates/common/src/diagnostics/profiling.rs similarity index 100% rename from common/src/diagnostics/profiling.rs rename to crates/common/src/diagnostics/profiling.rs diff --git a/common/src/diagnostics/server.rs b/crates/common/src/diagnostics/server.rs similarity index 100% rename from common/src/diagnostics/server.rs rename to crates/common/src/diagnostics/server.rs diff --git a/common/src/diagnostics/telemetry.rs b/crates/common/src/diagnostics/telemetry.rs similarity index 100% rename from common/src/diagnostics/telemetry.rs rename to crates/common/src/diagnostics/telemetry.rs diff --git a/common/src/io.rs b/crates/common/src/io.rs similarity index 100% rename from common/src/io.rs rename to crates/common/src/io.rs diff --git a/common/src/io/serde.rs b/crates/common/src/io/serde.rs similarity index 100% rename from common/src/io/serde.rs rename to crates/common/src/io/serde.rs diff --git a/common/src/io/streams.rs b/crates/common/src/io/streams.rs similarity index 100% rename from common/src/io/streams.rs rename to crates/common/src/io/streams.rs diff --git a/common/src/io/virtualfs.rs b/crates/common/src/io/virtualfs.rs similarity index 100% rename from common/src/io/virtualfs.rs rename to crates/common/src/io/virtualfs.rs diff --git a/common/src/io/virtualfs/local.rs b/crates/common/src/io/virtualfs/local.rs similarity index 95% rename from common/src/io/virtualfs/local.rs rename to crates/common/src/io/virtualfs/local.rs index b240d7ca..fc9cec73 100644 --- a/common/src/io/virtualfs/local.rs +++ b/crates/common/src/io/virtualfs/local.rs @@ -59,7 +59,7 @@ mod tests { #[test] fn test_read_file_from_disk() { - let path = "local://../assets/fonts/bitboy8_v1.otf".to_virtual_path(); + let path = "local://../../assets/fonts/bitboy8_v1.otf".to_virtual_path(); let bytes = path.read_all_bytes().unwrap(); assert!(!bytes.is_empty()); diff --git a/common/src/io/virtualfs/memory.rs b/crates/common/src/io/virtualfs/memory.rs similarity index 100% rename from common/src/io/virtualfs/memory.rs rename to crates/common/src/io/virtualfs/memory.rs diff --git a/common/src/lib.rs b/crates/common/src/lib.rs similarity index 100% rename from common/src/lib.rs rename to crates/common/src/lib.rs diff --git a/common/src/maths.rs b/crates/common/src/maths.rs similarity index 100% rename from common/src/maths.rs rename to crates/common/src/maths.rs diff --git a/common/src/maths/angles.rs b/crates/common/src/maths/angles.rs similarity index 100% rename from common/src/maths/angles.rs rename to crates/common/src/maths/angles.rs diff --git a/common/src/maths/cameras.rs b/crates/common/src/maths/cameras.rs similarity index 100% rename from common/src/maths/cameras.rs rename to crates/common/src/maths/cameras.rs diff --git a/common/src/maths/curves.rs b/crates/common/src/maths/curves.rs similarity index 100% rename from common/src/maths/curves.rs rename to crates/common/src/maths/curves.rs diff --git a/common/src/maths/geometry.rs b/crates/common/src/maths/geometry.rs similarity index 100% rename from common/src/maths/geometry.rs rename to crates/common/src/maths/geometry.rs diff --git a/common/src/maths/hex.rs b/crates/common/src/maths/hex.rs similarity index 100% rename from common/src/maths/hex.rs rename to crates/common/src/maths/hex.rs diff --git a/common/src/maths/lerp.rs b/crates/common/src/maths/lerp.rs similarity index 100% rename from common/src/maths/lerp.rs rename to crates/common/src/maths/lerp.rs diff --git a/common/src/maths/linear.rs b/crates/common/src/maths/linear.rs similarity index 100% rename from common/src/maths/linear.rs rename to crates/common/src/maths/linear.rs diff --git a/common/src/maths/linear/aabb.rs b/crates/common/src/maths/linear/aabb.rs similarity index 100% rename from common/src/maths/linear/aabb.rs rename to crates/common/src/maths/linear/aabb.rs diff --git a/common/src/maths/linear/frustum.rs b/crates/common/src/maths/linear/frustum.rs similarity index 100% rename from common/src/maths/linear/frustum.rs rename to crates/common/src/maths/linear/frustum.rs diff --git a/common/src/maths/linear/planes.rs b/crates/common/src/maths/linear/planes.rs similarity index 100% rename from common/src/maths/linear/planes.rs rename to crates/common/src/maths/linear/planes.rs diff --git a/common/src/maths/linear/rays.rs b/crates/common/src/maths/linear/rays.rs similarity index 100% rename from common/src/maths/linear/rays.rs rename to crates/common/src/maths/linear/rays.rs diff --git a/common/src/maths/linear/scalars.rs b/crates/common/src/maths/linear/scalars.rs similarity index 100% rename from common/src/maths/linear/scalars.rs rename to crates/common/src/maths/linear/scalars.rs diff --git a/common/src/maths/linear/vectors.rs b/crates/common/src/maths/linear/vectors.rs similarity index 100% rename from common/src/maths/linear/vectors.rs rename to crates/common/src/maths/linear/vectors.rs diff --git a/common/src/maths/neighbours.rs b/crates/common/src/maths/neighbours.rs similarity index 100% rename from common/src/maths/neighbours.rs rename to crates/common/src/maths/neighbours.rs diff --git a/common/src/maths/paths.rs b/crates/common/src/maths/paths.rs similarity index 100% rename from common/src/maths/paths.rs rename to crates/common/src/maths/paths.rs diff --git a/common/src/maths/random.rs b/crates/common/src/maths/random.rs similarity index 100% rename from common/src/maths/random.rs rename to crates/common/src/maths/random.rs diff --git a/common/src/maths/ranges.rs b/crates/common/src/maths/ranges.rs similarity index 100% rename from common/src/maths/ranges.rs rename to crates/common/src/maths/ranges.rs diff --git a/common/src/maths/rectangles.rs b/crates/common/src/maths/rectangles.rs similarity index 100% rename from common/src/maths/rectangles.rs rename to crates/common/src/maths/rectangles.rs diff --git a/common/src/maths/shapes.rs b/crates/common/src/maths/shapes.rs similarity index 100% rename from common/src/maths/shapes.rs rename to crates/common/src/maths/shapes.rs diff --git a/common/src/maths/size.rs b/crates/common/src/maths/size.rs similarity index 100% rename from common/src/maths/size.rs rename to crates/common/src/maths/size.rs diff --git a/common/src/maths/splines.rs b/crates/common/src/maths/splines.rs similarity index 100% rename from common/src/maths/splines.rs rename to crates/common/src/maths/splines.rs diff --git a/common/src/maths/time.rs b/crates/common/src/maths/time.rs similarity index 100% rename from common/src/maths/time.rs rename to crates/common/src/maths/time.rs diff --git a/common/src/maths/time/clocks.rs b/crates/common/src/maths/time/clocks.rs similarity index 100% rename from common/src/maths/time/clocks.rs rename to crates/common/src/maths/time/clocks.rs diff --git a/common/src/maths/time/counters.rs b/crates/common/src/maths/time/counters.rs similarity index 100% rename from common/src/maths/time/counters.rs rename to crates/common/src/maths/time/counters.rs diff --git a/common/src/maths/time/spans.rs b/crates/common/src/maths/time/spans.rs similarity index 100% rename from common/src/maths/time/spans.rs rename to crates/common/src/maths/time/spans.rs diff --git a/common/src/maths/time/stamps.rs b/crates/common/src/maths/time/stamps.rs similarity index 100% rename from common/src/maths/time/stamps.rs rename to crates/common/src/maths/time/stamps.rs diff --git a/common/src/strings.rs b/crates/common/src/strings.rs similarity index 100% rename from common/src/strings.rs rename to crates/common/src/strings.rs diff --git a/common/src/strings/names.rs b/crates/common/src/strings/names.rs similarity index 100% rename from common/src/strings/names.rs rename to crates/common/src/strings/names.rs diff --git a/common/src/strings/spans.rs b/crates/common/src/strings/spans.rs similarity index 100% rename from common/src/strings/spans.rs rename to crates/common/src/strings/spans.rs diff --git a/common/src/utilities.rs b/crates/common/src/utilities.rs similarity index 100% rename from common/src/utilities.rs rename to crates/common/src/utilities.rs diff --git a/common/src/utilities/errors.rs b/crates/common/src/utilities/errors.rs similarity index 100% rename from common/src/utilities/errors.rs rename to crates/common/src/utilities/errors.rs diff --git a/common/src/utilities/events.rs b/crates/common/src/utilities/events.rs similarity index 100% rename from common/src/utilities/events.rs rename to crates/common/src/utilities/events.rs diff --git a/common/src/utilities/reflect.rs b/crates/common/src/utilities/reflect.rs similarity index 100% rename from common/src/utilities/reflect.rs rename to crates/common/src/utilities/reflect.rs diff --git a/common/src/utilities/settings.rs b/crates/common/src/utilities/settings.rs similarity index 100% rename from common/src/utilities/settings.rs rename to crates/common/src/utilities/settings.rs diff --git a/common/src/utilities/version.rs b/crates/common/src/utilities/version.rs similarity index 100% rename from common/src/utilities/version.rs rename to crates/common/src/utilities/version.rs diff --git a/modules/graphics/Cargo.toml b/crates/graphics/Cargo.toml similarity index 74% rename from modules/graphics/Cargo.toml rename to crates/graphics/Cargo.toml index f86ff7ec..95df9b23 100644 --- a/modules/graphics/Cargo.toml +++ b/crates/graphics/Cargo.toml @@ -5,8 +5,8 @@ authors.workspace = true edition.workspace = true [dependencies] -common = { package = "surreal-common", path = "../../common" } -macros = { package = "surreal-macros", path = "../../macros" } +common = { package = "surreal-common", path = "../common" } +macros = { package = "surreal-macros", path = "../macros" } serde = { workspace = true, optional = true } bitflags = { workspace = true } image = { version = "0.25.1", default-features = false, features = ["png"] } diff --git a/modules/graphics/src/animations.rs b/crates/graphics/src/animations.rs similarity index 90% rename from modules/graphics/src/animations.rs rename to crates/graphics/src/animations.rs index 9e4c1774..8bfe39c0 100644 --- a/modules/graphics/src/animations.rs +++ b/crates/graphics/src/animations.rs @@ -4,6 +4,34 @@ use common::{FastHashMap, Identity, Lerp, Quat, StringName, TimeSpan, Vec2, Vec3 use crate::{Color, Color32}; +/// Represents a type that can be animated by an animation tree. +pub trait Animatable { + /// Applies the given value to the animatable type. + fn apply(&mut self, track: AnimationTrack, time: f32); +} + +impl Animatable for Vec2 { + fn apply(&mut self, track: AnimationTrack, time: f32) { + match track { + AnimationTrack::Vec2(data) => { + *self = evaluate_keyframes(time, &data); + } + _ => {} + } + } +} + +impl Animatable for Vec3 { + fn apply(&mut self, track: AnimationTrack, time: f32) { + match track { + AnimationTrack::Vec3(data) => { + *self = evaluate_keyframes(time, &data); + } + _ => {} + } + } +} + /// An animation tree that can be used to drive animation state changes. /// /// The animation tree is a directed acyclic graph (DAG) where each node is an @@ -118,18 +146,6 @@ impl AnimationTree { state.time_elapsed = TimeSpan::ZERO; } - // evaluate all tracks and apply them to the state - for track in &state.clip.tracks { - match track { - AnimationTrack::Scalar(_) => {} - AnimationTrack::Vec2(_) => {} - AnimationTrack::Vec3(_) => {} - AnimationTrack::Quat(_) => {} - AnimationTrack::Color(_) => {} - AnimationTrack::Color32(_) => {} - } - } - // evaluate all transitions each tick for transition in &state.transitions { let AnimationTransition { condition, target } = transition; diff --git a/modules/graphics/src/buffers.rs b/crates/graphics/src/buffers.rs similarity index 100% rename from modules/graphics/src/buffers.rs rename to crates/graphics/src/buffers.rs diff --git a/modules/graphics/src/colors.rs b/crates/graphics/src/colors.rs similarity index 100% rename from modules/graphics/src/colors.rs rename to crates/graphics/src/colors.rs diff --git a/modules/graphics/src/fonts.rs b/crates/graphics/src/fonts.rs similarity index 100% rename from modules/graphics/src/fonts.rs rename to crates/graphics/src/fonts.rs diff --git a/modules/graphics/src/fonts/otf.rs b/crates/graphics/src/fonts/otf.rs similarity index 100% rename from modules/graphics/src/fonts/otf.rs rename to crates/graphics/src/fonts/otf.rs diff --git a/modules/graphics/src/geometry.rs b/crates/graphics/src/geometry.rs similarity index 100% rename from modules/graphics/src/geometry.rs rename to crates/graphics/src/geometry.rs diff --git a/modules/graphics/src/headless.rs b/crates/graphics/src/headless.rs similarity index 100% rename from modules/graphics/src/headless.rs rename to crates/graphics/src/headless.rs diff --git a/modules/graphics/src/images.rs b/crates/graphics/src/images.rs similarity index 100% rename from modules/graphics/src/images.rs rename to crates/graphics/src/images.rs diff --git a/modules/graphics/src/lib.rs b/crates/graphics/src/lib.rs similarity index 100% rename from modules/graphics/src/lib.rs rename to crates/graphics/src/lib.rs diff --git a/modules/graphics/src/materials.rs b/crates/graphics/src/materials.rs similarity index 100% rename from modules/graphics/src/materials.rs rename to crates/graphics/src/materials.rs diff --git a/modules/graphics/src/meshes.rs b/crates/graphics/src/meshes.rs similarity index 100% rename from modules/graphics/src/meshes.rs rename to crates/graphics/src/meshes.rs diff --git a/modules/graphics/src/opengl.rs b/crates/graphics/src/opengl.rs similarity index 100% rename from modules/graphics/src/opengl.rs rename to crates/graphics/src/opengl.rs diff --git a/modules/graphics/src/rendering.rs b/crates/graphics/src/rendering.rs similarity index 100% rename from modules/graphics/src/rendering.rs rename to crates/graphics/src/rendering.rs diff --git a/modules/graphics/src/rendering/contexts.rs b/crates/graphics/src/rendering/contexts.rs similarity index 100% rename from modules/graphics/src/rendering/contexts.rs rename to crates/graphics/src/rendering/contexts.rs diff --git a/modules/graphics/src/rendering/culling.rs b/crates/graphics/src/rendering/culling.rs similarity index 100% rename from modules/graphics/src/rendering/culling.rs rename to crates/graphics/src/rendering/culling.rs diff --git a/modules/graphics/src/rendering/pipelines.rs b/crates/graphics/src/rendering/pipelines.rs similarity index 100% rename from modules/graphics/src/rendering/pipelines.rs rename to crates/graphics/src/rendering/pipelines.rs diff --git a/modules/graphics/src/rendering/queue.rs b/crates/graphics/src/rendering/queue.rs similarity index 87% rename from modules/graphics/src/rendering/queue.rs rename to crates/graphics/src/rendering/queue.rs index 87ab37ca..8a8be53d 100644 --- a/modules/graphics/src/rendering/queue.rs +++ b/crates/graphics/src/rendering/queue.rs @@ -164,22 +164,23 @@ impl RenderQueue { /// Flushes all [`RenderCommand`]s in the queue to the given renderer. pub fn flush(&mut self) -> Result<(), RenderQueueError> { let mut commands = self.commands.lock().unwrap(); + let graphics = graphics(); for command in commands.drain(..) { common::profile_scope!("RenderCommand::{:?}", command.type_name()); match command { RenderCommand::SetRenderTarget { target_id } => { - graphics().target_activate(target_id)?; + graphics.target_activate(target_id)?; } RenderCommand::SetRenderTargetToDisplay => { - graphics().target_set_default()?; + graphics.target_set_default()?; } RenderCommand::ClearColorBuffer { color } => { - graphics().clear_color_buffer(color); + graphics.clear_color_buffer(color); } RenderCommand::ClearDepthBuffer { depth } => { - graphics().clear_depth_buffer(depth); + graphics.clear_depth_buffer(depth); } RenderCommand::SetShader { shader_id, @@ -188,46 +189,46 @@ impl RenderQueue { culling_mode, scissor_mode, } => { - graphics().set_blend_state(blend_state); - graphics().set_culling_mode(culling_mode); - graphics().set_scissor_mode(scissor_mode); + graphics.set_blend_state(blend_state); + graphics.set_culling_mode(culling_mode); + graphics.set_scissor_mode(scissor_mode); for (key, uniform) in uniforms.iter() { - let location = graphics() + let location = graphics .shader_uniform_location(shader_id, key) .ok_or(ShaderError::InvalidUniform)?; - graphics().shader_set_uniform(shader_id, location, uniform)?; + graphics.shader_set_uniform(shader_id, location, uniform)?; } - graphics().shader_activate(shader_id)?; + graphics.shader_activate(shader_id)?; } RenderCommand::SetUniformByKey { shader_id, key, uniform, } => { - let location = graphics() + let location = graphics .shader_uniform_location(shader_id, &key) .ok_or(ShaderError::InvalidUniform)?; - graphics().shader_set_uniform(shader_id, location, &uniform)?; + graphics.shader_set_uniform(shader_id, location, &uniform)?; } RenderCommand::SetUniformByLocation { shader_id, location, uniform, } => { - graphics().shader_set_uniform(shader_id, location, &uniform)?; + graphics.shader_set_uniform(shader_id, location, &uniform)?; } RenderCommand::DispatchCompute { shader_id, group_count: (x, y, z), } => { - graphics().shader_dispatch_compute(shader_id, x, y, z)?; + graphics.shader_dispatch_compute(shader_id, x, y, z)?; } RenderCommand::MemoryBarrier { barrier } => { - graphics().shader_memory_barrier(barrier)?; + graphics.shader_memory_barrier(barrier)?; } RenderCommand::DrawMesh { mesh_id, @@ -235,10 +236,10 @@ impl RenderQueue { vertex_count, index_count, } => { - graphics().mesh_draw(mesh_id, topology, vertex_count, index_count)?; + graphics.mesh_draw(mesh_id, topology, vertex_count, index_count)?; } RenderCommand::BlitRenderTargetToActive { target_id, filter } => { - graphics().target_blit_to_active(target_id, None, None, filter)?; + graphics.target_blit_to_active(target_id, None, None, filter)?; } } } @@ -261,9 +262,11 @@ mod tests { #[test] fn test_basic_commands() { let mut queue = RenderQueue::default(); + let mesh = Mesh::create_circle(1.0, 16); queue.set_render_target_to_display(); queue.clear_color_buffer(Color::BLACK); + queue.draw_mesh(&mesh, PrimitiveTopology::Triangles); queue.flush().unwrap(); } diff --git a/modules/graphics/src/shaders.rs b/crates/graphics/src/shaders.rs similarity index 100% rename from modules/graphics/src/shaders.rs rename to crates/graphics/src/shaders.rs diff --git a/modules/graphics/src/shaders/embedded/canvas-standard.glsl b/crates/graphics/src/shaders/embedded/canvas-standard.glsl similarity index 100% rename from modules/graphics/src/shaders/embedded/canvas-standard.glsl rename to crates/graphics/src/shaders/embedded/canvas-standard.glsl diff --git a/modules/graphics/src/shaders/embedded/mesh-skinned.glsl b/crates/graphics/src/shaders/embedded/mesh-skinned.glsl similarity index 100% rename from modules/graphics/src/shaders/embedded/mesh-skinned.glsl rename to crates/graphics/src/shaders/embedded/mesh-skinned.glsl diff --git a/modules/graphics/src/shaders/embedded/sprite-multitex-palette.glsl b/crates/graphics/src/shaders/embedded/sprite-multitex-palette.glsl similarity index 100% rename from modules/graphics/src/shaders/embedded/sprite-multitex-palette.glsl rename to crates/graphics/src/shaders/embedded/sprite-multitex-palette.glsl diff --git a/modules/graphics/src/shaders/embedded/sprite-multitex.glsl b/crates/graphics/src/shaders/embedded/sprite-multitex.glsl similarity index 100% rename from modules/graphics/src/shaders/embedded/sprite-multitex.glsl rename to crates/graphics/src/shaders/embedded/sprite-multitex.glsl diff --git a/modules/graphics/src/shaders/embedded/sprite-standard-palette.glsl b/crates/graphics/src/shaders/embedded/sprite-standard-palette.glsl similarity index 100% rename from modules/graphics/src/shaders/embedded/sprite-standard-palette.glsl rename to crates/graphics/src/shaders/embedded/sprite-standard-palette.glsl diff --git a/modules/graphics/src/shaders/embedded/sprite-standard.glsl b/crates/graphics/src/shaders/embedded/sprite-standard.glsl similarity index 100% rename from modules/graphics/src/shaders/embedded/sprite-standard.glsl rename to crates/graphics/src/shaders/embedded/sprite-standard.glsl diff --git a/modules/graphics/src/shaders/embedded/sprite-standard.shady b/crates/graphics/src/shaders/embedded/sprite-standard.shady similarity index 100% rename from modules/graphics/src/shaders/embedded/sprite-standard.shady rename to crates/graphics/src/shaders/embedded/sprite-standard.shady diff --git a/modules/graphics/src/shaders/lang/glsl.rs b/crates/graphics/src/shaders/lang/glsl.rs similarity index 100% rename from modules/graphics/src/shaders/lang/glsl.rs rename to crates/graphics/src/shaders/lang/glsl.rs diff --git a/modules/graphics/src/shaders/lang/shady.rs b/crates/graphics/src/shaders/lang/shady.rs similarity index 100% rename from modules/graphics/src/shaders/lang/shady.rs rename to crates/graphics/src/shaders/lang/shady.rs diff --git a/modules/graphics/src/shaders/templates.rs b/crates/graphics/src/shaders/templates.rs similarity index 100% rename from modules/graphics/src/shaders/templates.rs rename to crates/graphics/src/shaders/templates.rs diff --git a/modules/graphics/src/sprites.rs b/crates/graphics/src/sprites.rs similarity index 100% rename from modules/graphics/src/sprites.rs rename to crates/graphics/src/sprites.rs diff --git a/modules/graphics/src/targets.rs b/crates/graphics/src/targets.rs similarity index 100% rename from modules/graphics/src/targets.rs rename to crates/graphics/src/targets.rs diff --git a/modules/graphics/src/textures.rs b/crates/graphics/src/textures.rs similarity index 100% rename from modules/graphics/src/textures.rs rename to crates/graphics/src/textures.rs diff --git a/modules/input/Cargo.toml b/crates/input/Cargo.toml similarity index 68% rename from modules/input/Cargo.toml rename to crates/input/Cargo.toml index c1439e17..4f308ed1 100644 --- a/modules/input/Cargo.toml +++ b/crates/input/Cargo.toml @@ -5,4 +5,4 @@ authors.workspace = true edition.workspace = true [dependencies] -common = { package = "surreal-common", path = "../../common" } +common = { package = "surreal-common", path = "../common" } diff --git a/modules/input/src/keyboards.rs b/crates/input/src/keyboards.rs similarity index 100% rename from modules/input/src/keyboards.rs rename to crates/input/src/keyboards.rs diff --git a/modules/input/src/lib.rs b/crates/input/src/lib.rs similarity index 100% rename from modules/input/src/lib.rs rename to crates/input/src/lib.rs diff --git a/modules/input/src/mouse.rs b/crates/input/src/mouse.rs similarity index 100% rename from modules/input/src/mouse.rs rename to crates/input/src/mouse.rs diff --git a/macros/Cargo.toml b/crates/macros/Cargo.toml similarity index 100% rename from macros/Cargo.toml rename to crates/macros/Cargo.toml diff --git a/macros/src/lib.rs b/crates/macros/src/lib.rs similarity index 100% rename from macros/src/lib.rs rename to crates/macros/src/lib.rs diff --git a/macros/src/profiling.rs b/crates/macros/src/profiling.rs similarity index 100% rename from macros/src/profiling.rs rename to crates/macros/src/profiling.rs diff --git a/macros/src/reflect.rs b/crates/macros/src/reflect.rs similarity index 100% rename from macros/src/reflect.rs rename to crates/macros/src/reflect.rs diff --git a/macros/src/singleton.rs b/crates/macros/src/singleton.rs similarity index 100% rename from macros/src/singleton.rs rename to crates/macros/src/singleton.rs diff --git a/macros/src/vertex.rs b/crates/macros/src/vertex.rs similarity index 100% rename from macros/src/vertex.rs rename to crates/macros/src/vertex.rs diff --git a/editor/Cargo.toml b/editor/Cargo.toml index 3dbd5723..30fd0de8 100644 --- a/editor/Cargo.toml +++ b/editor/Cargo.toml @@ -7,10 +7,10 @@ version.workspace = true [dependencies] # core dependencies -common = { package = "surreal-common", path = "../common" } -audio = { package = "surreal-audio", path = "../modules/audio" } -graphics = { package = "surreal-graphics", path = "../modules/graphics" } -input = { package = "surreal-input", path = "../modules/input" } +common = { package = "surreal-common", path = "../crates/common" } +audio = { package = "surreal-audio", path = "../crates/audio" } +graphics = { package = "surreal-graphics", path = "../crates/graphics" } +input = { package = "surreal-input", path = "../crates/input" } sdl = { package = "surreal-backend-sdl", path = "../backends/sdl" } # third-party dependencies