objc2_sprite_kit/generated/
SKShader.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
8use crate::*;
9
10extern_class!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/spritekit/skshader?language=objc)
12    #[unsafe(super(NSObject))]
13    #[derive(Debug, PartialEq, Eq, Hash)]
14    pub struct SKShader;
15);
16
17unsafe impl NSCoding for SKShader {}
18
19unsafe impl NSCopying for SKShader {}
20
21unsafe impl CopyingHelper for SKShader {
22    type Result = Self;
23}
24
25unsafe impl NSObjectProtocol for SKShader {}
26
27unsafe impl NSSecureCoding for SKShader {}
28
29impl SKShader {
30    extern_methods!(
31        /// Create a custom shader with source code.
32        ///
33        ///
34        /// Parameter `source`: the source code for the custom fragment shader.
35        #[unsafe(method(initWithSource:))]
36        #[unsafe(method_family = init)]
37        pub unsafe fn initWithSource(this: Allocated<Self>, source: &NSString) -> Retained<Self>;
38
39        #[cfg(feature = "SKUniform")]
40        /// Create a custom shader with source code and uniforms.
41        ///
42        ///
43        /// Parameter `source`: the source code for the custom fragment shader.
44        ///
45        /// Parameter `uniforms`: the array of uniforms supplied to this shader
46        #[unsafe(method(initWithSource:uniforms:))]
47        #[unsafe(method_family = init)]
48        pub unsafe fn initWithSource_uniforms(
49            this: Allocated<Self>,
50            source: &NSString,
51            uniforms: &NSArray<SKUniform>,
52        ) -> Retained<Self>;
53
54        #[unsafe(method(shader))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn shader() -> Retained<Self>;
57
58        #[unsafe(method(shaderWithSource:))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn shaderWithSource(source: &NSString) -> Retained<Self>;
61
62        #[cfg(feature = "SKUniform")]
63        #[unsafe(method(shaderWithSource:uniforms:))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn shaderWithSource_uniforms(
66            source: &NSString,
67            uniforms: &NSArray<SKUniform>,
68        ) -> Retained<Self>;
69
70        /// Loads a shader source file named 'name' from the main bundle. This is simpler yet functionally equivalent to the following code
71        ///
72        /// [SKShader shaderWithSource:[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:name ofType:
73        /// "
74        /// fsh"]
75        /// encoding:NSUTF8StringEncoding
76        /// error:NULL]];
77        ///
78        /// The encoding is assumed to be NSUTF8StringEncoding.
79        #[unsafe(method(shaderWithFileNamed:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn shaderWithFileNamed(name: &NSString) -> Retained<Self>;
82
83        /// Shader source must define the 'main' method of the fragment shader
84        ///
85        /// Your shader must assign a premultipled fragment value to 'gl_FragColor'
86        ///
87        /// The following implicit uniforms are available:
88        ///
89        /// 1. sampler2D u_texture  (the primary texuture attached the the sprite)
90        ///
91        /// The following varyings are available:
92        ///
93        /// 1. vec2 v_tex_coord  (normalized texture coordiantes for the primary texture)
94        /// 2. vec4 v_color_mix  (premultiplied color value based on color
95        /// &
96        /// alpha)
97        ///
98        /// The following functions are available:
99        ///
100        /// 1. vec4 SKDefaultShading()  (returns the fragment value that would have been output if no shader was used)
101        ///
102        ///
103        /// Sample shader source that produces the same result are SpriteKit's normal rendering:
104        ///
105        /// "void main() { gl_FragColor = SKDefaultShading(); }"
106        #[unsafe(method(source))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn source(&self) -> Option<Retained<NSString>>;
109
110        /// Setter for [`source`][Self::source].
111        #[unsafe(method(setSource:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn setSource(&self, source: Option<&NSString>);
114
115        #[cfg(feature = "SKUniform")]
116        /// You may define additional uniforms to be used in your shader here.
117        /// There is no need to declare them in you source, just use them by name.
118        ///
119        /// All uniforms declared must be used within the source.
120        #[unsafe(method(uniforms))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn uniforms(&self) -> Retained<NSArray<SKUniform>>;
123
124        #[cfg(feature = "SKUniform")]
125        /// Setter for [`uniforms`][Self::uniforms].
126        #[unsafe(method(setUniforms:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn setUniforms(&self, uniforms: &NSArray<SKUniform>);
129
130        #[cfg(feature = "SKUniform")]
131        #[unsafe(method(addUniform:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn addUniform(&self, uniform: &SKUniform);
134
135        #[cfg(feature = "SKUniform")]
136        #[unsafe(method(uniformNamed:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn uniformNamed(&self, name: &NSString) -> Option<Retained<SKUniform>>;
139
140        #[unsafe(method(removeUniformNamed:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn removeUniformNamed(&self, name: &NSString);
143
144        #[cfg(feature = "SKAttribute")]
145        #[unsafe(method(attributes))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn attributes(&self) -> Retained<NSArray<SKAttribute>>;
148
149        #[cfg(feature = "SKAttribute")]
150        /// Setter for [`attributes`][Self::attributes].
151        #[unsafe(method(setAttributes:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn setAttributes(&self, attributes: &NSArray<SKAttribute>);
154    );
155}
156
157/// Methods declared on superclass `NSObject`.
158impl SKShader {
159    extern_methods!(
160        #[unsafe(method(init))]
161        #[unsafe(method_family = init)]
162        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
163
164        #[unsafe(method(new))]
165        #[unsafe(method_family = new)]
166        pub unsafe fn new() -> Retained<Self>;
167    );
168}