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