color functions

This commit is contained in:
Quaternions 2025-01-03 17:45:57 -08:00
parent e8da9d2a72
commit 3c78d9c94c
2 changed files with 11 additions and 10 deletions

View File

@ -13,5 +13,6 @@ mod physics_worker;
mod graphics_worker; mod graphics_worker;
fn main(){ 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));
} }

View File

@ -66,18 +66,18 @@ struct SetupContextPartial2<'a>{
surface:wgpu::Surface<'a>, surface:wgpu::Surface<'a>,
} }
impl<'a> SetupContextPartial2<'a>{ impl<'a> SetupContextPartial2<'a>{
fn pick_adapter(self)->SetupContextPartial3<'a>{ async fn pick_adapter(self)->SetupContextPartial3<'a>{
let adapter; let adapter;
//TODO: prefer adapter that implements optional features //TODO: prefer adapter that implements optional features
//let optional_features=optional_features(); //let optional_features=optional_features();
let required_features=required_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, power_preference:wgpu::PowerPreference::HighPerformance,
force_fallback_adapter:false, force_fallback_adapter:false,
compatible_surface:Some(&self.surface), compatible_surface:Some(&self.surface),
})); }).await;
if let Some(maybe_chosen_adapter)=chosen_adapter{ if let Some(maybe_chosen_adapter)=chosen_adapter{
adapter=maybe_chosen_adapter; adapter=maybe_chosen_adapter;
@ -116,7 +116,7 @@ struct SetupContextPartial3<'a>{
adapter:wgpu::Adapter, adapter:wgpu::Adapter,
} }
impl<'a> SetupContextPartial3<'a>{ impl<'a> SetupContextPartial3<'a>{
fn request_device(self)->SetupContextPartial4<'a>{ async fn request_device(self)->SetupContextPartial4<'a>{
let optional_features=optional_features(); let optional_features=optional_features();
let required_features=required_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 needed_limits=required_limits().using_resolution(self.adapter.limits());
let trace_dir=std::env::var("WGPU_TRACE"); let trace_dir=std::env::var("WGPU_TRACE");
let (device, queue)=pollster::block_on(self.adapter let (device, queue)=self.adapter
.request_device( .request_device(
&wgpu::DeviceDescriptor { &wgpu::DeviceDescriptor {
label: None, label: None,
@ -133,7 +133,7 @@ impl<'a> SetupContextPartial3<'a>{
memory_hints:wgpu::MemoryHints::Performance, memory_hints:wgpu::MemoryHints::Performance,
}, },
trace_dir.ok().as_ref().map(std::path::Path::new), trace_dir.ok().as_ref().map(std::path::Path::new),
)) ).await
.expect("Unable to find a suitable GPU adapter!"); .expect("Unable to find a suitable GPU adapter!");
SetupContextPartial4{ SetupContextPartial4{
@ -179,7 +179,7 @@ pub struct SetupContext<'a>{
pub config:wgpu::SurfaceConfiguration, 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(); let event_loop=winit::event_loop::EventLoop::new().unwrap();
println!("Initializing the surface..."); 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_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(); let size=window.inner_size();