Start moving towards a generic voxel renderer implementation

This commit is contained in:
Jarrod Doyle 2024-04-06 09:31:44 +01:00
parent e5c06fa365
commit 8a4909dced
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
6 changed files with 20 additions and 14 deletions

View File

@ -9,8 +9,8 @@ use winit::{
use super::camera;
use crate::{
gfx::{self, Renderer},
voxel::{self, brickmap::BrickmapRenderer},
gfx,
voxel::{self, brickmap::BrickmapRenderer, VoxelRenderer},
};
pub struct App<'window> {

View File

@ -1,13 +1,11 @@
mod bind_group;
mod buffer;
mod context;
mod renderer;
mod texture;
pub use self::{
bind_group::{BindGroupBuilder, BindGroupLayoutBuilder},
buffer::{BufferExt, BulkBufferBuilder},
context::Context,
renderer::Renderer,
texture::{Texture, TextureBuilder},
};

View File

@ -1,8 +0,0 @@
use std::time::Duration;
use anyhow::Result;
pub trait Renderer {
fn update(&mut self, dt: &Duration, context: &super::Context) -> Result<()>;
fn render(&self, context: &super::Context) -> Result<()>;
}

View File

@ -2,7 +2,10 @@ use std::time::Duration;
use anyhow::Result;
use crate::{core, gfx, voxel::world::WorldManager};
use crate::{
core, gfx,
voxel::{renderer::VoxelRenderer, world::WorldManager},
};
use super::BrickmapManager;
@ -189,7 +192,7 @@ impl BrickmapRenderer {
}
}
impl gfx::Renderer for BrickmapRenderer {
impl VoxelRenderer for BrickmapRenderer {
fn render(&self, context: &gfx::Context) -> Result<()> {
let frame = context.surface.get_current_texture()?;
let view = frame

View File

@ -1,2 +1,5 @@
pub mod brickmap;
mod renderer;
pub mod world;
pub use renderer::VoxelRenderer;

10
src/voxel/renderer.rs Normal file
View File

@ -0,0 +1,10 @@
use std::time::Duration;
use anyhow::Result;
use crate::gfx::Context;
pub trait VoxelRenderer {
fn update(&mut self, dt: &Duration, context: &Context) -> Result<()>;
fn render(&self, context: &Context) -> Result<()>;
}