Class

MTKTextureLoader

An object that decodes common image formats into Metal textures for use in your app.

Declaration

@interface MTKTextureLoader : NSObject

Overview

The MTKTextureLoader class simplifies the effort required to load your texture data into a Metal app. This class can load images from common file formats such as PNG, JPEG, and TIFF. Images can also be loaded from KTX and PVR files, along with additional loading options. Images are always loaded as MTLTextureType2D types and their pixel format is intrinsically inferred from their data.

Texture data can be loaded synchronously or asynchronously. MTKTextureLoader methods return MTLTexture objects, but the class does not manage the objects for you.

Topics

Creating a Texture Loader

- initWithDevice:

Initializes a new texture loader object.

device

The device object that the texture loader uses to create textures.

Loading Textures from URLs

- newTextureWithContentsOfURL:options:error:

Synchronously loads image data and creates a new Metal texture from a given URL.

- newTextureWithContentsOfURL:options:completionHandler:

Asynchronously loads image data and creates a new Metal texture from a given URL.

- newTexturesWithContentsOfURLs:options:error:

Synchronously loads image data and creates new Metal textures from the specified list of URLs.

- newTexturesWithContentsOfURLs:options:completionHandler:

Asynchronously loads image data and creates new Metal textures from the specified list of URLs.

Loading Textures from Asset Catalogs

- newTextureWithName:scaleFactor:bundle:options:error:

Synchronously loads image data and creates a Metal texture from the named texture asset in an asset catalog.

- newTextureWithName:scaleFactor:bundle:options:completionHandler:

Asynchronously loads image data and creates a Metal texture from the named texture asset in an asset catalog.

- newTexturesWithNames:scaleFactor:bundle:options:completionHandler:

Asynchronously loads image data and creates Metal textures from the specified list of named texture assets in an asset catalog.

- newTextureWithName:scaleFactor:displayGamut:bundle:options:error:

Synchronously loads image data and creates a Metal texture from the named texture asset in an asset catalog, using a specified display gamut.

- newTextureWithName:scaleFactor:displayGamut:bundle:options:completionHandler:

Asynchronously loads image data and creates a Metal texture from the named texture asset in an asset catalog.

- newTexturesWithNames:scaleFactor:displayGamut:bundle:options:completionHandler:

Asynchronously loads image data and creates Metal textures from the specified list of named texture assets in an asset catalog.

Loading Textures from Core Graphics Images

- newTextureWithCGImage:options:error:

Synchronously loads image data and creates a new Metal texture from a given bitmap image.

- newTextureWithCGImage:options:completionHandler:

Asynchronously loads image data and creates a new Metal texture from a given bitmap image.

Loading Textures from In-Memory Data Representations

- newTextureWithData:options:error:

Synchronously creates a new Metal texture from an in-memory representation of the texture's data.

- newTextureWithData:options:completionHandler:

Asynchronously creates a new Metal texture from an in-memory representation of the texture's data.

Loading Textures from Model I/O Representations

- newTextureWithMDLTexture:options:error:

Synchronously loads image data and creates a Metal texture from the specified Model I/O texture.

- newTextureWithMDLTexture:options:completionHandler:

Asynchronously loads image data and creates a Metal texture from the specified Model I/O texture.

Specifying Loading Options

MTKTextureLoaderOption

Keys and values used to specify loading options.

Completing a Texture Loading Operation

MTKTextureLoaderArrayCallback

The signature for the block executed after an asynchronous loading operation for multiple textures has completed.

MTKTextureLoaderCallback

The signature for the block executed after an asynchronous loading operation for a single texture has completed.

Handling Errors

MTKTextureLoaderError

Errors returned by the texture loader.

Relationships

Inherits From