objc2_scene_kit/generated/
SCNTechnique.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::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-metal")]
8#[cfg(not(target_os = "watchos"))]
9use objc2_metal::*;
10
11use crate::*;
12
13extern_class!(
14    /// SCNTechnique represents a rendering process that may require multiple passes.
15    ///
16    /// A technique is generally initialized from a Property List file. It can be set to any object that conforms to the SCNTechniqueSupport protocol.
17    ///
18    /// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scntechnique?language=objc)
19    #[unsafe(super(NSObject))]
20    #[derive(Debug, PartialEq, Eq, Hash)]
21    pub struct SCNTechnique;
22);
23
24unsafe impl NSCoding for SCNTechnique {}
25
26unsafe impl NSCopying for SCNTechnique {}
27
28unsafe impl CopyingHelper for SCNTechnique {
29    type Result = Self;
30}
31
32unsafe impl NSObjectProtocol for SCNTechnique {}
33
34unsafe impl NSSecureCoding for SCNTechnique {}
35
36#[cfg(feature = "SCNAnimation")]
37unsafe impl SCNAnimatable for SCNTechnique {}
38
39impl SCNTechnique {
40    extern_methods!(
41        /// Creates and returns a technique instance initialized with the specified dictionary.
42        ///
43        /// Parameter `dictionary`: The dictionary representation of the technique.
44        ///
45        /// The format of the dictionary is described below. Quoted strings can be any name of your choice. Tags are defined below.
46        /// The passes are executed sequentially as specified in the "sequence" section. The definition of each pass is within the "passes" section. A pass may have inputs/outputs that reference targets or symbols defined in the "targets" and "symbols" section. The entries of the "symbols" section can be set/get and animated with SCNTechnique's APIs below.
47        ///
48        /// {
49        /// sequence: ["Pass1", "Pass2", ...],
50        /// passes: {
51        /// "Pass1": {
52        /// outputs:
53        /// <outputs
54        /// >
55        /// inputs:
56        /// <inputs
57        /// >
58        /// draw:
59        /// <draw
60        /// command>
61        /// program:
62        /// <program
63        /// name>
64        /// metalVertexShader:
65        /// <METAL
66        /// vertex shader function name>
67        /// metalFragmentShader:
68        /// <METAL
69        /// fragment shader function name>
70        /// colorStates:
71        /// <color
72        /// states>               //optional
73        /// depthStates:
74        /// <depth
75        /// states>               //optional
76        /// stencilStates:
77        /// <stencil
78        /// states>           //optional
79        /// cullMode:
80        /// <cull
81        /// mode>                     //optional
82        /// blendStates:
83        /// <blend
84        /// states>               //optional
85        /// viewport:
86        /// <custom
87        /// viewport>               //optional
88        /// pointOfView:
89        /// <node
90        /// name>                  //optional
91        /// samples:
92        /// <sample
93        /// count>                   //optional
94        /// excludeCategoryMask:
95        /// <category
96        /// bitMask>   //optional
97        /// includeCategoryMask:
98        /// <category
99        /// bitMask>   //optional
100        /// },
101        /// "Pass2" : {
102        /// [...]
103        /// }
104        /// }
105        /// symbols: {
106        /// "symbol A": {
107        /// <symbol
108        /// description>
109        /// }
110        /// [...]
111        /// }
112        /// targets: {
113        /// "target A": {
114        /// <target
115        /// description>
116        /// }
117        /// [...]
118        /// },
119        ///
120        /// //optional
121        ///
122        /// bundle:
123        /// <bundleIdentifier
124        /// >,
125        /// metalLibraryName:
126        /// <metalLibraryName
127        /// >,
128        /// }
129        ///
130        /// <outputs
131        /// >:
132        /// The possible (and optional) keys with their possible associated values are:
133        /// color: a string referencing a color render target. See
134        /// <render
135        /// target reference>.
136        /// depth: a string referencing a depth render target. See
137        /// <render
138        /// target reference>.
139        /// stencil: a string referencing a stencil render target. See
140        /// <render
141        /// target reference>.
142        ///
143        /// <inputs
144        /// >:
145        /// The inputs are listed in a dictionary. The keys are the uniform name as specified in the program of this pass.
146        /// The values can be a single string referencing a symbol or a semantic or a target OR a dictionary with the following structure:
147        ///
148        /// {
149        /// target:
150        /// <render
151        /// target reference>,
152        ///
153        /// //optional:
154        /// minificationFilter: linear, nearest
155        /// magnificationFilter: linear, nearest
156        /// mipFilter: linear, nearest, none
157        /// wrapS: clamp, repeat, clampToBorder, mirror
158        /// wrapT: clamp, repeat, clampToBorder, mirror
159        /// wrapP: clamp, repeat, clampToBorder, mirror
160        /// maxAnisotropy: a number
161        /// }
162        ///
163        /// (See SCNMaterialProperty for more documentation and default values of these optional parameters.)
164        ///
165        /// <render
166        /// target reference>
167        /// A string referencing a target (i.e an entry in the top level "targets" dictionary) or one of the special strings below:
168        /// COLOR  The render target that represents that main color fragments that will be displayed on the screen ultimately.
169        /// DEPTH  The render target that represents that main depth fragments.
170        ///
171        /// <draw
172        /// command>
173        /// can be one of the following strings:
174        /// DRAW_SCENE:    render the entire scene
175        /// DRAW_QUAD:     render a fullscreen quad
176        /// DRAW_NODE:     render a node and its sub-tree. The node is specified by setting its name as the value for the key "node".
177        ///
178        /// <program
179        /// name>
180        /// Name of a program (a vertex shader + a fragment shader) located in the application bundle.
181        /// The vertex shader must have the extension "vsh" and the fragment shader "fsh".
182        ///
183        /// <METAL
184        /// vertex shader function name>
185        /// Name of a METAL function to use as the vertex shader.
186        ///
187        /// <METAL
188        /// fragment shader function name>
189        /// Name of a METAL function to use as the fragment shader.
190        ///
191        /// <color
192        /// states>
193        /// A dictionary with the following optional keys:
194        /// "clear" a boolean specifying whether the color target should be cleared or not
195        /// "clearColor" a string specifying the clear color as 4 float ("red green blue alpha"), or the string "sceneBackground" to clear with the scene background color.
196        ///
197        /// <depth
198        /// states>
199        /// A dictionary with the following optional keys:
200        /// "clear" a boolean specifying whether the depth target should be cleared or not
201        /// "enableWrite" a boolean specifying whether writing to depth should be enabled or not.
202        /// "enableRead" a boolean specifying whether reading from depth should be enabled or not.
203        /// "func" a string specifying depth function to use. See
204        /// <comparison
205        /// function> for the possible values.
206        ///
207        /// <stencil
208        /// states>
209        /// A dictionary with the following optional keys:
210        /// "clear" a boolean specifying whether the stencil target should be cleared or not
211        /// "enable" a boolean specifying whether writing to stencil should be enabled or not.
212        /// "behavior" a dictionary describing the stencil behavior of the front face, or of both faces if no backFaceBehavior is specified. See
213        /// <stencil
214        /// behavior> for the format of this dictionary.
215        /// "backFaceBehavior" a dictionary describing the behavior of the back face. See
216        /// <stencil
217        /// behavior> for the format of this dictionary.
218        ///
219        /// <stencil
220        /// behavior>
221        /// A dictionary with the following optional keys:
222        /// "depthFail" a string specifying the operation to do if the depth test fails. See
223        /// <stencil
224        /// operation> for the possible values.
225        /// "fail" a string specifying the operation to do if the stencil test fails. See
226        /// <Stencil
227        /// operation> for the possible values.
228        /// "pass" a string specifying the operation to do if the stencil test passes. See
229        /// <stencil
230        /// operation> for the possible values.
231        /// "function" a string specifying the stencil test. See
232        /// <comparison
233        /// function> for the possible values.
234        /// "readMask" a uint8_t number specifying a mask that is ANDed with both the reference value and the stored stencil value when the test is done
235        /// "writeMask" a uint8_t number specifies a bit mask to enable and disable writing of individual bits in the stencil planes
236        /// "referenceValue" a uint8_t number specifies the reference value for the stencil test. The initial value is 0.
237        ///
238        /// <stencil
239        /// operation>
240        /// A string specifying a stencil operation. It can be one of the following: keep, zero, replace, increment, decrement, invert, incrementWrap, decrementWrap
241        ///
242        /// <comparison
243        /// function>
244        /// A string specifying a comparison function. It can be one of the following: never, always, equal, notEqual, less, lessEqual, greater, greaterEqual
245        ///
246        /// <blend
247        /// states>
248        /// A dictionary with the following optional keys:
249        /// "enable" a boolean number specifying if the blending should be enabled or not. defaults to true.
250        /// "colorSrc" a string specifying a blend mode. See
251        /// <blend
252        /// mode>
253        /// "colorDst" a string specifying a blend mode. See
254        /// <blend
255        /// mode>
256        /// "alphaSrc" a string specifying a blend mode. See
257        /// <blend
258        /// mode>
259        /// "alphaDst" a string specifying a blend mode. See
260        /// <blend
261        /// mode>
262        /// "colorOp" a string specifying a blend operation. See
263        /// <blend
264        /// operation>
265        /// "alphaOp" a string specifying a blend operation. See
266        /// <blend
267        /// operation>
268        /// In no Blend states are specified, then the blending is turned off.
269        ///
270        /// <blend
271        /// mode>
272        /// A string specifying a blend mode. It can be one of the following: zero, one, srcColor, oneMinusSrcColor, srcAlpha, oneMinusSrcAlpha, dstColor, oneMinusDstColor, dstAlpha, oneMinusDstAlpha, constantColor, oneMinusConstantColor, constantAlpha, oneMinusConstantAlpha, alphaSaturate.
273        ///
274        /// <blend
275        /// operation>
276        /// A string specifying a blend operation. It can be one of the following: add, substract, reverseSubstract, min, max.
277        ///
278        /// <cull
279        /// mode>
280        /// A string specifying a cull mode. It can be one of the following: front, none, back.
281        ///
282        /// <custom
283        /// viewport>
284        /// A string specifying the viewport as 4 float.
285        ///
286        /// <category
287        /// bitMask>
288        /// A integer value representing a node category mask (see SCNNode's categoryBitMask).
289        /// if the key "excludeCategoryMask" is not specified then it defaults to 0.
290        /// if the key "includeCategoryMask" is not specified then it defaults to all bits set.
291        /// The DRAW_SCENE command will then render nodes that validate the following test (node.categoryBitMask
292        /// &
293        /// includeCategoryMask)
294        /// &
295        /// &
296        /// !(excludeCategoryMask
297        /// &
298        /// node.categoryBitMask).
299        ///
300        /// <node
301        /// name>
302        /// The name of a node, or "self" to reference the owner of the technique if any.
303        ///
304        /// <sample
305        /// count>
306        /// The number of samples (multisampling) used to render the pass.
307        ///
308        /// <symbol
309        /// description>
310        /// A dictionary with the following optional keys and their possible associated values:
311        ///
312        /// semantic: vertex, normal, color, texcoord, tangent, time, modelViewProjectionTransform, modelViewTransform, modelTransform, viewTransform, projectionTransform, normalTransform, modelViewProjectionInverseTransform, modelViewInverseTransform, modelInverseTransform, viewInverseTransform, projectionInverseTransform, normalInverseTransform
313        ///
314        /// type: float, vec2, vec3, vec4, mat4, int, ivec2, ivec3, ivec4, mat3, sampler2D, none. Every types can also be an array of the given type by adding [N] where N is the number of elements in the array.
315        ///
316        /// image: name of an image located in the application bundle. (only valid when type is sampler2D)
317        ///
318        /// if a semantic is set, no type is required.
319        /// Note that with Metal shaders you should not provide any semantic. Instead simply declare a struct in you shader and add the members you need named as specified in SceneKit/scn_metal.
320        ///
321        /// For example for a per-node semantic:
322        ///
323        /// struct MyStruct
324        /// {
325        /// float4x4 modelTransform;
326        /// float4x4 modelViewProjectionTransform;
327        /// };
328        /// then in your function add an argument that must be named “scn_node” to get the members automatically filed with node semantics (see the documentation in scn_metal).
329        ///
330        /// <target
331        /// description>
332        /// A dictionary with the following optional keys and their possible associated values:
333        ///
334        /// type: a string specifying the type of the render target. It can be one of the following: color, depth, stencil
335        /// format: a string specifying the format of the render target. It can be:
336        /// - for color targets (if not specified defaults to the framebuffer's pixel format)
337        /// - r8
338        /// - r16                   // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
339        /// - r16f
340        /// - r32f                  // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
341        /// - rg8                   // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
342        /// - rg16
343        /// - rg16f                 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
344        /// - rg32f                 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
345        /// - rgba8                 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
346        /// - rgba16                // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
347        /// - rgba16f               // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
348        /// - rgba32f
349        /// - rgba (deprecated)
350        /// - for depth targets
351        /// - depth16               // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
352        /// - depth24
353        /// - depth32f              // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
354        /// - for combined depth and stencil targets:
355        /// - depth24Unorm_stencil8 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
356        /// - depth32Float_stencil8 // Available since macOS 13, iOS 16, tvOS 16 and watchOS 9
357        /// scaleFactor: a float value (encapsulated in a NSNumber) that controls the size of the render target. Defaults to 1, which means 1x the size of the main viewport.
358        /// size: a string with the format %dx%d that controls the size of the render target.
359        /// persistent: a boolean that tells if this target should persist from one frame to the next. It permits to create temporal effects suchs as motion blur. Defaults to NO.
360        ///
361        /// <bundleIdentifier
362        /// >
363        /// An optional bundle identifier to load metal programs from
364        ///
365        /// <metalLibraryName
366        /// >
367        /// An optional metal library name to load metal programs from. The metallib file is located from the default or specified bundle using NSBundle pathForResource:ofType:.
368        #[unsafe(method(techniqueWithDictionary:))]
369        #[unsafe(method_family = none)]
370        pub unsafe fn techniqueWithDictionary(
371            dictionary: &NSDictionary<NSString, AnyObject>,
372        ) -> Option<Retained<SCNTechnique>>;
373
374        /// Creates and returns a technique by sequencing the passes from the specified techniques.
375        ///
376        /// Parameter `techniques`: The techniques to sequence.
377        ///
378        /// The passes from "techniques" are executed sequentially. The symbols and targets are merged. This allows to use the same uniform ad targets across multiple techniques.
379        #[unsafe(method(techniqueBySequencingTechniques:))]
380        #[unsafe(method_family = none)]
381        pub unsafe fn techniqueBySequencingTechniques(
382            techniques: &NSArray<SCNTechnique>,
383        ) -> Option<Retained<SCNTechnique>>;
384
385        #[cfg(all(
386            feature = "SCNNode",
387            feature = "SCNRenderer",
388            feature = "SCNShadable",
389            feature = "block2"
390        ))]
391        /// Sets the block to call at render time to bind the value for the specified symbol of the receiver.
392        ///
393        /// Parameter `symbol`: The name of the symbol to bind a value for.
394        ///
395        /// Parameter `block`: The block to call to bind the specified symbol.
396        ///
397        /// The block will be called at every frame for every pass referencing the specified symbol.
398        #[unsafe(method(handleBindingOfSymbol:usingBlock:))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn handleBindingOfSymbol_usingBlock(
401            &self,
402            symbol: &NSString,
403            block: SCNBindingBlock,
404        );
405
406        /// Returns the dictionary representation of the technique.
407        #[unsafe(method(dictionaryRepresentation))]
408        #[unsafe(method_family = none)]
409        pub unsafe fn dictionaryRepresentation(
410            &self,
411        ) -> Retained<NSDictionary<NSString, AnyObject>>;
412
413        #[unsafe(method(objectForKeyedSubscript:))]
414        #[unsafe(method_family = none)]
415        pub unsafe fn objectForKeyedSubscript(
416            &self,
417            key: &AnyObject,
418        ) -> Option<Retained<AnyObject>>;
419
420        #[unsafe(method(setObject:forKeyedSubscript:))]
421        #[unsafe(method_family = none)]
422        pub unsafe fn setObject_forKeyedSubscript(
423            &self,
424            obj: Option<&AnyObject>,
425            key: &ProtocolObject<dyn NSCopying>,
426        );
427
428        #[cfg(feature = "objc2-metal")]
429        #[cfg(not(target_os = "watchos"))]
430        /// The Metal library to use to load the Metal programs specified in the technique description. Defaults to nil which corresponds to the default Metal library.
431        #[unsafe(method(library))]
432        #[unsafe(method_family = none)]
433        pub unsafe fn library(&self) -> Option<Retained<ProtocolObject<dyn MTLLibrary>>>;
434
435        #[cfg(feature = "objc2-metal")]
436        #[cfg(not(target_os = "watchos"))]
437        /// Setter for [`library`][Self::library].
438        #[unsafe(method(setLibrary:))]
439        #[unsafe(method_family = none)]
440        pub unsafe fn setLibrary(&self, library: Option<&ProtocolObject<dyn MTLLibrary>>);
441    );
442}
443
444/// Methods declared on superclass `NSObject`.
445impl SCNTechnique {
446    extern_methods!(
447        #[unsafe(method(init))]
448        #[unsafe(method_family = init)]
449        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
450
451        #[unsafe(method(new))]
452        #[unsafe(method_family = new)]
453        pub unsafe fn new() -> Retained<Self>;
454    );
455}
456
457extern_protocol!(
458    /// The SCNTechniqueSupport protocol describes an object that supports single or multi-pass techniques
459    ///
460    /// See also [Apple's documentation](https://developer.apple.com/documentation/scenekit/scntechniquesupport?language=objc)
461    pub unsafe trait SCNTechniqueSupport: NSObjectProtocol {
462        /// Specifies the technique of the receiver. Defaults to nil.
463        #[unsafe(method(technique))]
464        #[unsafe(method_family = none)]
465        unsafe fn technique(&self) -> Option<Retained<SCNTechnique>>;
466
467        /// Setter for [`technique`][Self::technique].
468        #[unsafe(method(setTechnique:))]
469        #[unsafe(method_family = none)]
470        unsafe fn setTechnique(&self, technique: Option<&SCNTechnique>);
471    }
472);