pub struct MTLSamplerDescriptor { /* private fields */ }MTLSampler only.Expand description
A mutable descriptor used to configure a sampler. When complete, this can be used to create an immutable MTLSamplerState.
See also Apple’s documentation
Implementations§
Source§impl MTLSamplerDescriptor
impl MTLSamplerDescriptor
Sourcepub fn minFilter(&self) -> MTLSamplerMinMagFilter
pub fn minFilter(&self) -> MTLSamplerMinMagFilter
Filter option for combining texels within a mipmap level the sample footprint is larger than a pixel (minification).
The default value is MTLSamplerMinMagFilterNearest.
Sourcepub fn setMinFilter(&self, min_filter: MTLSamplerMinMagFilter)
pub fn setMinFilter(&self, min_filter: MTLSamplerMinMagFilter)
Setter for minFilter.
Sourcepub fn magFilter(&self) -> MTLSamplerMinMagFilter
pub fn magFilter(&self) -> MTLSamplerMinMagFilter
Filter option for combining texels within a mipmap level the sample footprint is smaller than a pixel (magnification).
The default value is MTLSamplerMinMagFilterNearest.
Sourcepub fn setMagFilter(&self, mag_filter: MTLSamplerMinMagFilter)
pub fn setMagFilter(&self, mag_filter: MTLSamplerMinMagFilter)
Setter for magFilter.
Sourcepub fn mipFilter(&self) -> MTLSamplerMipFilter
pub fn mipFilter(&self) -> MTLSamplerMipFilter
Filter options for filtering between two mipmap levels.
The default value is MTLSamplerMipFilterNotMipmapped
Sourcepub fn setMipFilter(&self, mip_filter: MTLSamplerMipFilter)
pub fn setMipFilter(&self, mip_filter: MTLSamplerMipFilter)
Setter for mipFilter.
Sourcepub fn maxAnisotropy(&self) -> NSUInteger
pub fn maxAnisotropy(&self) -> NSUInteger
The number of samples that can be taken to improve quality of sample footprints that are anisotropic.
The default value is 1.
Sourcepub fn setMaxAnisotropy(&self, max_anisotropy: NSUInteger)
pub fn setMaxAnisotropy(&self, max_anisotropy: NSUInteger)
Setter for maxAnisotropy.
Sourcepub fn sAddressMode(&self) -> MTLSamplerAddressMode
pub fn sAddressMode(&self) -> MTLSamplerAddressMode
Set the wrap mode for the S texture coordinate. The default value is MTLSamplerAddressModeClampToEdge.
Sourcepub fn setSAddressMode(&self, s_address_mode: MTLSamplerAddressMode)
pub fn setSAddressMode(&self, s_address_mode: MTLSamplerAddressMode)
Setter for sAddressMode.
Sourcepub fn tAddressMode(&self) -> MTLSamplerAddressMode
pub fn tAddressMode(&self) -> MTLSamplerAddressMode
Set the wrap mode for the T texture coordinate. The default value is MTLSamplerAddressModeClampToEdge.
Sourcepub fn setTAddressMode(&self, t_address_mode: MTLSamplerAddressMode)
pub fn setTAddressMode(&self, t_address_mode: MTLSamplerAddressMode)
Setter for tAddressMode.
Sourcepub fn rAddressMode(&self) -> MTLSamplerAddressMode
pub fn rAddressMode(&self) -> MTLSamplerAddressMode
Set the wrap mode for the R texture coordinate. The default value is MTLSamplerAddressModeClampToEdge.
Sourcepub fn setRAddressMode(&self, r_address_mode: MTLSamplerAddressMode)
pub fn setRAddressMode(&self, r_address_mode: MTLSamplerAddressMode)
Setter for rAddressMode.
Sourcepub fn borderColor(&self) -> MTLSamplerBorderColor
pub fn borderColor(&self) -> MTLSamplerBorderColor
Set the color for the MTLSamplerAddressMode to one of the predefined in the MTLSamplerBorderColor enum.
Sourcepub fn setBorderColor(&self, border_color: MTLSamplerBorderColor)
pub fn setBorderColor(&self, border_color: MTLSamplerBorderColor)
Setter for borderColor.
Sourcepub fn reductionMode(&self) -> MTLSamplerReductionMode
pub fn reductionMode(&self) -> MTLSamplerReductionMode
Sets the reduction mode for filtering contributing samples.
The property’s default value is MTLSamplerReductionModeWeightedAverage.
The sampler ignores this property if any of the following property values are equal to a specific value:
- The sampler’s
mipFilterproperty is equal toMTLSamplerMipFilterNotMipmapped. - The sampler’s
mipFilterproperty is equal toMTLSamplerMipFilterNearest. - The sampler’s
minFilterproperty is equal toMTLSamplerMinMagFilterNearest. - The sampler’s
magFilterproperty is equal toMTLSamplerMinMagFilterNearest.
Sourcepub fn setReductionMode(&self, reduction_mode: MTLSamplerReductionMode)
pub fn setReductionMode(&self, reduction_mode: MTLSamplerReductionMode)
Setter for reductionMode.
Sourcepub fn normalizedCoordinates(&self) -> bool
pub fn normalizedCoordinates(&self) -> bool
If YES, texture coordates are from 0 to 1. If NO, texture coordinates are 0..width, 0..height.
normalizedCoordinates defaults to YES. Non-normalized coordinates should only be used with 1D and 2D textures with the ClampToEdge wrap mode, otherwise the results of sampling are undefined.
Sourcepub fn setNormalizedCoordinates(&self, normalized_coordinates: bool)
pub fn setNormalizedCoordinates(&self, normalized_coordinates: bool)
Setter for normalizedCoordinates.
Sourcepub fn lodMinClamp(&self) -> c_float
pub fn lodMinClamp(&self) -> c_float
The minimum level of detail that will be used when sampling from a texture.
The default value of lodMinClamp is 0.0. Clamp values are ignored for texture sample variants that specify an explicit level of detail.
Sourcepub fn setLodMinClamp(&self, lod_min_clamp: c_float)
pub fn setLodMinClamp(&self, lod_min_clamp: c_float)
Setter for lodMinClamp.
Sourcepub fn lodMaxClamp(&self) -> c_float
pub fn lodMaxClamp(&self) -> c_float
The maximum level of detail that will be used when sampling from a texture.
The default value of lodMaxClamp is FLT_MAX. Clamp values are ignored for texture sample variants that specify an explicit level of detail.
Sourcepub fn setLodMaxClamp(&self, lod_max_clamp: c_float)
pub fn setLodMaxClamp(&self, lod_max_clamp: c_float)
Setter for lodMaxClamp.
Sourcepub fn lodAverage(&self) -> bool
pub fn lodAverage(&self) -> bool
If YES, an average level of detail will be used when sampling from a texture. If NO, no averaging is performed.
lodAverage defaults to NO. This option is a performance hint. An implementation is free to ignore this property.
Sourcepub fn setLodAverage(&self, lod_average: bool)
pub fn setLodAverage(&self, lod_average: bool)
Setter for lodAverage.
Sourcepub fn lodBias(&self) -> c_float
pub fn lodBias(&self) -> c_float
Sets the level-of-detail (lod) bias when sampling from a texture.
The property’s default value is 0.0f.
The precision format is S4.6, and the range is [-16.0, 15.999].
Sourcepub fn setLodBias(&self, lod_bias: c_float)
pub fn setLodBias(&self, lod_bias: c_float)
Setter for lodBias.
Sourcepub fn compareFunction(&self) -> MTLCompareFunction
Available on crate feature MTLDepthStencil only.
pub fn compareFunction(&self) -> MTLCompareFunction
MTLDepthStencil only.Set the comparison function used when sampling shadow maps. The default value is MTLCompareFunctionNever.
Sourcepub fn setCompareFunction(&self, compare_function: MTLCompareFunction)
Available on crate feature MTLDepthStencil only.
pub fn setCompareFunction(&self, compare_function: MTLCompareFunction)
MTLDepthStencil only.Setter for compareFunction.
Sourcepub fn supportArgumentBuffers(&self) -> bool
pub fn supportArgumentBuffers(&self) -> bool
true if the sampler can be used inside an argument buffer
Sourcepub fn setSupportArgumentBuffers(&self, support_argument_buffers: bool)
pub fn setSupportArgumentBuffers(&self, support_argument_buffers: bool)
Setter for supportArgumentBuffers.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl AsRef<AnyObject> for MTLSamplerDescriptor
impl AsRef<AnyObject> for MTLSamplerDescriptor
Source§impl AsRef<NSObject> for MTLSamplerDescriptor
impl AsRef<NSObject> for MTLSamplerDescriptor
Source§impl Borrow<AnyObject> for MTLSamplerDescriptor
impl Borrow<AnyObject> for MTLSamplerDescriptor
Source§impl Borrow<NSObject> for MTLSamplerDescriptor
impl Borrow<NSObject> for MTLSamplerDescriptor
Source§impl ClassType for MTLSamplerDescriptor
impl ClassType for MTLSamplerDescriptor
Source§const NAME: &'static str = "MTLSamplerDescriptor"
const NAME: &'static str = "MTLSamplerDescriptor"
Source§type ThreadKind = <<MTLSamplerDescriptor as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<MTLSamplerDescriptor as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for MTLSamplerDescriptor
impl CopyingHelper for MTLSamplerDescriptor
Source§type Result = MTLSamplerDescriptor
type Result = MTLSamplerDescriptor
Self if the type has no
immutable counterpart. Read moreSource§impl Debug for MTLSamplerDescriptor
impl Debug for MTLSamplerDescriptor
Source§impl Deref for MTLSamplerDescriptor
impl Deref for MTLSamplerDescriptor
Source§impl Hash for MTLSamplerDescriptor
impl Hash for MTLSamplerDescriptor
Source§impl Message for MTLSamplerDescriptor
impl Message for MTLSamplerDescriptor
Source§impl NSCopying for MTLSamplerDescriptor
impl NSCopying for MTLSamplerDescriptor
Source§impl NSObjectProtocol for MTLSamplerDescriptor
impl NSObjectProtocol for MTLSamplerDescriptor
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref