graphics: remove SurfaceConfiguration from interfaces
This commit is contained in:
@@ -134,13 +134,13 @@ pub struct GraphicsState{
|
||||
impl GraphicsState{
|
||||
const DEPTH_FORMAT:wgpu::TextureFormat=wgpu::TextureFormat::Depth24Plus;
|
||||
fn create_depth_texture(
|
||||
config:&wgpu::SurfaceConfiguration,
|
||||
size:glam::UVec2,
|
||||
device:&wgpu::Device,
|
||||
)->wgpu::TextureView{
|
||||
let depth_texture=device.create_texture(&wgpu::TextureDescriptor{
|
||||
size:wgpu::Extent3d{
|
||||
width:config.width,
|
||||
height:config.height,
|
||||
width:size.x,
|
||||
height:size.y,
|
||||
depth_or_array_layers:1,
|
||||
},
|
||||
mip_level_count:1,
|
||||
@@ -542,7 +542,8 @@ impl GraphicsState{
|
||||
pub fn new(
|
||||
device:&wgpu::Device,
|
||||
queue:&wgpu::Queue,
|
||||
config:&wgpu::SurfaceConfiguration,
|
||||
size:glam::UVec2,
|
||||
view_format:wgpu::TextureFormat,
|
||||
)->Self{
|
||||
let camera_bind_group_layout=device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor{
|
||||
label:None,
|
||||
@@ -781,7 +782,7 @@ impl GraphicsState{
|
||||
fragment:Some(wgpu::FragmentState{
|
||||
module:&shader,
|
||||
entry_point:Some("fs_sky"),
|
||||
targets:&[Some(config.view_formats[0].into())],
|
||||
targets:&[Some(view_format.into())],
|
||||
compilation_options:wgpu::PipelineCompilationOptions::default(),
|
||||
}),
|
||||
primitive:wgpu::PrimitiveState{
|
||||
@@ -815,7 +816,7 @@ impl GraphicsState{
|
||||
fragment:Some(wgpu::FragmentState{
|
||||
module:&shader,
|
||||
entry_point:Some("fs_entity_texture"),
|
||||
targets:&[Some(config.view_formats[0].into())],
|
||||
targets:&[Some(view_format.into())],
|
||||
compilation_options:wgpu::PipelineCompilationOptions::default(),
|
||||
}),
|
||||
primitive:wgpu::PrimitiveState{
|
||||
@@ -868,7 +869,7 @@ impl GraphicsState{
|
||||
label:Some("Sky Texture"),
|
||||
});
|
||||
|
||||
let depth_view=Self::create_depth_texture(config,device);
|
||||
let depth_view=Self::create_depth_texture(size,device);
|
||||
|
||||
Self{
|
||||
pipelines:GraphicsPipelines{
|
||||
@@ -892,11 +893,11 @@ impl GraphicsState{
|
||||
pub fn resize(
|
||||
&mut self,
|
||||
device:&wgpu::Device,
|
||||
config:&wgpu::SurfaceConfiguration,
|
||||
size:glam::UVec2,
|
||||
fov:glam::Vec2,
|
||||
){
|
||||
self.depth_view=Self::create_depth_texture(config,device);
|
||||
self.camera.screen_size=glam::uvec2(config.width,config.height);
|
||||
self.depth_view=Self::create_depth_texture(size,device);
|
||||
self.camera.screen_size=size;
|
||||
self.camera.fov=fov;
|
||||
}
|
||||
pub fn render(
|
||||
|
||||
@@ -37,8 +37,9 @@ pub fn new(
|
||||
config.width=size.width.max(1);
|
||||
config.height=size.height.max(1);
|
||||
surface.configure(&device,&config);
|
||||
let fov=user_settings.calculate_fov(1.0,&glam::uvec2(config.width,config.height)).as_vec2();
|
||||
graphics.resize(&device,&config,fov);
|
||||
let size=glam::uvec2(config.width,config.height);
|
||||
let fov=user_settings.calculate_fov(1.0,&size).as_vec2();
|
||||
graphics.resize(&device,size,fov);
|
||||
println!("Resize took {:?}",t0.elapsed());
|
||||
}
|
||||
Instruction::Render(frame_state)=>{
|
||||
|
||||
@@ -252,12 +252,12 @@ pub fn worker<'a>(
|
||||
|
||||
let user_settings=directories.settings();
|
||||
|
||||
let mut graphics=strafesnet_graphics::graphics::GraphicsState::new(&device,&queue,&config);
|
||||
let screen_size=glam::uvec2(config.width,config.height);
|
||||
let mut graphics=strafesnet_graphics::graphics::GraphicsState::new(&device,&queue,screen_size,config.view_formats[0]);
|
||||
|
||||
//WindowContextSetup::into_context
|
||||
let screen_size=glam::uvec2(config.width,config.height);
|
||||
let fov=user_settings.calculate_fov(1.0,&screen_size).as_vec2();
|
||||
graphics.resize(&device,&config,fov);
|
||||
graphics.resize(&device,screen_size,fov);
|
||||
let graphics_thread=crate::graphics_worker::new(graphics,config,surface,device,queue);
|
||||
let mut window_context=WindowContext{
|
||||
manual_mouse_lock:false,
|
||||
|
||||
Reference in New Issue
Block a user