Add wgpu adapter
getter API (#340)
Co-authored-by: Jay Oster <jay@kodewerx.org>
This commit is contained in:
parent
860559272a
commit
bbfd49deba
|
@ -345,6 +345,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle>
|
||||||
|
|
||||||
let pixels = Pixels {
|
let pixels = Pixels {
|
||||||
context,
|
context,
|
||||||
|
adapter,
|
||||||
surface_size,
|
surface_size,
|
||||||
present_mode,
|
present_mode,
|
||||||
render_texture_format,
|
render_texture_format,
|
||||||
|
|
19
src/lib.rs
19
src/lib.rs
|
@ -100,6 +100,7 @@ pub struct Pixels {
|
||||||
surface_texture_format: wgpu::TextureFormat,
|
surface_texture_format: wgpu::TextureFormat,
|
||||||
blend_state: wgpu::BlendState,
|
blend_state: wgpu::BlendState,
|
||||||
alpha_mode: wgpu::CompositeAlphaMode,
|
alpha_mode: wgpu::CompositeAlphaMode,
|
||||||
|
adapter: wgpu::Adapter,
|
||||||
|
|
||||||
// Pixel buffer
|
// Pixel buffer
|
||||||
pixels: Vec<u8>,
|
pixels: Vec<u8>,
|
||||||
|
@ -275,6 +276,24 @@ impl Pixels {
|
||||||
self.context.scaling_renderer.clear_color = color;
|
self.context.scaling_renderer.clear_color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a reference of the `wgpu` adapter used by the crate.
|
||||||
|
///
|
||||||
|
/// The adapter can be used to retrieve runtime information about the host system
|
||||||
|
/// or the WGPU backend.
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// # use pixels::Pixels;
|
||||||
|
/// # let window = pixels_mocks::Rwh;
|
||||||
|
/// # let surface_texture = pixels::SurfaceTexture::new(320, 240, &window);
|
||||||
|
/// let mut pixels = Pixels::new(320, 240, surface_texture)?;
|
||||||
|
/// let adapter = pixels.adapter();
|
||||||
|
/// // Do something with the adapter.
|
||||||
|
/// # Ok::<(), pixels::Error>(())
|
||||||
|
/// ```
|
||||||
|
pub fn adapter(&self) -> &wgpu::Adapter {
|
||||||
|
&self.adapter
|
||||||
|
}
|
||||||
|
|
||||||
/// Resize the pixel buffer and zero its contents.
|
/// Resize the pixel buffer and zero its contents.
|
||||||
///
|
///
|
||||||
/// This does not resize the surface upon which the pixel buffer texture is rendered. Use
|
/// This does not resize the surface upon which the pixel buffer texture is rendered. Use
|
||||||
|
|
Loading…
Reference in a new issue