summaryrefslogtreecommitdiff
path: root/alligator_render/src/renderer.rs
diff options
context:
space:
mode:
authorMicha White <botahamec@outlook.com>2023-02-04 13:25:45 -0500
committerMicha White <botahamec@outlook.com>2023-02-04 13:25:45 -0500
commit9fd7d6689d5d90679e4b0c12e463ef4e2f8bf515 (patch)
treea0b127f1094b72d0966c2edea3d171e74001c875 /alligator_render/src/renderer.rs
parent518a87ddb2e6ce908affce2773fc7f92beb52c73 (diff)
Have the renderer take the texture manager
Diffstat (limited to 'alligator_render/src/renderer.rs')
-rw-r--r--alligator_render/src/renderer.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/alligator_render/src/renderer.rs b/alligator_render/src/renderer.rs
index a7d952a..f448119 100644
--- a/alligator_render/src/renderer.rs
+++ b/alligator_render/src/renderer.rs
@@ -1,8 +1,10 @@
-use std::{convert::TryInto, num::NonZeroU32};
+use std::convert::TryInto;
+use std::num::NonZeroU32;
use crate::{
vertex::SQUARE, Camera, Instance, InstanceBuffer, RenderWindowConfig, TextureAtlas, Vertex,
};
+use alligator_resources::texture::TextureManager;
use pollster::FutureExt;
use thiserror::Error;
use wgpu::{include_wgsl, util::DeviceExt};
@@ -146,7 +148,10 @@ impl Renderer {
/// panic on some platforms.
// TODO make it possible to use without a window (ie, use a bitmap in memory as a surface)
// TODO this function needs to be smaller
- pub fn new(config: &RenderWindowConfig) -> Result<Self, NewRendererError> {
+ pub fn new(
+ config: &RenderWindowConfig,
+ textures: TextureManager,
+ ) -> Result<Self, NewRendererError> {
// build the window
let event_loop = EventLoop::new();
let window = config.to_window().build(&event_loop)?;
@@ -214,6 +219,7 @@ impl Renderer {
// TODO make this configurable
let (textures, texture_layout) = TextureAtlas::new(
&device,
+ textures,
window.inner_size().width,
window.inner_size().height,
);
@@ -321,6 +327,7 @@ impl Renderer {
/// trying to acquire the next frame. There may also be no more memory left
/// that can be used for the new frame.
// TODO this needs to be smaller
+ // TODO don't return wgpu errors
#[profiling::function]
fn render(&mut self) -> Result<(), wgpu::SurfaceError> {
// this will allow us to send commands to the gpu