美文网首页
OpenGL ES(GLKTextureLoader)

OpenGL ES(GLKTextureLoader)

作者: 忆痕无殇 | 来源:发表于2019-06-03 17:57 被阅读0次

GLKit 框架的设计目标是为了简化基于OpenGL/OpenGL ES的应用开发。
https://developer.apple.com/documentation/glkit/glkview苹果官方文档介绍

功能:

1:加载纹理
2:提供高性能的数学运算
3:提供常见的着色器
4:提供视图以及视图控制器

一:纹理加载

1:初始化一个新的纹理加载到对象中

GLKTextureLoader
/*
 Internally creates a new shared context that will handle the texture creation operations.
 The sharegroup will be released upon releasing the GLKTextureLoader object.
 */
#if TARGET_OS_IPHONE
- (instancetype)initWithSharegroup:(EAGLSharegroup *)sharegroup;
#else
- (instancetype)initWithShareContext:(NSOpenGLContext *)context;
#endif

2:从文件中记载处理

/*
 Asynchronously load an image from disk into an OpenGL texture.
 Invokes the block on the provided queue when the operation is complete. If queue is NULL, the main queue will be used.
 */
- (void)textureWithContentsOfFile:(NSString *)path                                       /* File path of image. */
                          options:(nullable NSDictionary<NSString*, NSNumber*> *)options /* Options that control how the image is loaded. */
                            queue:(nullable dispatch_queue_t)queue                       /* Dispatch queue, or NULL to use the main queue. */
                completionHandler:(GLKTextureLoaderCallback)block;                       /* Block to be invoked on the above dispatch queue. */

//-textureWithContentsOfFile从文件中异步记载2D纹理图像,并根据数据创建新纹理。

/*
 Synchronously load an image from disk into an OpenGL texture.
 Returns the generated texture object when the operation is complete, or the operation terminates with an error (returning nil).
 Returned error can be queried via 'error', which is nil otherwise.
 */
+ (nullable GLKTextureInfo *)textureWithContentsOfFile:(NSString *)path                                       /* File path of image. */
                                               options:(nullable NSDictionary<NSString*, NSNumber*> *)options /* Options that control how the image is loaded. */
                                                 error:(NSError * __nullable * __nullable)outError;           /* Error description. */

//+ textureWithContentsOfFile 从文件加载2D纹理图像并从数据中创建新的纹理。

3:从URL加载纹理

- (void)textureWithContentsOfURL:(NSURL *)url                                           /* File path of image. */
                         options:(nullable NSDictionary<NSString*, NSNumber*> *)options /* Options that control how the image is loaded. */
                           queue:(nullable dispatch_queue_t)queue                       /* Dispatch queue, or NULL to use the main queue. */
               completionHandler:(GLKTextureLoaderCallback)block;                       /* Block to be invoked on the above dispatch queue. */

//从URL异步加载2D纹理图像,并根据数据创建新的纹理。

+ (nullable GLKTextureInfo *)textureWithContentsOfURL:(NSURL *)url                                           /* The URL from which to read. */
                                              options:(nullable NSDictionary<NSString*, NSNumber*> *)options /* Options that control how the image is loaded. */
                                                error:(NSError * __nullable * __nullable)outError;           /* Error description. */

//从URL记载2D纹理图像并从数据创建新的纹理。

3:从内存空间创建纹理

/*
 Asynchronously create a texture from data residing in memory.
 Invokes the block on the provided queue when the operation is complete. If queue is NULL, the main queue will be used.
 */
- (void)textureWithContentsOfData:(NSData *)data                                         /* NSData containing image contents. */
                          options:(nullable NSDictionary<NSString*, NSNumber*> *)options /* Options that control how the image is loaded. */
                            queue:(nullable dispatch_queue_t)queue                       /* Dispatch queue, or NULL to use the main queue. */
                completionHandler:(GLKTextureLoaderCallback)block;                       /* Block to be invoked on the above dispatch queue. */

//从内存空间中异步记载2D纹理图像,并从数据中创建新纹理。

/*
 Synchronously create a texture from data residing in memory.
 Returns the generated texture object when the operation is complete, or the operation terminates with an error (returning nil).
 Returned error can be queried via 'error', which is nil otherwise.
 */
+ (nullable GLKTextureInfo *)textureWithContentsOfData:(NSData *)data                                         /* NSData containing image contents. */
                                               options:(nullable NSDictionary<NSString*, NSNumber*> *)options /* Options that control how the image is loaded. */
                                                 error:(NSError * __nullable * __nullable)outError;           /* Error description. */

