ready for testing
This commit is contained in:
+5
-3
@@ -1,5 +1,6 @@
|
|||||||
mod camera_controller;
|
mod camera_controller;
|
||||||
pub mod world;
|
pub mod world;
|
||||||
|
use crate::renderer::content_view::ContentView;
|
||||||
use cgmath::{SquareMatrix, Point3, InnerSpace};
|
use cgmath::{SquareMatrix, Point3, InnerSpace};
|
||||||
use winit::event::Event;
|
use winit::event::Event;
|
||||||
use crate::renderer::{camera::CameraTransform};
|
use crate::renderer::{camera::CameraTransform};
|
||||||
@@ -17,14 +18,15 @@ pub struct App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new() -> Self {
|
pub fn new(content: &mut dyn ContentView) -> Self {
|
||||||
let mut app = Self {
|
let mut app = Self {
|
||||||
camera_controller: CameraController::new(),
|
camera_controller: CameraController::new(),
|
||||||
world: World::new("default".to_string())
|
world: World::new("default".to_string())
|
||||||
};
|
};
|
||||||
|
|
||||||
let block = app.world.gen_block(&Point3{x:0,y:0,z:0});
|
let pos = &Point3{x:0,y:0,z:0};
|
||||||
|
let block = app.world.gen_block(pos);
|
||||||
|
content.write(pos, block);
|
||||||
|
|
||||||
app
|
app
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ fn main() {
|
|||||||
.expect("Failed to create window");
|
.expect("Failed to create window");
|
||||||
|
|
||||||
let mut renderer = futures::executor::block_on(Renderer::new(&window));
|
let mut renderer = futures::executor::block_on(Renderer::new(&window));
|
||||||
let mut app = App::new();
|
let mut app = App::new(&mut renderer);
|
||||||
|
|
||||||
// Stats
|
// Stats
|
||||||
let mut fps_timer = std::time::Instant::now();
|
let mut fps_timer = std::time::Instant::now();
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
use crate::Renderer;
|
||||||
|
use crate::app::world::block::WorldBlock;
|
||||||
|
use cgmath::Point3;
|
||||||
|
|
||||||
|
pub trait ContentView {
|
||||||
|
fn write(&mut self, block_pos: &Point3<u32>, block: &WorldBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ContentView for Renderer {
|
||||||
|
|
||||||
|
fn write(&mut self, block_pos: &Point3<u32>, block: &WorldBlock) {
|
||||||
|
self.buffers.content.write(&self.queue, block_pos, block)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ mod passes;
|
|||||||
use passes::{RaytracePass, PostprocessPass};
|
use passes::{RaytracePass, PostprocessPass};
|
||||||
pub mod camera;
|
pub mod camera;
|
||||||
use camera::Camera;
|
use camera::Camera;
|
||||||
|
pub mod content_view;
|
||||||
|
|
||||||
pub struct Renderer {
|
pub struct Renderer {
|
||||||
surface: wgpu::Surface,
|
surface: wgpu::Surface,
|
||||||
|
|||||||
Reference in New Issue
Block a user