objc2-gl-kit 0.3.2

Bindings to the GLKit framework
Documentation
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "dispatch2")]
use dispatch2::*;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
use objc2_foundation::*;
#[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/glktextureloaderapplypremultiplication?language=objc)
    pub static GLKTextureLoaderApplyPremultiplication: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureloadergeneratemipmaps?language=objc)
    pub static GLKTextureLoaderGenerateMipmaps: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureloaderoriginbottomleft?language=objc)
    pub static GLKTextureLoaderOriginBottomLeft: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureloadergrayscaleasalpha?language=objc)
    pub static GLKTextureLoaderGrayscaleAsAlpha: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureloadersrgb?language=objc)
    pub static GLKTextureLoaderSRGB: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureloadererrordomain?language=objc)
    pub static GLKTextureLoaderErrorDomain: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureloadererrorkey?language=objc)
    pub static GLKTextureLoaderErrorKey: &'static NSString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureloaderglerrorkey?language=objc)
    pub static GLKTextureLoaderGLErrorKey: &'static NSString;
}

/// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureloadererror?language=objc)
// NS_ENUM
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GLKTextureLoaderError(pub GLuint);
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
impl GLKTextureLoaderError {
    #[doc(alias = "GLKTextureLoaderErrorFileOrURLNotFound")]
    pub const FileOrURLNotFound: Self = Self(0);
    #[doc(alias = "GLKTextureLoaderErrorInvalidNSData")]
    pub const InvalidNSData: Self = Self(1);
    #[doc(alias = "GLKTextureLoaderErrorInvalidCGImage")]
    pub const InvalidCGImage: Self = Self(2);
    #[doc(alias = "GLKTextureLoaderErrorUnknownPathType")]
    pub const UnknownPathType: Self = Self(3);
    #[doc(alias = "GLKTextureLoaderErrorUnknownFileType")]
    pub const UnknownFileType: Self = Self(4);
    #[doc(alias = "GLKTextureLoaderErrorPVRAtlasUnsupported")]
    pub const PVRAtlasUnsupported: Self = Self(5);
    #[doc(alias = "GLKTextureLoaderErrorCubeMapInvalidNumFiles")]
    pub const CubeMapInvalidNumFiles: Self = Self(6);
    #[doc(alias = "GLKTextureLoaderErrorCompressedTextureUpload")]
    pub const CompressedTextureUpload: Self = Self(7);
    #[doc(alias = "GLKTextureLoaderErrorUncompressedTextureUpload")]
    pub const UncompressedTextureUpload: Self = Self(8);
    #[doc(alias = "GLKTextureLoaderErrorUnsupportedCubeMapDimensions")]
    pub const UnsupportedCubeMapDimensions: Self = Self(9);
    #[doc(alias = "GLKTextureLoaderErrorUnsupportedBitDepth")]
    pub const UnsupportedBitDepth: Self = Self(10);
    #[doc(alias = "GLKTextureLoaderErrorUnsupportedPVRFormat")]
    pub const UnsupportedPVRFormat: Self = Self(11);
    #[doc(alias = "GLKTextureLoaderErrorDataPreprocessingFailure")]
    pub const DataPreprocessingFailure: Self = Self(12);
    #[doc(alias = "GLKTextureLoaderErrorMipmapUnsupported")]
    pub const MipmapUnsupported: Self = Self(13);
    #[doc(alias = "GLKTextureLoaderErrorUnsupportedOrientation")]
    pub const UnsupportedOrientation: Self = Self(14);
    #[doc(alias = "GLKTextureLoaderErrorReorientationFailure")]
    pub const ReorientationFailure: Self = Self(15);
    #[doc(alias = "GLKTextureLoaderErrorAlphaPremultiplicationFailure")]
    pub const AlphaPremultiplicationFailure: Self = Self(16);
    #[doc(alias = "GLKTextureLoaderErrorInvalidEAGLContext")]
    pub const InvalidEAGLContext: Self = Self(17);
    #[doc(alias = "GLKTextureLoaderErrorIncompatibleFormatSRGB")]
    pub const IncompatibleFormatSRGB: Self = Self(18);
    #[doc(alias = "GLKTextureLoaderErrorUnsupportedTextureTarget")]
    pub const UnsupportedTextureTarget: Self = Self(19);
}

#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
unsafe impl Encode for GLKTextureLoaderError {
    const ENCODING: Encoding = GLuint::ENCODING;
}

#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
unsafe impl RefEncode for GLKTextureLoaderError {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureinfoalphastate?language=objc)
// NS_ENUM
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GLKTextureInfoAlphaState(pub GLint);
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
impl GLKTextureInfoAlphaState {
    #[doc(alias = "GLKTextureInfoAlphaStateNone")]
    pub const None: Self = Self(0);
    #[doc(alias = "GLKTextureInfoAlphaStateNonPremultiplied")]
    pub const NonPremultiplied: Self = Self(1);
    #[doc(alias = "GLKTextureInfoAlphaStatePremultiplied")]
    pub const Premultiplied: Self = Self(2);
}

