ImageSampler linear/nearest constructors (#5466)
# Objective I found this small ux hiccup when writing the 0.8 blog post: ```rust image.sampler = ImageSampler::Descriptor(ImageSampler::nearest_descriptor()); ``` Not good! ## Solution ```rust image.sampler = ImageSampler::nearest(); ``` (there are Good Reasons to keep around the nearest_descriptor() constructor and I think it belongs on this type)
This commit is contained in:
parent
be19c696bd
commit
c6a41cdd10
@ -125,7 +125,20 @@ pub enum ImageSampler {
|
||||
}
|
||||
|
||||
impl ImageSampler {
|
||||
/// Returns an image sampler with `Linear` min and mag filters
|
||||
#[inline]
|
||||
pub fn linear() -> ImageSampler {
|
||||
ImageSampler::Descriptor(Self::linear_descriptor())
|
||||
}
|
||||
|
||||
/// Returns an image sampler with `nearest` min and mag filters
|
||||
#[inline]
|
||||
pub fn nearest() -> ImageSampler {
|
||||
ImageSampler::Descriptor(Self::nearest_descriptor())
|
||||
}
|
||||
|
||||
/// Returns a sampler descriptor with `Linear` min and mag filters
|
||||
#[inline]
|
||||
pub fn linear_descriptor() -> wgpu::SamplerDescriptor<'static> {
|
||||
wgpu::SamplerDescriptor {
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
@ -135,6 +148,7 @@ impl ImageSampler {
|
||||
}
|
||||
|
||||
/// Returns a sampler descriptor with `Nearest` min and mag filters
|
||||
#[inline]
|
||||
pub fn nearest_descriptor() -> wgpu::SamplerDescriptor<'static> {
|
||||
wgpu::SamplerDescriptor {
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user