objc2_scene_kit/generated/
SCNRenderer.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9#[cfg(feature = "objc2-core-foundation")]
10use objc2_core_foundation::*;
11use objc2_foundation::*;
12#[cfg(feature = "objc2-metal")]
13#[cfg(not(target_os = "watchos"))]
14use objc2_metal::*;
15#[cfg(feature = "objc2-open-gl")]
16#[cfg(target_os = "macos")]
17use objc2_open_gl::*;
18
19use crate::*;
20
21extern_class!(
22    /// SCNRenderer lets you use the SceneKit renderer in an OpenGL context or Metal render pass descriptor of your own.
23    ///
24    /// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scnrenderer?language=objc)
25    #[unsafe(super(NSObject))]
26    #[derive(Debug, PartialEq, Eq, Hash)]
27    pub struct SCNRenderer;
28);
29
30extern_conformance!(
31    unsafe impl NSObjectProtocol for SCNRenderer {}
32);
33
34#[cfg(feature = "SCNSceneRenderer")]
35extern_conformance!(
36    unsafe impl SCNSceneRenderer for SCNRenderer {}
37);
38
39#[cfg(feature = "SCNTechnique")]
40extern_conformance!(
41    unsafe impl SCNTechniqueSupport for SCNRenderer {}
42);
43
44impl SCNRenderer {
45    extern_methods!(
46        #[cfg(feature = "objc2-open-gl")]
47        #[cfg(target_os = "macos")]
48        /// Creates a new renderer object.
49        ///
50        /// Parameter `context`: The context to render into.
51        ///
52        /// Parameter `options`: An optional dictionary for future extensions.
53        ///
54        /// # Safety
55        ///
56        /// - `context` must be a valid pointer or null.
57        /// - `options` generic should be of the correct type.
58        #[unsafe(method(rendererWithContext:options:))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn rendererWithContext_options(
61            context: CGLContextObj,
62            options: Option<&NSDictionary>,
63        ) -> Retained<Self>;
64
65        #[cfg(feature = "objc2-metal")]
66        #[cfg(not(target_os = "watchos"))]
67        /// Creates a new renderer object that renders using Metal.
68        ///
69        /// Parameter `device`: The metal device to use. Pass nil to let SceneKit choose a default device.
70        ///
71        /// Parameter `options`: An optional dictionary for future extensions.
72        ///
73        /// # Safety
74        ///
75        /// `options` generic should be of the correct type.
76        #[unsafe(method(rendererWithDevice:options:))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn rendererWithDevice_options(
79            device: Option<&ProtocolObject<dyn MTLDevice>>,
80            options: Option<&NSDictionary>,
81        ) -> Retained<Self>;
82
83        #[cfg(feature = "SCNScene")]
84        /// Specifies the scene of the receiver
85        #[unsafe(method(scene))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn scene(&self) -> Option<Retained<SCNScene>>;
88
89        #[cfg(feature = "SCNScene")]
90        /// Setter for [`scene`][Self::scene].
91        #[unsafe(method(setScene:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn setScene(&self, scene: Option<&SCNScene>);
94
95        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-metal"))]
96        #[cfg(not(target_os = "watchos"))]
97        /// updates and renders the receiver's scene at the specified time (system time) viewport, Metal command buffer and pass descriptor.
98        ///
99        /// Use this method to render using Metal.
100        #[unsafe(method(renderAtTime:viewport:commandBuffer:passDescriptor:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn renderAtTime_viewport_commandBuffer_passDescriptor(
103            &self,
104            time: CFTimeInterval,
105            viewport: CGRect,
106            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
107            render_pass_descriptor: &MTLRenderPassDescriptor,
108        );
109
110        #[cfg(feature = "objc2-core-foundation")]
111        /// updates and renders the receiver's scene at the specified time (system time).
112        ///
113        /// This method only work if the receiver was allocated with an OpenGL context. Use renderAtTime:withEncoder:pass:commandQueue: to render with Metal.
114        #[unsafe(method(renderAtTime:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn renderAtTime(&self, time: CFTimeInterval);
117
118        #[cfg(feature = "objc2-core-foundation")]
119        /// updates the receiver's scene at the specified time (system time).
120        #[unsafe(method(updateAtTime:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn updateAtTime(&self, time: CFTimeInterval);
123
124        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-metal"))]
125        #[cfg(not(target_os = "watchos"))]
126        /// renders the receiver's scene with the specified viewport, Metal command buffer and pass descriptor.
127        ///
128        /// 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.
129        #[unsafe(method(renderWithViewport:commandBuffer:passDescriptor:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn renderWithViewport_commandBuffer_passDescriptor(
132            &self,
133            viewport: CGRect,
134            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
135            render_pass_descriptor: &MTLRenderPassDescriptor,
136        );
137
138        #[cfg(feature = "objc2-core-foundation")]
139        /// 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.
140        #[unsafe(method(nextFrameTime))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn nextFrameTime(&self) -> CFTimeInterval;
143
144        #[cfg(all(
145            feature = "SCNSceneRenderer",
146            feature = "objc2-app-kit",
147            feature = "objc2-core-foundation"
148        ))]
149        #[cfg(target_os = "macos")]
150        /// renders the receiver's scene at the specified time (system time) into an image.
151        #[unsafe(method(snapshotAtTime:withSize:antialiasingMode:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn snapshotAtTime_withSize_antialiasingMode(
154            &self,
155            time: CFTimeInterval,
156            size: CGSize,
157            antialiasing_mode: SCNAntialiasingMode,
158        ) -> Retained<NSImage>;
159
160        #[cfg(all(feature = "SCNNode", feature = "objc2-core-foundation"))]
161        /// Update the specified probes by computing their incoming irradiance in the receiver's scene at the specified time.
162        ///
163        /// Parameter `lightProbes`: An array of nodes that must have a light probe attached.
164        ///
165        /// Parameter `time`: The time used to render the scene when computing the light probes irradiance.
166        ///
167        /// Light probes are only supported with Metal. This method is observable using NSProgress.
168        #[unsafe(method(updateProbes:atTime:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn updateProbes_atTime(
171            &self,
172            light_probes: &NSArray<SCNNode>,
173            time: CFTimeInterval,
174        );
175    );
176}
177
178/// Methods declared on superclass `NSObject`.
179impl SCNRenderer {
180    extern_methods!(
181        #[unsafe(method(init))]
182        #[unsafe(method_family = init)]
183        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
184
185        #[unsafe(method(new))]
186        #[unsafe(method_family = new)]
187        pub unsafe fn new() -> Retained<Self>;
188    );
189}