Moved renderer to render module

This commit is contained in:
Jarrod Doyle 2023-04-24 09:24:22 +01:00
parent 40cdd5766d
commit a94932836f
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
5 changed files with 9 additions and 7 deletions

View File

@ -5,7 +5,7 @@ use winit::{
event_loop::{ControlFlow, EventLoop}, event_loop::{ControlFlow, EventLoop},
}; };
use crate::{camera, render, renderer}; use crate::{camera, render};
pub(crate) struct App { pub(crate) struct App {
window: winit::window::Window, window: winit::window::Window,
@ -74,7 +74,7 @@ impl App {
.with_entry(camera_controller.get_buffer().as_entire_binding()) .with_entry(camera_controller.get_buffer().as_entire_binding())
.build(&self.render_ctx); .build(&self.render_ctx);
let renderer = renderer::Renderer::new(&self.render_ctx, &camera_bind_group_layout); let renderer = render::Renderer::new(&self.render_ctx, &camera_bind_group_layout);
let mut last_render_time = Instant::now(); let mut last_render_time = Instant::now();
self.event_loop self.event_loop

0
src/core.rs Normal file
View File

View File

@ -1,7 +1,7 @@
mod app; mod app;
mod camera; mod camera;
mod core;
mod render; mod render;
mod renderer;
fn main() { fn main() {
env_logger::init(); env_logger::init();

View File

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

View File

@ -1,6 +1,6 @@
use crate::render::{BindGroupBuilder, BindGroupLayoutBuilder, Context, Texture, TextureBuilder}; use super::{BindGroupBuilder, BindGroupLayoutBuilder, Context, Texture, TextureBuilder};
pub(crate) struct Renderer { pub struct Renderer {
clear_color: wgpu::Color, clear_color: wgpu::Color,
compute_pipeline: wgpu::ComputePipeline, compute_pipeline: wgpu::ComputePipeline,
compute_bind_group: wgpu::BindGroup, compute_bind_group: wgpu::BindGroup,
@ -12,7 +12,7 @@ pub(crate) struct Renderer {
impl Renderer { impl Renderer {
pub fn new(context: &Context, camera_bind_group_layout: &wgpu::BindGroupLayout) -> Self { pub fn new(context: &Context, camera_bind_group_layout: &wgpu::BindGroupLayout) -> Self {
log::info!("Creating render shader..."); log::info!("Creating render shader...");
let shader_descriptor = wgpu::include_wgsl!("../assets/shaders/shader.wgsl"); let shader_descriptor = wgpu::include_wgsl!("../../assets/shaders/shader.wgsl");
let shader = context.device.create_shader_module(shader_descriptor); let shader = context.device.create_shader_module(shader_descriptor);
log::info!("Creating render texture..."); log::info!("Creating render texture...");
@ -94,7 +94,7 @@ impl Renderer {
}); });
log::info!("Creating compute pipeline..."); log::info!("Creating compute pipeline...");
let cs_descriptor = wgpu::include_wgsl!("../assets/shaders/voxel_volume.wgsl"); let cs_descriptor = wgpu::include_wgsl!("../../assets/shaders/voxel_volume.wgsl");
let cs = context.device.create_shader_module(cs_descriptor); let cs = context.device.create_shader_module(cs_descriptor);
let compute_layout = BindGroupLayoutBuilder::new() let compute_layout = BindGroupLayoutBuilder::new()
.with_entry( .with_entry(