mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 14:40:19 +00:00
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
1 changed files with 14 additions and 0 deletions
|
@ -125,7 +125,20 @@ pub enum ImageSampler {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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
|
/// Returns a sampler descriptor with `Linear` min and mag filters
|
||||||
|
#[inline]
|
||||||
pub fn linear_descriptor() -> wgpu::SamplerDescriptor<'static> {
|
pub fn linear_descriptor() -> wgpu::SamplerDescriptor<'static> {
|
||||||
wgpu::SamplerDescriptor {
|
wgpu::SamplerDescriptor {
|
||||||
mag_filter: wgpu::FilterMode::Linear,
|
mag_filter: wgpu::FilterMode::Linear,
|
||||||
|
@ -135,6 +148,7 @@ impl ImageSampler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a sampler descriptor with `Nearest` min and mag filters
|
/// Returns a sampler descriptor with `Nearest` min and mag filters
|
||||||
|
#[inline]
|
||||||
pub fn nearest_descriptor() -> wgpu::SamplerDescriptor<'static> {
|
pub fn nearest_descriptor() -> wgpu::SamplerDescriptor<'static> {
|
||||||
wgpu::SamplerDescriptor {
|
wgpu::SamplerDescriptor {
|
||||||
mag_filter: wgpu::FilterMode::Nearest,
|
mag_filter: wgpu::FilterMode::Nearest,
|
||||||
|
|
Loading…
Reference in a new issue