From 9fd7d6689d5d90679e4b0c12e463ef4e2f8bf515 Mon Sep 17 00:00:00 2001 From: Micha White Date: Sat, 4 Feb 2023 13:25:45 -0500 Subject: Have the renderer take the texture manager --- alligator_render/src/renderer.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'alligator_render/src/renderer.rs') 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 { + pub fn new( + config: &RenderWindowConfig, + textures: TextureManager, + ) -> Result { // 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 -- cgit v1.2.3