ImageSampler::init_descriptor (#11113)
Shortcut to avoid repetition in code like https://github.com/bevyengine/bevy/pull/11109. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
parent
6cc96f4c1f
commit
2e36b2719c
@ -202,6 +202,23 @@ impl ImageSampler {
|
||||
pub fn nearest() -> ImageSampler {
|
||||
ImageSampler::Descriptor(ImageSamplerDescriptor::nearest())
|
||||
}
|
||||
|
||||
/// Initialize the descriptor if it is not already initialized.
|
||||
///
|
||||
/// Descriptor is typically initialized by Bevy when the image is loaded,
|
||||
/// so this is convenient shortcut for updating the descriptor.
|
||||
pub fn get_or_init_descriptor(&mut self) -> &mut ImageSamplerDescriptor {
|
||||
match self {
|
||||
ImageSampler::Default => {
|
||||
*self = ImageSampler::Descriptor(ImageSamplerDescriptor::default());
|
||||
match self {
|
||||
ImageSampler::Descriptor(descriptor) => descriptor,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
ImageSampler::Descriptor(descriptor) => descriptor,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A rendering resource for the default image sampler which is set during renderer
|
||||
|
Loading…
Reference in New Issue
Block a user