rename
This commit is contained in:
parent
62e8953ba9
commit
099915c980
@ -2,6 +2,7 @@ mod bvh;
|
|||||||
mod run;
|
mod run;
|
||||||
mod aabb;
|
mod aabb;
|
||||||
mod model;
|
mod model;
|
||||||
|
mod setup;
|
||||||
mod worker;
|
mod worker;
|
||||||
mod zeroes;
|
mod zeroes;
|
||||||
mod integer;
|
mod integer;
|
||||||
@ -118,7 +119,7 @@ fn default_models()->model::IndexedModelInstances{
|
|||||||
|
|
||||||
fn main(){
|
fn main(){
|
||||||
let title=format!("Strafe Client v{}",env!("CARGO_PKG_VERSION")).as_str();
|
let title=format!("Strafe Client v{}",env!("CARGO_PKG_VERSION")).as_str();
|
||||||
let context=graphics_context::setup(title);
|
let context=setup_context::setup(title);
|
||||||
let run=run::RunState::init();//new
|
let run=run::RunState::init();//new
|
||||||
run.replace_models(&context,default_models());
|
run.replace_models(&context,default_models());
|
||||||
context.start(run);
|
context.start(run);
|
||||||
|
@ -18,7 +18,7 @@ pub fn required_limits() -> wgpu::Limits {
|
|||||||
wgpu::Limits::downlevel_webgl2_defaults() // These downlevel limits will allow the code to run on all possible hardware
|
wgpu::Limits::downlevel_webgl2_defaults() // These downlevel limits will allow the code to run on all possible hardware
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GraphicsContextPartial1{
|
struct SetupContextPartial1{
|
||||||
backends:wgpu::Backends,
|
backends:wgpu::Backends,
|
||||||
instance:wgpu::Instance,
|
instance:wgpu::Instance,
|
||||||
}
|
}
|
||||||
@ -32,10 +32,10 @@ fn create_window(title:&str,event_loop:&winit::event_loop::EventLoop<()>)->Resul
|
|||||||
}
|
}
|
||||||
builder.build(event_loop)
|
builder.build(event_loop)
|
||||||
}
|
}
|
||||||
fn create_instance()->GraphicsContextPartial1{
|
fn create_instance()->SetupContextPartial1{
|
||||||
let backends=wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all);
|
let backends=wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all);
|
||||||
let dx12_shader_compiler=wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default();
|
let dx12_shader_compiler=wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default();
|
||||||
GraphicsContextPartial1{
|
SetupContextPartial1{
|
||||||
backends,
|
backends,
|
||||||
instance:wgpu::Instance::new(wgpu::InstanceDescriptor{
|
instance:wgpu::Instance::new(wgpu::InstanceDescriptor{
|
||||||
backends,
|
backends,
|
||||||
@ -43,22 +43,22 @@ fn create_instance()->GraphicsContextPartial1{
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl GraphicsContextPartial1{
|
impl SetupContextPartial1{
|
||||||
fn create_surface(self,window:&winit::window::Window)->Result<GraphicsContextPartial2,wgpu::CreateSurfaceError>{
|
fn create_surface(self,window:&winit::window::Window)->Result<SetupContextPartial2,wgpu::CreateSurfaceError>{
|
||||||
Ok(GraphicsContextPartial2{
|
Ok(SetupContextPartial2{
|
||||||
backends:self.backends,
|
backends:self.backends,
|
||||||
instance:self.instance,
|
instance:self.instance,
|
||||||
surface:unsafe{self.instance.create_surface(window)}?
|
surface:unsafe{self.instance.create_surface(window)}?
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct GraphicsContextPartial2{
|
struct SetupContextPartial2{
|
||||||
backends:wgpu::Backends,
|
backends:wgpu::Backends,
|
||||||
instance:wgpu::Instance,
|
instance:wgpu::Instance,
|
||||||
surface:wgpu::Surface,
|
surface:wgpu::Surface,
|
||||||
}
|
}
|
||||||
impl GraphicsContextPartial2{
|
impl SetupContextPartial2{
|
||||||
fn pick_adapter(self)->GraphicsContextPartial3{
|
fn pick_adapter(self)->SetupContextPartial3{
|
||||||
let adapter;
|
let adapter;
|
||||||
|
|
||||||
let optional_features=optional_features();
|
let optional_features=optional_features();
|
||||||
@ -112,20 +112,20 @@ impl GraphicsContextPartial2{
|
|||||||
"Adapter does not support the downlevel capabilities required to run this example: {:?}",
|
"Adapter does not support the downlevel capabilities required to run this example: {:?}",
|
||||||
required_downlevel_capabilities.flags - downlevel_capabilities.flags
|
required_downlevel_capabilities.flags - downlevel_capabilities.flags
|
||||||
);
|
);
|
||||||
GraphicsContextPartial3{
|
SetupContextPartial3{
|
||||||
instance:self.instance,
|
instance:self.instance,
|
||||||
surface:self.surface,
|
surface:self.surface,
|
||||||
adapter,
|
adapter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct GraphicsContextPartial3{
|
struct SetupContextPartial3{
|
||||||
instance:wgpu::Instance,
|
instance:wgpu::Instance,
|
||||||
surface:wgpu::Surface,
|
surface:wgpu::Surface,
|
||||||
adapter:wgpu::Adapter,
|
adapter:wgpu::Adapter,
|
||||||
}
|
}
|
||||||
impl GraphicsContextPartial3{
|
impl SetupContextPartial3{
|
||||||
fn request_device(self)->GraphicsContextPartial4{
|
fn request_device(self)->SetupContextPartial4{
|
||||||
let optional_features=optional_features();
|
let optional_features=optional_features();
|
||||||
let required_features=required_features();
|
let required_features=required_features();
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ impl GraphicsContextPartial3{
|
|||||||
))
|
))
|
||||||
.expect("Unable to find a suitable GPU adapter!");
|
.expect("Unable to find a suitable GPU adapter!");
|
||||||
|
|
||||||
GraphicsContextPartial4{
|
SetupContextPartial4{
|
||||||
instance:self.instance,
|
instance:self.instance,
|
||||||
surface:self.surface,
|
surface:self.surface,
|
||||||
adapter:self.adapter,
|
adapter:self.adapter,
|
||||||
@ -153,15 +153,15 @@ impl GraphicsContextPartial3{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct GraphicsContextPartial4{
|
struct SetupContextPartial4{
|
||||||
instance:wgpu::Instance,
|
instance:wgpu::Instance,
|
||||||
surface:wgpu::Surface,
|
surface:wgpu::Surface,
|
||||||
adapter:wgpu::Adapter,
|
adapter:wgpu::Adapter,
|
||||||
device:wgpu::Device,
|
device:wgpu::Device,
|
||||||
queue:wgpu::Queue,
|
queue:wgpu::Queue,
|
||||||
}
|
}
|
||||||
impl GraphicsContextPartial4{
|
impl SetupContextPartial4{
|
||||||
fn configure_surface(self,size:&winit::dpi::PhysicalSize<u32>)->GraphicsContext{
|
fn configure_surface(self,size:&winit::dpi::PhysicalSize<u32>)->SetupContext{
|
||||||
let mut config=self.surface
|
let mut config=self.surface
|
||||||
.get_default_config(&self.adapter, size.width, size.height)
|
.get_default_config(&self.adapter, size.width, size.height)
|
||||||
.expect("Surface isn't supported by the adapter.");
|
.expect("Surface isn't supported by the adapter.");
|
||||||
@ -169,7 +169,7 @@ impl GraphicsContextPartial4{
|
|||||||
config.view_formats.push(surface_view_format);
|
config.view_formats.push(surface_view_format);
|
||||||
self.surface.configure(&self.device, &config);
|
self.surface.configure(&self.device, &config);
|
||||||
|
|
||||||
GraphicsContext{
|
SetupContext{
|
||||||
instance:self.instance,
|
instance:self.instance,
|
||||||
surface:self.surface,
|
surface:self.surface,
|
||||||
device:self.device,
|
device:self.device,
|
||||||
@ -178,7 +178,7 @@ impl GraphicsContextPartial4{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub struct GraphicsContext{
|
pub struct SetupContext{
|
||||||
pub instance:wgpu::Instance,
|
pub instance:wgpu::Instance,
|
||||||
pub surface:wgpu::Surface,
|
pub surface:wgpu::Surface,
|
||||||
pub device:wgpu::Device,
|
pub device:wgpu::Device,
|
||||||
@ -186,7 +186,7 @@ pub struct GraphicsContext{
|
|||||||
pub config:wgpu::SurfaceConfiguration,
|
pub config:wgpu::SurfaceConfiguration,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setup(title:&str)->GraphicsContextSetup{
|
pub fn setup(title:&str)->SetupContextSetup{
|
||||||
let event_loop=winit::event_loop::EventLoop::new().unwrap();
|
let event_loop=winit::event_loop::EventLoop::new().unwrap();
|
||||||
|
|
||||||
let window=create_window(title,&event_loop).unwrap();
|
let window=create_window(title,&event_loop).unwrap();
|
||||||
@ -201,21 +201,21 @@ pub fn setup(title:&str)->GraphicsContextSetup{
|
|||||||
|
|
||||||
let partial_4=partial_3.request_device();
|
let partial_4=partial_3.request_device();
|
||||||
|
|
||||||
GraphicsContextSetup{
|
SetupContextSetup{
|
||||||
window,
|
window,
|
||||||
event_loop,
|
event_loop,
|
||||||
partial_graphics_context:partial_4,
|
partial_graphics_context:partial_4,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GraphicsContextSetup{
|
struct SetupContextSetup{
|
||||||
window:winit::window::Window,
|
window:winit::window::Window,
|
||||||
event_loop:winit::event_loop::EventLoop<()>,
|
event_loop:winit::event_loop::EventLoop<()>,
|
||||||
partial_graphics_context:GraphicsContextPartial4,
|
partial_graphics_context:SetupContextPartial4,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GraphicsContextSetup{
|
impl SetupContextSetup{
|
||||||
fn into_split(self)->(winit::window::Window,winit::event_loop::EventLoop<()>,GraphicsContext){
|
fn into_split(self)->(winit::window::Window,winit::event_loop::EventLoop<()>,SetupContext){
|
||||||
let size=self.window.inner_size();
|
let size=self.window.inner_size();
|
||||||
//Steal values and drop self
|
//Steal values and drop self
|
||||||
(
|
(
|
||||||
|
Loading…
Reference in New Issue
Block a user