#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
unsafe impl Encode for GLKTextureInfoAlphaState {
    const ENCODING: Encoding = GLint::ENCODING;
}

#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
unsafe impl RefEncode for GLKTextureInfoAlphaState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureinfoorigin?language=objc)
// NS_ENUM
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GLKTextureInfoOrigin(pub GLint);
#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
impl GLKTextureInfoOrigin {
    #[doc(alias = "GLKTextureInfoOriginUnknown")]
    pub const Unknown: Self = Self(0);
    #[doc(alias = "GLKTextureInfoOriginTopLeft")]
    pub const TopLeft: Self = Self(1);
    #[doc(alias = "GLKTextureInfoOriginBottomLeft")]
    pub const BottomLeft: Self = Self(2);
}

#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
unsafe impl Encode for GLKTextureInfoOrigin {
    const ENCODING: Encoding = GLint::ENCODING;
}

#[cfg(feature = "objc2-open-gl")]
#[cfg(target_os = "macos")]
unsafe impl RefEncode for GLKTextureInfoOrigin {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureinfo?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GLKTextureInfo;
);

extern_conformance!(
    unsafe impl NSCopying for GLKTextureInfo {}
);

unsafe impl CopyingHelper for GLKTextureInfo {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for GLKTextureInfo {}
);

impl GLKTextureInfo {
    extern_methods!(
        #[cfg(feature = "objc2-open-gl")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(name))]
        #[unsafe(method_family = none)]
        pub unsafe fn name(&self) -> GLuint;

        #[cfg(feature = "objc2-open-gl")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(target))]
        #[unsafe(method_family = none)]
        pub unsafe fn target(&self) -> GLenum;

        #[cfg(feature = "objc2-open-gl")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(width))]
        #[unsafe(method_family = none)]
        pub unsafe fn width(&self) -> GLuint;

        #[cfg(feature = "objc2-open-gl")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(height))]
        #[unsafe(method_family = none)]
        pub unsafe fn height(&self) -> GLuint;

        #[cfg(feature = "objc2-open-gl")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(depth))]
        #[unsafe(method_family = none)]
        pub unsafe fn depth(&self) -> GLuint;

        #[cfg(feature = "objc2-open-gl")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(alphaState))]
        #[unsafe(method_family = none)]
        pub unsafe fn alphaState(&self) -> GLKTextureInfoAlphaState;

        #[cfg(feature = "objc2-open-gl")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(textureOrigin))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureOrigin(&self) -> GLKTextureInfoOrigin;

        #[unsafe(method(containsMipmaps))]
        #[unsafe(method_family = none)]
        pub unsafe fn containsMipmaps(&self) -> bool;

        #[cfg(feature = "objc2-open-gl")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(mimapLevelCount))]
        #[unsafe(method_family = none)]
        pub unsafe fn mimapLevelCount(&self) -> GLuint;

        #[cfg(feature = "objc2-open-gl")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(arrayLength))]
        #[unsafe(method_family = none)]
        pub unsafe fn arrayLength(&self) -> GLuint;
    );
}

/// Methods declared on superclass `NSObject`.
impl GLKTextureInfo {
    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>;
    );
}

/// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureloadercallback?language=objc)
#[cfg(feature = "block2")]
pub type GLKTextureLoaderCallback =
    *mut block2::DynBlock<dyn Fn(*mut GLKTextureInfo, *mut NSError)>;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/glkit/glktextureloader?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct GLKTextureLoader;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for GLKTextureLoader {}
);

impl GLKTextureLoader {
    extern_methods!(
        #[unsafe(method(textureWithContentsOfFile:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureWithContentsOfFile_options_error(
            path: &NSString,
            options: Option<&NSDictionary<NSString, NSNumber>>,
        ) -> Result<Retained<GLKTextureInfo>, Retained<NSError>>;

