#[repr(C)]pub struct SCNRenderer { /* private fields */ }SCNRenderer only.Expand description
SCNRenderer lets you use the SceneKit renderer in an OpenGL context or Metal render pass descriptor of your own.
See also Apple’s documentation
Implementations§
Source§impl SCNRenderer
impl SCNRenderer
Sourcepub unsafe fn rendererWithDevice_options(
device: Option<&ProtocolObject<dyn MTLDevice>>,
options: Option<&NSDictionary>,
) -> Retained<Self>
Available on crate feature objc2-metal and non-watchOS only.
pub unsafe fn rendererWithDevice_options( device: Option<&ProtocolObject<dyn MTLDevice>>, options: Option<&NSDictionary>, ) -> Retained<Self>
objc2-metal and non-watchOS only.Creates a new renderer object that renders using Metal.
Parameter device: The metal device to use. Pass nil to let SceneKit choose a default device.
Parameter options: An optional dictionary for future extensions.
Sourcepub unsafe fn scene(&self) -> Option<Retained<SCNScene>>
Available on crate feature SCNScene only.
pub unsafe fn scene(&self) -> Option<Retained<SCNScene>>
SCNScene only.Specifies the scene of the receiver
Sourcepub unsafe fn setScene(&self, scene: Option<&SCNScene>)
Available on crate feature SCNScene only.
pub unsafe fn setScene(&self, scene: Option<&SCNScene>)
SCNScene only.Setter for scene.
Sourcepub unsafe fn renderAtTime_viewport_commandBuffer_passDescriptor(
&self,
time: CFTimeInterval,
viewport: CGRect,
command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
render_pass_descriptor: &MTLRenderPassDescriptor,
)
Available on crate feature objc2-core-foundation and crate feature objc2-metal and non-watchOS only.
pub unsafe fn renderAtTime_viewport_commandBuffer_passDescriptor( &self, time: CFTimeInterval, viewport: CGRect, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, render_pass_descriptor: &MTLRenderPassDescriptor, )
objc2-core-foundation and crate feature objc2-metal and non-watchOS only.updates and renders the receiver’s scene at the specified time (system time) viewport, Metal command buffer and pass descriptor.
Use this method to render using Metal.
Sourcepub unsafe fn renderAtTime(&self, time: CFTimeInterval)
Available on crate feature objc2-core-foundation only.
pub unsafe fn renderAtTime(&self, time: CFTimeInterval)
objc2-core-foundation only.updates and renders the receiver’s scene at the specified time (system time).
This method only work if the receiver was allocated with an OpenGL context. Use renderAtTime:withEncoder:pass:commandQueue: to render with Metal.
Sourcepub unsafe fn updateAtTime(&self, time: CFTimeInterval)
Available on crate feature objc2-core-foundation only.
pub unsafe fn updateAtTime(&self, time: CFTimeInterval)
objc2-core-foundation only.updates the receiver’s scene at the specified time (system time).
Sourcepub unsafe fn renderWithViewport_commandBuffer_passDescriptor(
&self,
viewport: CGRect,
command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
render_pass_descriptor: &MTLRenderPassDescriptor,
)
Available on crate feature objc2-core-foundation and crate feature objc2-metal and non-watchOS only.
pub unsafe fn renderWithViewport_commandBuffer_passDescriptor( &self, viewport: CGRect, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, render_pass_descriptor: &MTLRenderPassDescriptor, )
objc2-core-foundation and crate feature objc2-metal and non-watchOS only.renders the receiver’s scene with the specified viewport, Metal command buffer and pass descriptor.
Use this method to render using Metal. This method doesn’t update the scene’s animations, physics, particles etc… It’s up to you to call “updateAtTime:” to update the scene.
Sourcepub unsafe fn nextFrameTime(&self) -> CFTimeInterval
Available on crate feature objc2-core-foundation only.
pub unsafe fn nextFrameTime(&self) -> CFTimeInterval
objc2-core-foundation only.Returns the time at which the next update should happen. If infinite no update needs to be scheduled yet. If the current frame time, a continuous animation is running and an update should be scheduled after a “natural” delay.
Sourcepub unsafe fn snapshotAtTime_withSize_antialiasingMode(
&self,
time: CFTimeInterval,
size: CGSize,
antialiasing_mode: SCNAntialiasingMode,
) -> Retained<NSImage>
Available on crate feature SCNSceneRenderer and crate feature objc2-app-kit and crate feature objc2-core-foundation and macOS only.
pub unsafe fn snapshotAtTime_withSize_antialiasingMode( &self, time: CFTimeInterval, size: CGSize, antialiasing_mode: SCNAntialiasingMode, ) -> Retained<NSImage>
SCNSceneRenderer and crate feature objc2-app-kit and crate feature objc2-core-foundation and macOS only.renders the receiver’s scene at the specified time (system time) into an image.
Sourcepub unsafe fn updateProbes_atTime(
&self,
light_probes: &NSArray<SCNNode>,
time: CFTimeInterval,
)
Available on crate features SCNNode and objc2-core-foundation only.
pub unsafe fn updateProbes_atTime( &self, light_probes: &NSArray<SCNNode>, time: CFTimeInterval, )
SCNNode and objc2-core-foundation only.Update the specified probes by computing their incoming irradiance in the receiver’s scene at the specified time.
Parameter lightProbes: An array of nodes that must have a light probe attached.
Parameter time: The time used to render the scene when computing the light probes irradiance.
Light probes are only supported with Metal. This method is observable using NSProgress.
Source§impl SCNRenderer
Methods declared on superclass NSObject.
impl SCNRenderer
Methods declared on superclass NSObject.
Source§impl SCNRenderer
SCNDeprecated.
impl SCNRenderer
SCNDeprecated.
Sourcepub unsafe fn render(&self)
👎DeprecatedAvailable on crate feature SceneKitDeprecated only.
pub unsafe fn render(&self)
SceneKitDeprecated only.renders the receiver’s scene at the current system time.
This method only work if the receiver was allocated with an OpenGL context and it is deprecated (use renderAtTime: instead). Use renderAtTime:withEncoder:pass:commandQueue: to render with Metal.
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.
§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 SCNRenderer
impl AsRef<AnyObject> for SCNRenderer
Source§impl AsRef<NSObject> for SCNRenderer
impl AsRef<NSObject> for SCNRenderer
Source§impl AsRef<SCNRenderer> for SCNRenderer
impl AsRef<SCNRenderer> for SCNRenderer
Source§impl Borrow<AnyObject> for SCNRenderer
impl Borrow<AnyObject> for SCNRenderer
Source§impl Borrow<NSObject> for SCNRenderer
impl Borrow<NSObject> for SCNRenderer
Source§impl ClassType for SCNRenderer
impl ClassType for SCNRenderer
Source§const NAME: &'static str = "SCNRenderer"
const NAME: &'static str = "SCNRenderer"
Source§type ThreadKind = <<SCNRenderer as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<SCNRenderer as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for SCNRenderer
impl Debug for SCNRenderer
Source§impl Deref for SCNRenderer
impl Deref for SCNRenderer
Source§impl Hash for SCNRenderer
impl Hash for SCNRenderer
Source§impl Message for SCNRenderer
impl Message for SCNRenderer
Source§impl NSObjectProtocol for SCNRenderer
impl NSObjectProtocol for SCNRenderer
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_refSource§fn isMemberOfClass(&self, cls: &AnyClass) -> bool
fn isMemberOfClass(&self, cls: &AnyClass) -> bool
Source§fn respondsToSelector(&self, aSelector: Sel) -> bool
fn respondsToSelector(&self, aSelector: Sel) -> bool
Source§fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
Source§fn debugDescription(&self) -> Retained<NSObject>
fn debugDescription(&self) -> Retained<NSObject>
Source§impl PartialEq for SCNRenderer
impl PartialEq for SCNRenderer
Source§impl RefEncode for SCNRenderer
impl RefEncode for SCNRenderer
Source§const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
Source§impl SCNSceneRenderer for SCNRenderer
Available on crate feature SCNSceneRenderer only.
impl SCNSceneRenderer for SCNRenderer
SCNSceneRenderer only.Source§unsafe fn scene(&self) -> Option<Retained<SCNScene>>
unsafe fn scene(&self) -> Option<Retained<SCNScene>>
SCNScene only.Source§unsafe fn setScene(&self, scene: Option<&SCNScene>)
unsafe fn setScene(&self, scene: Option<&SCNScene>)
SCNScene only.scene.Source§unsafe fn sceneTime(&self) -> NSTimeInterval
unsafe fn sceneTime(&self) -> NSTimeInterval
Source§unsafe fn setSceneTime(&self, scene_time: NSTimeInterval)
unsafe fn setSceneTime(&self, scene_time: NSTimeInterval)
sceneTime.Source§unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn SCNSceneRendererDelegate>>>
unsafe fn delegate( &self, ) -> Option<Retained<ProtocolObject<dyn SCNSceneRendererDelegate>>>
Source§unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn SCNSceneRendererDelegate>>,
)
unsafe fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn SCNSceneRendererDelegate>>, )
delegate.Source§unsafe fn hitTest_options(
&self,
point: CGPoint,
options: Option<&NSDictionary<SCNHitTestOption, AnyObject>>,
) -> Retained<NSArray<SCNHitTestResult>>
unsafe fn hitTest_options( &self, point: CGPoint, options: Option<&NSDictionary<SCNHitTestOption, AnyObject>>, ) -> Retained<NSArray<SCNHitTestResult>>
SCNHitTest and objc2-core-foundation only.Source§unsafe fn isNodeInsideFrustum_withPointOfView(
&self,
node: &SCNNode,
point_of_view: &SCNNode,
) -> bool
unsafe fn isNodeInsideFrustum_withPointOfView( &self, node: &SCNNode, point_of_view: &SCNNode, ) -> bool
SCNNode only.Source§unsafe fn nodesInsideFrustumWithPointOfView(
&self,
point_of_view: &SCNNode,
) -> Retained<NSArray<SCNNode>>
unsafe fn nodesInsideFrustumWithPointOfView( &self, point_of_view: &SCNNode, ) -> Retained<NSArray<SCNNode>>
SCNNode only.Source§unsafe fn projectPoint(&self, point: SCNVector3) -> SCNVector3
unsafe fn projectPoint(&self, point: SCNVector3) -> SCNVector3
SceneKitTypes and objc2-core-foundation only.Source§unsafe fn unprojectPoint(&self, point: SCNVector3) -> SCNVector3
unsafe fn unprojectPoint(&self, point: SCNVector3) -> SCNVector3
SceneKitTypes and objc2-core-foundation only.Source§unsafe fn loops(&self) -> bool
unsafe fn loops(&self) -> bool
Source§unsafe fn pointOfView(&self) -> Option<Retained<SCNNode>>
unsafe fn pointOfView(&self) -> Option<Retained<SCNNode>>
SCNNode only.Source§unsafe fn setPointOfView(&self, point_of_view: Option<&SCNNode>)
unsafe fn setPointOfView(&self, point_of_view: Option<&SCNNode>)
SCNNode only.pointOfView.Source§unsafe fn autoenablesDefaultLighting(&self) -> bool
unsafe fn autoenablesDefaultLighting(&self) -> bool
Source§unsafe fn setAutoenablesDefaultLighting(
&self,
autoenables_default_lighting: bool,
)
unsafe fn setAutoenablesDefaultLighting( &self, autoenables_default_lighting: bool, )
autoenablesDefaultLighting.Source§unsafe fn isJitteringEnabled(&self) -> bool
unsafe fn isJitteringEnabled(&self) -> bool
Source§unsafe fn setJitteringEnabled(&self, jittering_enabled: bool)
unsafe fn setJitteringEnabled(&self, jittering_enabled: bool)
isJitteringEnabled.Source§unsafe fn isTemporalAntialiasingEnabled(&self) -> bool
unsafe fn isTemporalAntialiasingEnabled(&self) -> bool
Source§unsafe fn setTemporalAntialiasingEnabled(
&self,
temporal_antialiasing_enabled: bool,
)
unsafe fn setTemporalAntialiasingEnabled( &self, temporal_antialiasing_enabled: bool, )
isTemporalAntialiasingEnabled.Source§unsafe fn prepareObject_shouldAbortBlock(
&self,
object: &AnyObject,
block: Option<&Block<dyn Fn() -> Bool + '_>>,
) -> bool
unsafe fn prepareObject_shouldAbortBlock( &self, object: &AnyObject, block: Option<&Block<dyn Fn() -> Bool + '_>>, ) -> bool
block2 only.Source§unsafe fn prepareObjects_withCompletionHandler(
&self,
objects: &NSArray,
completion_handler: Option<&Block<dyn Fn(Bool)>>,
)
unsafe fn prepareObjects_withCompletionHandler( &self, objects: &NSArray, completion_handler: Option<&Block<dyn Fn(Bool)>>, )
block2 only.Source§unsafe fn showsStatistics(&self) -> bool
unsafe fn showsStatistics(&self) -> bool
Source§unsafe fn setShowsStatistics(&self, shows_statistics: bool)
unsafe fn setShowsStatistics(&self, shows_statistics: bool)
showsStatistics.Source§unsafe fn debugOptions(&self) -> SCNDebugOptions
unsafe fn debugOptions(&self) -> SCNDebugOptions
Source§unsafe fn setDebugOptions(&self, debug_options: SCNDebugOptions)
unsafe fn setDebugOptions(&self, debug_options: SCNDebugOptions)
debugOptions.Source§unsafe fn renderingAPI(&self) -> SCNRenderingAPI
unsafe fn renderingAPI(&self) -> SCNRenderingAPI
Source§unsafe fn workingColorSpace(&self) -> Retained<CGColorSpace>
unsafe fn workingColorSpace(&self) -> Retained<CGColorSpace>
objc2-core-graphics only.Source§unsafe fn context(&self) -> *mut c_void
unsafe fn context(&self) -> *mut c_void
Source§unsafe fn currentRenderCommandEncoder(
&self,
) -> Option<Retained<ProtocolObject<dyn MTLRenderCommandEncoder>>>
unsafe fn currentRenderCommandEncoder( &self, ) -> Option<Retained<ProtocolObject<dyn MTLRenderCommandEncoder>>>
objc2-metal and non-watchOS only.Source§unsafe fn currentRenderPassDescriptor(
&self,
) -> Retained<MTLRenderPassDescriptor>
unsafe fn currentRenderPassDescriptor( &self, ) -> Retained<MTLRenderPassDescriptor>
objc2-metal and non-watchOS only.Source§unsafe fn device(&self) -> Option<Retained<ProtocolObject<dyn MTLDevice>>>
unsafe fn device(&self) -> Option<Retained<ProtocolObject<dyn MTLDevice>>>
objc2-metal and non-watchOS only.Source§unsafe fn colorPixelFormat(&self) -> MTLPixelFormat
unsafe fn colorPixelFormat(&self) -> MTLPixelFormat
objc2-metal and non-watchOS only.Source§unsafe fn depthPixelFormat(&self) -> MTLPixelFormat
unsafe fn depthPixelFormat(&self) -> MTLPixelFormat
objc2-metal and non-watchOS only.Source§unsafe fn stencilPixelFormat(&self) -> MTLPixelFormat
unsafe fn stencilPixelFormat(&self) -> MTLPixelFormat
objc2-metal and non-watchOS only.Source§unsafe fn commandQueue(
&self,
) -> Option<Retained<ProtocolObject<dyn MTLCommandQueue>>>
unsafe fn commandQueue( &self, ) -> Option<Retained<ProtocolObject<dyn MTLCommandQueue>>>
objc2-metal and non-watchOS only.Source§unsafe fn audioEngine(&self) -> Retained<AVAudioEngine>
unsafe fn audioEngine(&self) -> Retained<AVAudioEngine>
objc2-avf-audio only.Source§unsafe fn audioEnvironmentNode(&self) -> Retained<AVAudioEnvironmentNode>
unsafe fn audioEnvironmentNode(&self) -> Retained<AVAudioEnvironmentNode>
objc2-avf-audio only.Source§unsafe fn audioListener(&self) -> Option<Retained<SCNNode>>
unsafe fn audioListener(&self) -> Option<Retained<SCNNode>>
SCNNode only.Source§unsafe fn setAudioListener(&self, audio_listener: Option<&SCNNode>)
unsafe fn setAudioListener(&self, audio_listener: Option<&SCNNode>)
SCNNode only.audioListener.Source§unsafe fn currentViewport(&self) -> CGRect
unsafe fn currentViewport(&self) -> CGRect
objc2-core-foundation only.Source§unsafe fn currentTime(&self) -> NSTimeInterval
unsafe fn currentTime(&self) -> NSTimeInterval
Source§unsafe fn setCurrentTime(&self, current_time: NSTimeInterval)
unsafe fn setCurrentTime(&self, current_time: NSTimeInterval)
currentTime.Source§unsafe fn usesReverseZ(&self) -> bool
unsafe fn usesReverseZ(&self) -> bool
Source§unsafe fn setUsesReverseZ(&self, uses_reverse_z: bool)
unsafe fn setUsesReverseZ(&self, uses_reverse_z: bool)
usesReverseZ.Source§impl SCNTechniqueSupport for SCNRenderer
Available on crate feature SCNTechnique only.
impl SCNTechniqueSupport for SCNRenderer
SCNTechnique only.