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 an object conforming to the MTLTexture protocol, but the class does not manage this object for you.

Topics

Creating a Texture Loader

initWithDevice:

Initializes a new texture loader object.

device

The device used to create Metal objects.

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.

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 CoreGraphics 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 loads image data and creates a new Metal texture from given file data.

newTextureWithData:options:completionHandler:

Asynchronously loads image data and creates a new Metal texture from given file 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.

Constants

Loading Options

Optional settings that specify additional characteristics of a texture.

Loading Errors

Potential errors that may be thrown by texture loading methods.

Completion Blocks

Convenience type alias declarations for the completion blocks of texture loading methods.

Relationships

Inherits From