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