---
title: GLKTextureLoader
framework: glkit
role: symbol
role_heading: Class
path: glkit/glktextureloader
---

# GLKTextureLoader

A utility class that simplifies loading OpenGL or OpenGL ES texture datas from a variety of image file formats.

## Declaration

```swift
class GLKTextureLoader
```

## Overview

Overview The GLKTextureLoader class can load two-dimensional or cubemap textures in most image formats supported by the Image I/O framework. In iOS, it can also load textures compressed in the PVRTC format. It can load the data synchronously or asynchronously. To load textures synchronously, make a context with the desired sharegroup the current context, and then call one or more of the class methods. The returned texture info object includes details about the loaded texture. To load textures asynchronously, your initialization code allocates and initializes a new GLKTextureLoader object using the sharegroup object that should be the destination for new textures. Then, to load a texture, your app calls one of the texture loader’s instance methods, passing in a completion handler block to be called when the texture has been loaded. The following OpenGL properties are set for a newly created, non-mipmapped texture: GL_TEXTURE_MIN_FILTER:GL_LINEAR GL_TEXTURE_MAG_FILTER:GL_LINEAR GL_TEXTURE_WRAP_S:GL_CLAMP_TO_EDGE GL_TEXTURE_WRAP_T:GL_CLAMP_TO_EDGE The following OpenGL properties are set for a newly created, mipmapped texture: GL_TEXTURE_MIN_FILTER:GL_LINEAR_MIPMAP_LINEAR GL_TEXTURE_MAG_FILTER:GL_LINEAR GL_TEXTURE_WRAP_S:GL_CLAMP_TO_EDGE GL_TEXTURE_WRAP_T:GL_CLAMP_TO_EDGE The GLKTextureLoader and GLKTextureInfo classes do not manage the OpenGL texture for you. Once the texture is returned to your app, you are responsible for it. This means that after your app is finished using an OpenGL texture, it must explicitly deallocate it by calling the glDeleteTextures function.

## Topics

### Initialization

- [init(sharegroup:)](glkit/glktextureloader/init(sharegroup:).md)
- [init(share:)](glkit/glktextureloader/init(share:).md)

### Loading Textures from Files

- [texture(withContentsOfFile:options:)](glkit/glktextureloader/texture(withcontentsoffile:options:).md)
- [texture(withContentsOfFile:options:queue:completionHandler:)](glkit/glktextureloader/texture(withcontentsoffile:options:queue:completionhandler:).md)

### Loading a Texture From a URL

- [texture(withContentsOf:options:)](glkit/glktextureloader/texture(withcontentsof:options:)-708ft.md)
- [texture(withContentsOf:options:queue:completionHandler:)](glkit/glktextureloader/texture(withcontentsof:options:queue:completionhandler:)-55187.md)

### Creating Textures from In-Memory Representations

- [texture(withContentsOf:options:)](glkit/glktextureloader/texture(withcontentsof:options:)-2ljxb.md)
- [texture(withContentsOf:options:queue:completionHandler:)](glkit/glktextureloader/texture(withcontentsof:options:queue:completionhandler:)-6n0cf.md)

### Creating Textures from CGImages

- [texture(with:options:)](glkit/glktextureloader/texture(with:options:).md)
- [texture(with:options:queue:completionHandler:)](glkit/glktextureloader/texture(with:options:queue:completionhandler:).md)

### Loading Cube Maps from Files

- [cubeMap(withContentsOfFile:options:)](glkit/glktextureloader/cubemap(withcontentsoffile:options:).md)
- [cubeMap(withContentsOfFile:options:queue:completionHandler:)](glkit/glktextureloader/cubemap(withcontentsoffile:options:queue:completionhandler:).md)
- [cubeMap(withContentsOfFiles:options:)](glkit/glktextureloader/cubemap(withcontentsoffiles:options:).md)
- [cubeMap(withContentsOfFiles:options:queue:completionHandler:)](glkit/glktextureloader/cubemap(withcontentsoffiles:options:queue:completionhandler:).md)

### Loading Cube Maps from URLs

- [cubeMap(withContentsOf:options:)](glkit/glktextureloader/cubemap(withcontentsof:options:).md)
- [cubeMap(withContentsOf:options:queue:completionHandler:)](glkit/glktextureloader/cubemap(withcontentsof:options:queue:completionhandler:).md)

### Constants

- [GLKTextureLoaderCallback](glkit/glktextureloadercallback.md)
- [Texture Loading Options](glkit/texture-loading-options.md)
- [Texture Error Handling](glkit/texture-error-handling.md)
- [GLKTextureLoaderError.Code](glkit/glktextureloadererror-swift.struct/code.md)

### Instance Methods

- [texture(withName:scaleFactor:bundle:options:queue:completionHandler:)](glkit/glktextureloader/texture(withname:scalefactor:bundle:options:queue:completionhandler:).md)

### Type Methods

- [texture(withName:scaleFactor:bundle:options:)](glkit/glktextureloader/texture(withname:scalefactor:bundle:options:).md)

### Initializers

- [init(shareContext:)](glkit/glktextureloader/init(sharecontext:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Texture Loading

- [GLKTextureInfo](glkit/glktextureinfo.md)
