summaryrefslogtreecommitdiff
path: root/engine/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-02-19 23:06:17 +0100
committerHampusM <hampus@hampusmat.com>2024-02-19 23:06:17 +0100
commit88d6ae3e4854c5fb4b37f75a29aba4f13dcfb382 (patch)
tree033431187e1f6fc4aa4f36a7f46490af5ef338ce /engine/src/lib.rs
parente8c6c096b2068f4ea71b021bf02f56d266ed671c (diff)
refactor(engine): create shaders on start
Diffstat (limited to 'engine/src/lib.rs')
-rw-r--r--engine/src/lib.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/engine/src/lib.rs b/engine/src/lib.rs
index fada83f..a1d9e2f 100644
--- a/engine/src/lib.rs
+++ b/engine/src/lib.rs
@@ -25,6 +25,7 @@ pub mod material;
pub mod math;
pub mod mesh;
pub mod object;
+pub mod shader;
pub mod texture;
pub mod vertex;
@@ -140,6 +141,10 @@ where
/// Will return `Err` if updating the window fails.
pub fn start(&mut self, mut func: impl FnMut(&mut Self)) -> Result<(), Error>
{
+ self.renderer
+ .create_shader_programs(self.objects.values().map(Object::shader))
+ .map_err(Error::ShaderCreationFailed)?;
+
let mut prev_frame_start: Option<Instant> = None;
while !self.window.should_close() {
@@ -288,6 +293,9 @@ pub enum Error
#[error("Rendering failed")]
RenderingFailed(#[source] renderer::Error),
+
+ #[error("Failed to create shaders")]
+ ShaderCreationFailed(#[source] renderer::Error),
}
#[derive(Debug)]