color functions
This commit is contained in:
parent
e8da9d2a72
commit
3c78d9c94c
@ -13,5 +13,6 @@ mod physics_worker;
|
||||
mod graphics_worker;
|
||||
|
||||
fn main(){
|
||||
setup::setup_and_start(format!("Strafe Client v{}",env!("CARGO_PKG_VERSION")));
|
||||
let title=format!("Strafe Client v{}",env!("CARGO_PKG_VERSION"));
|
||||
pollster::block_on(setup::setup_and_start(title));
|
||||
}
|
||||
|
@ -66,18 +66,18 @@ struct SetupContextPartial2<'a>{
|
||||
surface:wgpu::Surface<'a>,
|
||||
}
|
||||
impl<'a> SetupContextPartial2<'a>{
|
||||
fn pick_adapter(self)->SetupContextPartial3<'a>{
|
||||
async fn pick_adapter(self)->SetupContextPartial3<'a>{
|
||||
let adapter;
|
||||
|
||||
//TODO: prefer adapter that implements optional features
|
||||
//let optional_features=optional_features();
|
||||
let required_features=required_features();
|
||||
|
||||
let chosen_adapter=pollster::block_on(self.instance.request_adapter(&wgpu::RequestAdapterOptions{
|
||||
let chosen_adapter=self.instance.request_adapter(&wgpu::RequestAdapterOptions{
|
||||
power_preference:wgpu::PowerPreference::HighPerformance,
|
||||
force_fallback_adapter:false,
|
||||
compatible_surface:Some(&self.surface),
|
||||
}));
|
||||
}).await;
|
||||
|
||||
if let Some(maybe_chosen_adapter)=chosen_adapter{
|
||||
adapter=maybe_chosen_adapter;
|
||||
@ -116,7 +116,7 @@ struct SetupContextPartial3<'a>{
|
||||
adapter:wgpu::Adapter,
|
||||
}
|
||||
impl<'a> SetupContextPartial3<'a>{
|
||||
fn request_device(self)->SetupContextPartial4<'a>{
|
||||
async fn request_device(self)->SetupContextPartial4<'a>{
|
||||
let optional_features=optional_features();
|
||||
let required_features=required_features();
|
||||
|
||||
@ -124,7 +124,7 @@ impl<'a> SetupContextPartial3<'a>{
|
||||
let needed_limits=required_limits().using_resolution(self.adapter.limits());
|
||||
|
||||
let trace_dir=std::env::var("WGPU_TRACE");
|
||||
let (device, queue)=pollster::block_on(self.adapter
|
||||
let (device, queue)=self.adapter
|
||||
.request_device(
|
||||
&wgpu::DeviceDescriptor {
|
||||
label: None,
|
||||
@ -133,7 +133,7 @@ impl<'a> SetupContextPartial3<'a>{
|
||||
memory_hints:wgpu::MemoryHints::Performance,
|
||||
},
|
||||
trace_dir.ok().as_ref().map(std::path::Path::new),
|
||||
))
|
||||
).await
|
||||
.expect("Unable to find a suitable GPU adapter!");
|
||||
|
||||
SetupContextPartial4{
|
||||
@ -179,7 +179,7 @@ pub struct SetupContext<'a>{
|
||||
pub config:wgpu::SurfaceConfiguration,
|
||||
}
|
||||
|
||||
pub fn setup_and_start(title:String){
|
||||
pub async fn setup_and_start(title:String){
|
||||
let event_loop=winit::event_loop::EventLoop::new().unwrap();
|
||||
|
||||
println!("Initializing the surface...");
|
||||
@ -190,9 +190,9 @@ pub fn setup_and_start(title:String){
|
||||
|
||||
let partial_2=partial_1.create_surface(&window).unwrap();
|
||||
|
||||
let partial_3=partial_2.pick_adapter();
|
||||
let partial_3=partial_2.pick_adapter().await;
|
||||
|
||||
let partial_4=partial_3.request_device();
|
||||
let partial_4=partial_3.request_device().await;
|
||||
|
||||
let size=window.inner_size();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user