pub fn new(swap_chain_format: wgpu::TextureFormat) -> Result<Self, GetDeviceError> {
		let instance = wgpu::Instance::new(select_backend());
		let event_loop = EventLoop::with_user_event();
		let proxy = ContextProxy::new(event_loop.create_proxy(), std::thread::current().id());

		let (device, queue) = futures::executor::block_on(get_device(&instance))?;

		let window_bind_group_layout = create_window_bind_group_layout(&device);
		let image_bind_group_layout = create_image_bind_group_layout(&device);

		let vertex_shader = device.create_shader_module(&wgpu::include_spirv!("../../shaders/shader.vert.spv"));
		let fragment_shader_unorm8 = device.create_shader_module(&wgpu::include_spirv!("../../shaders/unorm8.frag.spv"));

		let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
			label: Some("show-image-pipeline-layout"),
			bind_group_layouts: &[&window_bind_group_layout, &image_bind_group_layout],
			push_constant_ranges: &[],
		});

		let window_pipeline = create_render_pipeline(
			&device,
			&pipeline_layout,
			&vertex_shader,
			&fragment_shader_unorm8,
			swap_chain_format,
		);
		let image_pipeline = create_render_pipeline(
			&device,
			&pipeline_layout,
			&vertex_shader,
			&fragment_shader_unorm8,
			wgpu::TextureFormat::Rgba8Unorm,
		);

		Ok(Self {
			unsend: Default::default(),
			instance,
			event_loop: Some(event_loop),
			proxy,
			device,
			queue,
			swap_chain_format,
			window_bind_group_layout,
			image_bind_group_layout,
			window_pipeline,
			image_pipeline,
			windows: Vec::new(),
			mouse_cache: Default::default(),
			exit_with_last_window: false,
			event_handlers: Vec::new(),
			background_tasks: Vec::new(),
		})
	}
/// Create a new global context.
///
/// You can theoreticlly create as many contexts as you want,
/// but they must be run from the main thread and the [`run`](Self::run) function never returns.
/// So it is not possible to *run* more than one context.
Create a new global context.
You can theoreticlly create as many contexts as you want,
but they must be run from the main thread and the [`run`](Self::run) function never returns.
So it is not possible to *run* more than one context.
Create a new global context . You can theoreticlly create as many contexts as you want but they must be run from the main thread and the [ ` run ` ] ( Self :: run ) function never returns . So it is not possible to * run * more than one context .
pub fn new(swap_chain_format: wgpu::TextureFormat) -> Result<Self, GetDeviceError> {
		let instance = wgpu::Instance::new(select_backend());
		let event_loop = EventLoop::with_user_event();
		let proxy = ContextProxy::new(event_loop.create_proxy(), std::thread::current().id());
		let (device, queue) = futures::executor::block_on(get_device(&instance))?;
		let window_bind_group_layout = create_window_bind_group_layout(&device);
		let image_bind_group_layout = create_image_bind_group_layout(&device);
		let vertex_shader = device.create_shader_module(&wgpu::include_spirv!("../../shaders/shader.vert.spv"));
		let fragment_shader_unorm8 = device.create_shader_module(&wgpu::include_spirv!("../../shaders/unorm8.frag.spv"));
		let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
			label: Some("show-image-pipeline-layout"),
			bind_group_layouts: &[&window_bind_group_layout, &image_bind_group_layout],
			push_constant_ranges: &[],
		});
		let window_pipeline = create_render_pipeline(
			&device,
			&pipeline_layout,
			&vertex_shader,
			&fragment_shader_unorm8,
			swap_chain_format,
		);
		let image_pipeline = create_render_pipeline(
			&device,
			&pipeline_layout,
			&vertex_shader,
			&fragment_shader_unorm8,
			wgpu::TextureFormat::Rgba8Unorm,
		);
		Ok(Self {
			unsend: Default::default(),
			instance,
			event_loop: Some(event_loop),
			proxy,
			device,
			queue,
			swap_chain_format,
			window_bind_group_layout,
			image_bind_group_layout,
			window_pipeline,
			image_pipeline,
			windows: Vec::new(),
			mouse_cache: Default::default(),
			exit_with_last_window: false,
			event_handlers: Vec::new(),
			background_tasks: Vec::new(),
		})
	}
pub fn new ( swap_chain_format : wgpu :: TextureFormat ) -> Result < Self , GetDeviceError > { let instance = wgpu :: Instance :: new ( select_backend ( ) ) ; let event_loop = EventLoop :: with_user_event ( ) ; let proxy = ContextProxy :: new ( event_loop . create_proxy ( ) , std :: thread :: current ( ) . id ( ) ) ; let ( device , queue ) = futures :: executor :: block_on ( get_device ( & instance ) ) ? ; let window_bind_group_layout = create_window_bind_group_layout ( & device ) ; let image_bind_group_layout = create_image_bind_group_layout ( & device ) ; let vertex_shader = device . create_shader_module ( & wgpu :: include_spirv ! ( " " ) ) ; let fragment_shader_unorm8 = device . create_shader_module ( & wgpu :: include_spirv ! ( " " ) ) ; let pipeline_layout = device . create_pipeline_layout ( & wgpu :: PipelineLayoutDescriptor { label : Some ( " " ) , bind_group_layouts : & [ & window_bind_group_layout , & image_bind_group_layout ] , push_constant_ranges : & [ ] , } ) ; let window_pipeline = create_render_pipeline ( & device , & pipeline_layout , & vertex_shader , & fragment_shader_unorm8 , swap_chain_format , ) ; let image_pipeline = create_render_pipeline ( & device , & pipeline_layout , & vertex_shader , & fragment_shader_unorm8 , wgpu :: TextureFormat :: Rgba8Unorm , ) ; Ok ( Self { unsend : Default :: default ( ) , instance , event_loop : Some ( event_loop ) , proxy , device , queue , swap_chain_format , window_bind_group_layout , image_bind_group_layout , window_pipeline , image_pipeline , windows : Vec :: new ( ) , mouse_cache : Default :: default ( ) , exit_with_last_window : false , event_handlers : Vec :: new ( ) , background_tasks : Vec :: new ( ) , } ) }
Create a new global context.
Create a new global context .
swap_chain_format
wgpu::TextureFormat