        #[unsafe(method(textureWithContentsOfURL:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureWithContentsOfURL_options_error(
            url: &NSURL,
            options: Option<&NSDictionary<NSString, NSNumber>>,
        ) -> Result<Retained<GLKTextureInfo>, Retained<NSError>>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(textureWithName:scaleFactor:bundle:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureWithName_scaleFactor_bundle_options_error(
            name: &NSString,
            scale_factor: CGFloat,
            bundle: Option<&NSBundle>,
            options: Option<&NSDictionary<NSString, NSNumber>>,
        ) -> Result<Retained<GLKTextureInfo>, Retained<NSError>>;

        #[unsafe(method(textureWithContentsOfData:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureWithContentsOfData_options_error(
            data: &NSData,
            options: Option<&NSDictionary<NSString, NSNumber>>,
        ) -> Result<Retained<GLKTextureInfo>, Retained<NSError>>;

        #[cfg(feature = "objc2-core-graphics")]
        #[unsafe(method(textureWithCGImage:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureWithCGImage_options_error(
            cg_image: &CGImage,
            options: Option<&NSDictionary<NSString, NSNumber>>,
        ) -> Result<Retained<GLKTextureInfo>, Retained<NSError>>;

        /// # Safety
        ///
        /// `paths` generic should be of the correct type.
        #[unsafe(method(cubeMapWithContentsOfFiles:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn cubeMapWithContentsOfFiles_options_error(
            paths: &NSArray<AnyObject>,
            options: Option<&NSDictionary<NSString, NSNumber>>,
        ) -> Result<Retained<GLKTextureInfo>, Retained<NSError>>;

        #[unsafe(method(cubeMapWithContentsOfFile:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn cubeMapWithContentsOfFile_options_error(
            path: &NSString,
            options: Option<&NSDictionary<NSString, NSNumber>>,
        ) -> Result<Retained<GLKTextureInfo>, Retained<NSError>>;

        #[unsafe(method(cubeMapWithContentsOfURL:options:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn cubeMapWithContentsOfURL_options_error(
            url: &NSURL,
            options: Option<&NSDictionary<NSString, NSNumber>>,
        ) -> Result<Retained<GLKTextureInfo>, Retained<NSError>>;

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(initWithShareContext:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithShareContext(
            this: Allocated<Self>,
            context: &NSOpenGLContext,
        ) -> Retained<Self>;

        #[cfg(all(feature = "block2", feature = "dispatch2"))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `block` must be a valid pointer.
        #[unsafe(method(textureWithContentsOfFile:options:queue:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureWithContentsOfFile_options_queue_completionHandler(
            &self,
            path: &NSString,
            options: Option<&NSDictionary<NSString, NSNumber>>,
            queue: Option<&DispatchQueue>,
            block: GLKTextureLoaderCallback,
        );

        #[cfg(all(feature = "block2", feature = "dispatch2"))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `block` must be a valid pointer.
        #[unsafe(method(textureWithContentsOfURL:options:queue:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureWithContentsOfURL_options_queue_completionHandler(
            &self,
            url: &NSURL,
            options: Option<&NSDictionary<NSString, NSNumber>>,
            queue: Option<&DispatchQueue>,
            block: GLKTextureLoaderCallback,
        );

        #[cfg(all(
            feature = "block2",
            feature = "dispatch2",
            feature = "objc2-core-foundation"
        ))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `block` must be a valid pointer.
        #[unsafe(method(textureWithName:scaleFactor:bundle:options:queue:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureWithName_scaleFactor_bundle_options_queue_completionHandler(
            &self,
            name: &NSString,
            scale_factor: CGFloat,
            bundle: Option<&NSBundle>,
            options: Option<&NSDictionary<NSString, NSNumber>>,
            queue: Option<&DispatchQueue>,
            block: GLKTextureLoaderCallback,
        );

        #[cfg(all(feature = "block2", feature = "dispatch2"))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `block` must be a valid pointer.
        #[unsafe(method(textureWithContentsOfData:options:queue:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureWithContentsOfData_options_queue_completionHandler(
            &self,
            data: &NSData,
            options: Option<&NSDictionary<NSString, NSNumber>>,
            queue: Option<&DispatchQueue>,
            block: GLKTextureLoaderCallback,
        );

        #[cfg(all(
            feature = "block2",
            feature = "dispatch2",
            feature = "objc2-core-graphics"
        ))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `block` must be a valid pointer.
        #[unsafe(method(textureWithCGImage:options:queue:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn textureWithCGImage_options_queue_completionHandler(
            &self,
            cg_image: &CGImage,
            options: Option<&NSDictionary<NSString, NSNumber>>,
            queue: Option<&DispatchQueue>,
            block: GLKTextureLoaderCallback,
        );

        #[cfg(all(feature = "block2", feature = "dispatch2"))]
        /// # Safety
        ///
        /// - `paths` generic should be of the correct type.
        /// - `queue` possibly has additional threading requirements.
        /// - `block` must be a valid pointer.
        #[unsafe(method(cubeMapWithContentsOfFiles:options:queue:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cubeMapWithContentsOfFiles_options_queue_completionHandler(
            &self,
            paths: &NSArray<AnyObject>,
            options: Option<&NSDictionary<NSString, NSNumber>>,
            queue: Option<&DispatchQueue>,
            block: GLKTextureLoaderCallback,
        );

        #[cfg(all(feature = "block2", feature = "dispatch2"))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `block` must be a valid pointer.
        #[unsafe(method(cubeMapWithContentsOfFile:options:queue:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cubeMapWithContentsOfFile_options_queue_completionHandler(
            &self,
            path: &NSString,
            options: Option<&NSDictionary<NSString, NSNumber>>,
            queue: Option<&DispatchQueue>,
            block: GLKTextureLoaderCallback,
        );

        #[cfg(all(feature = "block2", feature = "dispatch2"))]
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `block` must be a valid pointer.
        #[unsafe(method(cubeMapWithContentsOfURL:options:queue:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn cubeMapWithContentsOfURL_options_queue_completionHandler(
            &self,
            url: &NSURL,
            options: Option<&NSDictionary<NSString, NSNumber>>,
            queue: Option<&DispatchQueue>,
            block: GLKTextureLoaderCallback,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl GLKTextureLoader {
    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>;
    );
}