Start moving towards a generic voxel renderer implementation
This commit is contained in:
parent
e5c06fa365
commit
8a4909dced
|
@ -9,8 +9,8 @@ use winit::{
|
||||||
|
|
||||||
use super::camera;
|
use super::camera;
|
||||||
use crate::{
|
use crate::{
|
||||||
gfx::{self, Renderer},
|
gfx,
|
||||||
voxel::{self, brickmap::BrickmapRenderer},
|
voxel::{self, brickmap::BrickmapRenderer, VoxelRenderer},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct App<'window> {
|
pub struct App<'window> {
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
mod bind_group;
|
mod bind_group;
|
||||||
mod buffer;
|
mod buffer;
|
||||||
mod context;
|
mod context;
|
||||||
mod renderer;
|
|
||||||
mod texture;
|
mod texture;
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
bind_group::{BindGroupBuilder, BindGroupLayoutBuilder},
|
bind_group::{BindGroupBuilder, BindGroupLayoutBuilder},
|
||||||
buffer::{BufferExt, BulkBufferBuilder},
|
buffer::{BufferExt, BulkBufferBuilder},
|
||||||
context::Context,
|
context::Context,
|
||||||
renderer::Renderer,
|
|
||||||
texture::{Texture, TextureBuilder},
|
texture::{Texture, TextureBuilder},
|
||||||
};
|
};
|
||||||
|
|
|
@ -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<()>;
|
|
||||||
}
|
|
|
@ -2,7 +2,10 @@ use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use crate::{core, gfx, voxel::world::WorldManager};
|
use crate::{
|
||||||
|
core, gfx,
|
||||||
|
voxel::{renderer::VoxelRenderer, world::WorldManager},
|
||||||
|
};
|
||||||
|
|
||||||
use super::BrickmapManager;
|
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<()> {
|
fn render(&self, context: &gfx::Context) -> Result<()> {
|
||||||
let frame = context.surface.get_current_texture()?;
|
let frame = context.surface.get_current_texture()?;
|
||||||
let view = frame
|
let view = frame
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
pub mod brickmap;
|
pub mod brickmap;
|
||||||
|
mod renderer;
|
||||||
pub mod world;
|
pub mod world;
|
||||||
|
|
||||||
|
pub use renderer::VoxelRenderer;
|
||||||
|
|
|
@ -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<()>;
|
||||||
|
}
|
Loading…
Reference in New Issue