aboutsummaryrefslogtreecommitdiff
path: root/stockton-render/src/lib.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 17:44:23 +0100
committertcmal <me@aria.rip>2024-08-25 17:44:23 +0100
commit0353181306702c40ad0fe482b5c2b159b46794a4 (patch)
tree33acc6a9e8ea4705884cf93b78cf869008f71832 /stockton-render/src/lib.rs
parent664f0b0777ba96298b29f0c753d52a81cbb233f1 (diff)
refactor(all): rename some crates
Diffstat (limited to 'stockton-render/src/lib.rs')
-rw-r--r--stockton-render/src/lib.rs95
1 files changed, 6 insertions, 89 deletions
diff --git a/stockton-render/src/lib.rs b/stockton-render/src/lib.rs
index 03f6d53..e3e5bf8 100644
--- a/stockton-render/src/lib.rs
+++ b/stockton-render/src/lib.rs
@@ -1,92 +1,9 @@
-#[cfg(feature = "vulkan")]
-extern crate gfx_backend_vulkan as back;
+#[macro_use]
+extern crate legion;
extern crate gfx_hal as hal;
extern crate nalgebra_glm as na;
-#[macro_use]
-extern crate derive_builder;
-
-pub mod buffers;
-pub mod builders;
-pub mod context;
-pub mod draw_passes;
-pub mod error;
-pub mod queue_negotiator;
-mod target;
-pub mod texture;
-pub mod types;
-pub mod utils;
-
-use context::RenderingContext;
-use draw_passes::{DrawPass, IntoDrawPass};
-
-use anyhow::{Context, Result};
-
-use stockton_types::Session;
-use winit::window::Window;
-
-/// Renders a world to a window when you tell it to.
-/// Also takes ownership of the window and channels window events to be processed outside winit's event loop.
-pub struct Renderer<DP> {
- /// All the vulkan stuff
- context: RenderingContext,
-
- /// The draw pass we're using
- draw_pass: DP,
-}
-
-impl<DP: DrawPass> Renderer<DP> {
- /// Create a new Renderer.
- pub fn new<IDP: IntoDrawPass<DP>>(
- window: &Window,
- session: &mut Session,
- idp: IDP,
- ) -> Result<Self> {
- let mut context = RenderingContext::new::<IDP, DP>(window)?;
-
- // Draw pass
- let draw_pass = idp
- .init(session, &mut context)
- .context("Error initialising draw pass")?;
-
- Ok(Renderer { context, draw_pass })
- }
-
- /// Render a single frame of the given session.
- pub fn render(&mut self, session: &Session) -> Result<()> {
- // Try to draw
- if self
- .context
- .draw_next_frame(session, &mut self.draw_pass)
- .is_err()
- {
- // Probably the surface changed
- self.handle_surface_change(session)?;
-
- // If it fails twice, then error
- self.context.draw_next_frame(session, &mut self.draw_pass)?;
- }
-
- Ok(())
- }
-
- pub fn get_aspect_ratio(&self) -> f32 {
- let e = self.context.target_chain().properties().extent;
- e.width as f32 / e.height as f32
- }
-
- pub fn handle_surface_change(&mut self, session: &Session) -> Result<()> {
- unsafe {
- self.context.handle_surface_change()?;
- self.draw_pass
- .handle_surface_change(session, &mut self.context)?;
- }
-
- Ok(())
- }
-
- /// Get a reference to the renderer's context.
- pub fn context(&self) -> &RenderingContext {
- &self.context
- }
-}
+pub mod camera;
+pub mod level;
+pub mod ui;
+pub mod window;