objc2_gl_kit/generated/
GLKModel.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6#[cfg(feature = "objc2-model-io")]
7use objc2_model_io::*;
8#[cfg(feature = "objc2-open-gl")]
9#[cfg(target_os = "macos")]
10use objc2_open_gl::*;
11
12use crate::*;
13
14extern "C" {
15    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/kglkmodelerrordomain?language=objc)
16    pub static kGLKModelErrorDomain: &'static NSString;
17}
18
19extern "C" {
20    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/kglkmodelerrorkey?language=objc)
21    pub static kGLKModelErrorKey: &'static NSString;
22}
23
24extern_class!(
25    /// Allocator passed to MDLAsset init method to load vertex and index data directly into OpenGL buffer object
26    ///
27    /// See also [Apple's documentation](https://developer.apple.com/documentation/glkit/glkmeshbufferallocator?language=objc)
28    #[unsafe(super(NSObject))]
29    #[derive(Debug, PartialEq, Eq, Hash)]
30    pub struct GLKMeshBufferAllocator;
31);
32
33#[cfg(feature = "objc2-model-io")]
34extern_conformance!(
35    unsafe impl MDLMeshBufferAllocator for GLKMeshBufferAllocator {}
36);
37
38extern_conformance!(
39    unsafe impl NSObjectProtocol for GLKMeshBufferAllocator {}
40);
41
42impl GLKMeshBufferAllocator {
43    extern_methods!();
44}
45
46/// Methods declared on superclass `NSObject`.
47impl GLKMeshBufferAllocator {
48    extern_methods!(
49        #[unsafe(method(init))]
50        #[unsafe(method_family = init)]
51        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
52
53        #[unsafe(method(new))]
54        #[unsafe(method_family = new)]
55        pub unsafe fn new() -> Retained<Self>;
56    );
57}
58
59extern_class!(
60    /// Mesh buffers created when  needs to allocate memory to back vertex or index data
61    ///
62    /// 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.
63    ///
64    /// See also [Apple's documentation](https://developer.apple.com/documentation/glkit/glkmeshbuffer?language=objc)
65    #[unsafe(super(NSObject))]
66    #[derive(Debug, PartialEq, Eq, Hash)]
67    pub struct GLKMeshBuffer;
68);
69
70#[cfg(feature = "objc2-model-io")]
71extern_conformance!(
72    unsafe impl MDLMeshBuffer for GLKMeshBuffer {}
73);
74
75extern_conformance!(
76    unsafe impl NSCopying for GLKMeshBuffer {}
77);
78
79unsafe impl CopyingHelper for GLKMeshBuffer {
80    type Result = Self;
81}
82
83extern_conformance!(
84    unsafe impl NSObjectProtocol for GLKMeshBuffer {}
85);
86
87impl GLKMeshBuffer {
88    extern_methods!(
89        /// Size in bytes of the buffer allocation
90        #[unsafe(method(length))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn length(&self) -> NSUInteger;
93
94        /// Allocator object used to create this buffer.
95        ///
96        /// This allcoator used for copy and relayout operations (such as when a new vertex descriptor is applied to a vertex buffer)
97        #[unsafe(method(allocator))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn allocator(&self) -> Retained<GLKMeshBufferAllocator>;
100
101        #[cfg(feature = "objc2-open-gl")]
102        #[cfg(target_os = "macos")]
103        /// glBufferName for buffer object backing vertex/index data
104        ///
105        /// 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)
106        #[unsafe(method(glBufferName))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn glBufferName(&self) -> GLuint;
109
110        /// Byte offset of the data within the OpenGL buffer
111        #[unsafe(method(offset))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn offset(&self) -> NSUInteger;
114
115        #[cfg(feature = "objc2-model-io")]
116        /// Zone from which this buffer was created (if it was created witha zone)
117        ///
118        /// 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.
119        #[unsafe(method(zone))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn zone(&self) -> Option<Retained<ProtocolObject<dyn MDLMeshBufferZone>>>;
122
123        #[cfg(feature = "objc2-model-io")]
124        /// the intended type of the buffer
125        #[unsafe(method(type))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn r#type(&self) -> MDLMeshBufferType;
128    );
129}
130
131/// Methods declared on superclass `NSObject`.
132impl GLKMeshBuffer {
133    extern_methods!(
134        #[unsafe(method(init))]
135        #[unsafe(method_family = init)]
136        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
137
138        #[unsafe(method(new))]
139        #[unsafe(method_family = new)]
140        pub unsafe fn new() -> Retained<Self>;
141    );
142}
143
144extern_class!(
145    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/glksubmesh?language=objc)
146    #[unsafe(super(NSObject))]
147    #[derive(Debug, PartialEq, Eq, Hash)]
148    pub struct GLKSubmesh;
149);
150
151extern_conformance!(
152    unsafe impl NSObjectProtocol for GLKSubmesh {}
153);
154
155impl GLKSubmesh {
156    extern_methods!(
157        /// Must be initialized by a GLKMesh object
158        #[unsafe(method(init))]
159        #[unsafe(method_family = init)]
160        pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
161
162        #[cfg(feature = "objc2-open-gl")]
163        #[cfg(target_os = "macos")]
164        /// Type of data in the elementBuffer (aka indexBuffer)
165        ///
166        /// This value should be used for the type parameter of glDrawElements
167        #[unsafe(method(type))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn r#type(&self) -> GLenum;
170
171        #[cfg(feature = "objc2-open-gl")]
172        #[cfg(target_os = "macos")]
173        /// Primitive type mode value of data in the elementBuffer (aka indexBuffer)
174        ///
175        /// This value should be used for the mode parameter in glDrawElements
176        #[unsafe(method(mode))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn mode(&self) -> GLenum;
179
180        #[cfg(feature = "objc2-open-gl")]
181        #[cfg(target_os = "macos")]
182        /// Number of elements (aka indicies) in the elementBuffer (aka indexBuffer)
183        ///
184        /// This value should be used for the count parameter in glDrawElements
185        #[unsafe(method(elementCount))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn elementCount(&self) -> GLsizei;
188
189        /// Name of buffer object with index data
190        ///
191        /// The buffer name to be used with DrawElements
192        #[unsafe(method(elementBuffer))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn elementBuffer(&self) -> Retained<GLKMeshBuffer>;
195
196        /// Parent GLKit mesh containing vertex data of this object
197        ///
198        /// Buffer of this parent mesh should be set in the encoder before a drawIndexedPrimitives call is made
199        #[unsafe(method(mesh))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn mesh(&self) -> Option<Retained<GLKMesh>>;
202
203        /// Name from the original MDLSubmesh object.
204        ///
205        /// Although not directly used by this object, the application may use this to identify the submesh in it renderer/scene/world.
206        #[unsafe(method(name))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn name(&self) -> Retained<NSString>;
209    );
210}
211
212/// Methods declared on superclass `NSObject`.
213impl GLKSubmesh {
214    extern_methods!(
215        #[unsafe(method(new))]
216        #[unsafe(method_family = new)]
217        pub unsafe fn new() -> Retained<Self>;
218    );
219}
220
221extern_class!(
222    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/glkmesh?language=objc)
223    #[unsafe(super(NSObject))]
224    #[derive(Debug, PartialEq, Eq, Hash)]
225    pub struct GLKMesh;
226);
227
228extern_conformance!(
229    unsafe impl NSObjectProtocol for GLKMesh {}
230);
231
232impl GLKMesh {
233    extern_methods!(
234        /// Must initialize with a mesh
235        #[unsafe(method(init))]
236        #[unsafe(method_family = init)]
237        pub unsafe fn init(this: Allocated<Self>) -> Option<Retained<Self>>;
238
239        #[cfg(feature = "objc2-model-io")]
240        /// Initialize the mesh and the mesh's submeshes
241        ///
242        /// This does NOT initialize any meshes that are children of the Model I/O mesh
243        /// Pointer to an NSError object which will be set if an error occurred
244        ///
245        /// Parameter `mesh`: Model I/O Mesh from which to create this GLKit mesh
246        #[unsafe(method(initWithMesh:error:_))]
247        #[unsafe(method_family = init)]
248        pub unsafe fn initWithMesh_error(
249            this: Allocated<Self>,
250            mesh: &MDLMesh,
251        ) -> Result<Retained<Self>, Retained<NSError>>;
252
253        #[cfg(feature = "objc2-model-io")]
254        /// Initialize all meshes in a Model I/O asset.
255        ///
256        /// Returns: An array of GLKit meshes built an asset
257        ///
258        /// Parameter `asset`: Model I/O asset from which to create GLKit meshes
259        ///
260        /// Parameter `sourceMeshes`: Model I/O meshes corresponding the newly created GLKMeshes
261        ///
262        /// Parameter `error`: Pointer to an NSError object set if an error occurred
263        ///
264        /// Parameter `return`: GLKit meshes created from the Model I/O asset
265        ///
266        /// 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.
267        #[unsafe(method(newMeshesFromAsset:sourceMeshes:error:_))]
268        #[unsafe(method_family = new)]
269        pub unsafe fn newMeshesFromAsset_sourceMeshes_error(
270            asset: &MDLAsset,
271            source_meshes: Option<&mut Option<Retained<NSArray<MDLMesh>>>>,
272        ) -> Result<Retained<NSArray<GLKMesh>>, Retained<NSError>>;
273
274        /// Number of verticies in the vertexBuffers
275        #[unsafe(method(vertexCount))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn vertexCount(&self) -> NSUInteger;
278
279        /// Array of buffers in which mesh vertex data resides
280        #[unsafe(method(vertexBuffers))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn vertexBuffers(&self) -> Retained<NSArray<GLKMeshBuffer>>;
283
284        #[cfg(feature = "objc2-model-io")]
285        /// Model I/O vertex descriptor specifying the layout of data in vertexBuffers
286        ///
287        /// 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.
288        #[unsafe(method(vertexDescriptor))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn vertexDescriptor(&self) -> Retained<MDLVertexDescriptor>;
291
292        /// Submeshes containing index buffers to rendering mesh verticies.
293        ///
294        /// Submeshes may also contain texture materials to apply when rendering this object
295        #[unsafe(method(submeshes))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn submeshes(&self) -> Retained<NSArray<GLKSubmesh>>;
298
299        /// Name of the mesh copies from the originating Model I/O mesh
300        ///
301        /// Can be used by the app to identiry the mesh in it's scene/world/renderer etc.
302        #[unsafe(method(name))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn name(&self) -> Retained<NSString>;
305    );
306}
307
308/// Methods declared on superclass `NSObject`.
309impl GLKMesh {
310    extern_methods!(
311        #[unsafe(method(new))]
312        #[unsafe(method_family = new)]
313        pub unsafe fn new() -> Retained<Self>;
314    );
315}
316
317/// Structure for parameters to use in glVertexAttribPointer given a MDLVertexForamt
318///
319/// See also [Apple's documentation](https://developer.apple.com/documentation/glkit/glkvertexattributeparameters?language=objc)
320#[cfg(feature = "objc2-open-gl")]
321#[cfg(target_os = "macos")]
322#[repr(C)]
323#[derive(Clone, Copy, Debug, PartialEq)]
324pub struct GLKVertexAttributeParameters {
325    pub r#type: GLenum,
326    pub size: GLint,
327    pub normalized: GLboolean,
328}
329
330#[cfg(feature = "objc2-open-gl")]
331#[cfg(target_os = "macos")]
332unsafe impl Encode for GLKVertexAttributeParameters {
333    const ENCODING: Encoding = Encoding::Struct(
334        "_GLKVertexAttributeParameters",
335        &[<GLenum>::ENCODING, <GLint>::ENCODING, <GLboolean>::ENCODING],
336    );
337}
338
339#[cfg(feature = "objc2-open-gl")]
340#[cfg(target_os = "macos")]
341unsafe impl RefEncode for GLKVertexAttributeParameters {
342    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
343}
344
345extern "C-unwind" {
346    /// Returns parameters to use in a call to glVertexAttribPointer given a MDLVertexFormat
347    #[cfg(all(feature = "objc2-model-io", feature = "objc2-open-gl"))]
348    #[cfg(target_os = "macos")]
349    pub fn GLKVertexAttributeParametersFromModelIO(
350        vertex_format: MDLVertexFormat,
351    ) -> GLKVertexAttributeParameters;
352}