aboutsummaryrefslogtreecommitdiff
path: root/stockton-render/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'stockton-render/src/lib.rs')
-rw-r--r--stockton-render/src/lib.rs27
1 files changed, 15 insertions, 12 deletions
diff --git a/stockton-render/src/lib.rs b/stockton-render/src/lib.rs
index 850d3eb..17dbf03 100644
--- a/stockton-render/src/lib.rs
+++ b/stockton-render/src/lib.rs
@@ -6,6 +6,9 @@ extern crate gfx_hal as hal;
extern crate nalgebra_glm as na;
#[macro_use]
+extern crate derive_builder;
+
+#[macro_use]
extern crate legion;
pub mod draw;
@@ -15,22 +18,18 @@ mod types;
pub mod window;
use draw::{
+ draw_passes::{DrawPass, IntoDrawPass},
RenderingContext,
- draw_passes::{DrawPass, IntoDrawPass}
};
-use error::full_error_display;
-use legion::world::SubWorld;
-use legion::IntoQuery;
+
use std::sync::mpsc::{Receiver, Sender};
use std::sync::Arc;
use std::sync::RwLock;
pub use window::{UiState, WindowEvent};
use anyhow::Result;
-use log::error;
-use stockton_levels::prelude::*;
-use stockton_types::components::{CameraSettings, Transform};
-use stockton_types::{Vector3, Session};
+
+use stockton_types::Session;
use winit::event_loop::ControlFlow;
use winit::window::Window;
@@ -51,13 +50,17 @@ pub struct Renderer<DP> {
impl<DP: DrawPass> Renderer<DP> {
/// Create a new Renderer.
- pub fn new<IDP: IntoDrawPass<DP>>(window: &Window, ui: &mut UiState, idp: IDP) -> Result<(Self, Sender<WindowEvent>)> {
+ pub fn new<IDP: IntoDrawPass<DP>>(
+ window: &Window,
+ session: &Session,
+ idp: IDP,
+ ) -> Result<(Self, Sender<WindowEvent>)> {
let (tx, rx) = channel();
let update_control_flow = Arc::new(RwLock::new(ControlFlow::Poll));
Ok((
Renderer {
- context: RenderingContext::new(window, idp)?,
+ context: RenderingContext::new(window, session, idp)?,
window_events: rx,
update_control_flow,
},
@@ -66,7 +69,7 @@ impl<DP: DrawPass> Renderer<DP> {
}
/// Render a single frame of the given session.
- fn render(&mut self, session: &Session) -> Result<()> {
+ pub fn render(&mut self, session: &Session) -> Result<()> {
// Try to draw
if self.context.draw_next_frame(session).is_err() {
// Probably the surface changed
@@ -82,4 +85,4 @@ impl<DP: DrawPass> Renderer<DP> {
fn resize(&mut self) -> Result<()> {
unsafe { self.context.handle_surface_change() }
}
-} \ No newline at end of file
+}