//从内存空间加载2D纹理图像,并根据数据创建新的纹理。

4:从CGImages创建纹理

/*
 Asynchronously create a texture from a CGImageRef.
 Invokes the block on the provided queue when the operation is complete. If queue is NULL, the main queue will be used.
 */
- (void)textureWithCGImage:(CGImageRef)cgImage                                    /* CGImage reference. */
                   options:(nullable NSDictionary<NSString*, NSNumber*> *)options /* Options that control how the image is loaded. */
                     queue:(nullable dispatch_queue_t)queue                       /* Dispatch queue, or NULL to use the main queue. */
         completionHandler:(GLKTextureLoaderCallback)block;                       /* Block to be invoked on the above dispatch queue. */

//从Quertz图像异步加载2D纹理图像,并根据数据创建新的纹理。

/*
 Synchronously create a texture from a CGImageRef.
 Returns the generated texture object when the operation is complete, or the operation terminates with an error (returning nil).
 Returned error can be queried via 'error', which is nil otherwise.
 */
+ (nullable GLKTextureInfo *)textureWithCGImage:(CGImageRef)cgImage                                    /* CGImage reference. */
                                        options:(nullable NSDictionary<NSString*, NSNumber*> *)options /* Options that control how the image is loaded. */
                                          error:(NSError * __nullable * __nullable)outError;           /* Error description. */

//从Quartz图像加载2D纹理图像并从数据创建新的纹理。

*5:从URL加载多维数据创建纹理

+ cabeMapWithContentsOfURL:options:errer: 从单个URL加载⽴立⽅方体贴图纹理理
图像,并根据数据创建新纹理理
- cabeMapWithContentsOfURL:options:queue:completionHandler:从单个
URL异步加载⽴立⽅方体贴图纹理理图像,并根据数据创建新纹理理

注:这个老师ppt里面有实际没有搜索到呢*
6:从文件加载多维数据创建纹理

/*
 Asynchronously load six images from disk into an OpenGL cubemap texture.
 Face ordering will always be interpreted as Right(+x), Left(-x), Top(+y), Bottom(-y), Front(+z), Back(-z).
 This coordinate system is left-handed if you think of yourself within the cube. The coordinate system is right-handed if you think of yourself outside of the cube.
 Invokes the block on the provided queue when the operation is complete. If queue is NULL, the main queue will be used.
 */
- (void)cubeMapWithContentsOfFiles:(NSArray<id> *)paths                                   /* An array of paths (NSStrings or NSURLs). */
                           options:(nullable NSDictionary<NSString*, NSNumber*> *)options /* Options that control how the image is loaded. */
                             queue:(nullable dispatch_queue_t)queue                       /* Dispatch queue, or NULL to use the main queue. */
                 completionHandler:(GLKTextureLoaderCallback)block;                       /* Block to be invoked on the above dispatch queue. */

//从单个文件异步加载立体贴图纹理对象,并从数据中创建新的纹理

/*
 Asynchronously creates an OpenGL cubemap texture by splitting one image into six parts.
 Takes a single image file where height = 6 * width or width = 6 * height.
 The former (vertical orientation) is preferred to avoid image data extraction overhead.
 Face ordering will always be interpreted as Right(+x), Left(-x), Top(+y), Bottom(-y), Front(+z), Back(-z).
 This coordinate system is left-handed if you think of yourself within the cube. The coordinate system is right-handed if you think of yourself outside of the cube.
 Invokes the block on the provided queue when the operation is complete. If queue is NULL, the main queue will be used.
 */
- (void)cubeMapWithContentsOfFile:(NSString *)path                                       /* File path of image. */
                          options:(nullable NSDictionary<NSString*, NSNumber*> *)options /* Options that control how the image is loaded. */
                            queue:(nullable dispatch_queue_t)queue                       /* Dispatch queue, or NULL to use the main queue. */
                completionHandler:(GLKTextureLoaderCallback)block;                       /* Block to be invoked on the above dispatch queue. */

//从单个文件加载立方体贴图纹理对象,并从数据中创建新纹理。

+ cubeMapWithContentsOfFiles:options:errer:

//从一系列文件中记载立方体贴图纹理图像,并从数据中创建新的纹理

- cubeMapWithContentsOfFiles:options:options:queue:completionHandler:

//从一系列文件异步加载立方体贴图纹理图像,并从数据中创建新的纹理。

相关文章

网友评论

      本文标题:OpenGL ES(GLKTextureLoader)

      本文链接:https://www.haomeiwen.com/subject/quxhxctx.html