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