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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-model-io")]
use objc2_model_io::*;
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
use objc2_open_gl::*;
use crate::*;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/glkit/kglkmodelerrordomain?language=objc)
pub static kGLKModelErrorDomain: &'static NSString;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/glkit/kglkmodelerrorkey?language=objc)
pub static kGLKModelErrorKey: &'static NSString;
}
extern_class!(
/// Allocator passed to MDLAsset init method to load vertex and index data directly into OpenGL buffer object
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/glkit/glkmeshbufferallocator?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct GLKMeshBufferAllocator;
);
#[cfg(feature = "objc2-model-io")]
extern_conformance!(
unsafe impl MDLMeshBufferAllocator for GLKMeshBufferAllocator {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for GLKMeshBufferAllocator {}
);
impl GLKMeshBufferAllocator {
extern_methods!();
}
/// Methods declared on superclass `NSObject`.
impl GLKMeshBufferAllocator {
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>;
);
}
extern_class!(
/// Mesh buffers created when needs to allocate memory to back vertex or index data
///
/// Memory backing these buffer are OpenGL buffers. Model I/O will load index and vertex data from from a model asset directly in to the OpenGL buffer object.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/glkit/glkmeshbuffer?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct GLKMeshBuffer;
);
#[cfg(feature = "objc2-model-io")]
extern_conformance!(
unsafe impl MDLMeshBuffer for GLKMeshBuffer {}
);
extern_conformance!(
unsafe impl NSCopying for GLKMeshBuffer {}
);
unsafe impl CopyingHelper for GLKMeshBuffer {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for GLKMeshBuffer {}
);
impl GLKMeshBuffer {
extern_methods!(
/// Size in bytes of the buffer allocation
#[unsafe(method(length))]
#[unsafe(method_family = none)]
pub unsafe fn length(&self) -> NSUInteger;
/// Allocator object used to create this buffer.
///
/// This allcoator used for copy and relayout operations (such as when a new vertex descriptor is applied to a vertex buffer)
#[unsafe(method(allocator))]
#[unsafe(method_family = none)]
pub unsafe fn allocator(&self) -> Retained<GLKMeshBufferAllocator>;
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
/// glBufferName for buffer object backing vertex/index data
///
/// Many GLKMeshBuffers may reference the same OpenGL buffer object, but each with its own offset. (i.e. Many GLKMeshBuffers may be suballocated from a single OpenGL buffer object)
#[unsafe(method(glBufferName))]
#[unsafe(method_family = none)]
pub unsafe fn glBufferName(&self) -> GLuint;
/// Byte offset of the data within the OpenGL buffer
#[unsafe(method(offset))]
#[unsafe(method_family = none)]
pub unsafe fn offset(&self) -> NSUInteger;
#[cfg(feature = "objc2-model-io")]
/// Zone from which this buffer was created (if it was created witha zone)
///
/// A single GL buffer is allocated for each zone. Each zone could have many GLKMeshBuffers, each with it's own offset. If a GLKMeshBufferAllocator is used, Model I/O will attempt to load all vertex and indexData of a single model into a single zone. So although there maybe many GLKMeshBuffers for a model they will be backed with the same contigous GL buffer.
#[unsafe(method(zone))]
#[unsafe(method_family = none)]
pub unsafe fn zone(&self) -> Option<Retained<ProtocolObject<dyn MDLMeshBufferZone>>>;
#[cfg(feature = "objc2-model-io")]
/// the intended type of the buffer
#[unsafe(method(type))]
#[unsafe(method_family = none)]
pub unsafe fn r#type(&self) -> MDLMeshBufferType;
);
}
/// Methods declared on superclass `NSObject`.
impl GLKMeshBuffer {
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>;
);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/glkit/glksubmesh?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct GLKSubmesh;
);
extern_conformance!(
unsafe impl NSObjectProtocol for GLKSubmesh {}
);
impl GLKSubmesh {
extern_methods!(
/// Must be initialized by a GLKMesh object
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
/// Type of data in the elementBuffer (aka indexBuffer)
///
/// This value should be used for the type parameter of glDrawElements
#[unsafe(method(type))]
#[unsafe(method_family = none)]
pub unsafe fn r#type(&self) -> GLenum;
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
/// Primitive type mode value of data in the elementBuffer (aka indexBuffer)
///
/// This value should be used for the mode parameter in glDrawElements
#[unsafe(method(mode))]
#[unsafe(method_family = none)]
pub unsafe fn mode(&self) -> GLenum;
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
/// Number of elements (aka indicies) in the elementBuffer (aka indexBuffer)
///
/// This value should be used for the count parameter in glDrawElements
#[unsafe(method(elementCount))]
#[unsafe(method_family = none)]
pub unsafe fn elementCount(&self) -> GLsizei;
/// Name of buffer object with index data
///
/// The buffer name to be used with DrawElements
#[unsafe(method(elementBuffer))]
#[unsafe(method_family = none)]
pub unsafe fn elementBuffer(&self) -> Retained<GLKMeshBuffer>;
/// Parent GLKit mesh containing vertex data of this object
///
/// Buffer of this parent mesh should be set in the encoder before a drawIndexedPrimitives call is made
#[unsafe(method(mesh))]
#[unsafe(method_family = none)]
pub unsafe fn mesh(&self) -> Option<Retained<GLKMesh>>;
/// Name from the original MDLSubmesh object.
///
/// Although not directly used by this object, the application may use this to identify the submesh in it renderer/scene/world.
#[unsafe(method(name))]
#[unsafe(method_family = none)]
pub unsafe fn name(&self) -> Retained<NSString>;
);
}
/// Methods declared on superclass `NSObject`.
impl GLKSubmesh {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/glkit/glkmesh?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct GLKMesh;
);
extern_conformance!(
unsafe impl NSObjectProtocol for GLKMesh {}
);
impl GLKMesh {
extern_methods!(
/// Must initialize with a mesh
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
#[cfg(feature = "objc2-model-io")]
/// Initialize the mesh and the mesh's submeshes
///
/// This does NOT initialize any meshes that are children of the Model I/O mesh
/// Pointer to an NSError object which will be set if an error occurred
///
/// Parameter `mesh`: Model I/O Mesh from which to create this GLKit mesh
#[unsafe(method(initWithMesh:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithMesh_error(
this: Allocated<Self>,
mesh: &MDLMesh,
) -> Result<Retained<Self>, Retained<NSError>>;
#[cfg(feature = "objc2-model-io")]
/// Initialize all meshes in a Model I/O asset.
///
/// Returns: An array of GLKit meshes built an asset
///
/// Parameter `asset`: Model I/O asset from which to create GLKit meshes
///
/// Parameter `sourceMeshes`: Model I/O meshes corresponding the newly created GLKMeshes
///
/// Parameter `error`: Pointer to an NSError object set if an error occurred
///
/// Parameter `return`: GLKit meshes created from the Model I/O asset
///
/// A convenience method to create GLKit meshes from each mesh in a Model/IO asset. Resulting meshes are returned while Model I/O meshes from which they were generated will appear in the sourceMeshes array.
#[unsafe(method(newMeshesFromAsset:sourceMeshes:error:_))]
#[unsafe(method_family = new)]
pub unsafe fn newMeshesFromAsset_sourceMeshes_error(
asset: &MDLAsset,
source_meshes: Option<&mut Option<Retained<NSArray<MDLMesh>>>>,
) -> Result<Retained<NSArray<GLKMesh>>, Retained<NSError>>;
/// Number of verticies in the vertexBuffers
#[unsafe(method(vertexCount))]
#[unsafe(method_family = none)]
pub unsafe fn vertexCount(&self) -> NSUInteger;
/// Array of buffers in which mesh vertex data resides
#[unsafe(method(vertexBuffers))]
#[unsafe(method_family = none)]
pub unsafe fn vertexBuffers(&self) -> Retained<NSArray<GLKMeshBuffer>>;
#[cfg(feature = "objc2-model-io")]
/// Model I/O vertex descriptor specifying the layout of data in vertexBuffers
///
/// This is not directly used by this object, but the application can use this information to determine rendering state or setup a vertex attribute object.
#[unsafe(method(vertexDescriptor))]
#[unsafe(method_family = none)]
pub unsafe fn vertexDescriptor(&self) -> Retained<MDLVertexDescriptor>;
/// Submeshes containing index buffers to rendering mesh verticies.
///
/// Submeshes may also contain texture materials to apply when rendering this object
#[unsafe(method(submeshes))]
#[unsafe(method_family = none)]
pub unsafe fn submeshes(&self) -> Retained<NSArray<GLKSubmesh>>;
/// Name of the mesh copies from the originating Model I/O mesh
///
/// Can be used by the app to identiry the mesh in it's scene/world/renderer etc.
#[unsafe(method(name))]
#[unsafe(method_family = none)]
pub unsafe fn name(&self) -> Retained<NSString>;
);
}
/// Methods declared on superclass `NSObject`.
impl GLKMesh {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
/// Structure for parameters to use in glVertexAttribPointer given a MDLVertexForamt
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/glkit/glkvertexattributeparameters?language=objc)
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct GLKVertexAttributeParameters {
pub r#type: GLenum,
pub size: GLint,
pub normalized: GLboolean,
}
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
unsafe impl Encode for GLKVertexAttributeParameters {
const ENCODING: Encoding = Encoding::Struct(
"_GLKVertexAttributeParameters",
&[<GLenum>::ENCODING, <GLint>::ENCODING, <GLboolean>::ENCODING],
);
}
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
unsafe impl RefEncode for GLKVertexAttributeParameters {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C-unwind" {
/// Returns parameters to use in a call to glVertexAttribPointer given a MDLVertexFormat
#[cfg(all(feature = "objc2-model-io", feature = "objc2-open-gl"))]
#[cfg(target_os = "macos")]
pub fn GLKVertexAttributeParametersFromModelIO(
vertex_format: MDLVertexFormat,
) -> GLKVertexAttributeParameters;
}