Instance Method

initWithData:topLeftOrigin:name:dimensions:rowStride:channelCount:channelEncoding:isCube:

Initializes a texture object with the specified image data and properties.

Declaration

- (instancetype)initWithData:(NSData *)pixelData topLeftOrigin:(BOOL)topLeftOrigin name:(NSString *)name dimensions:(vector_int2)dimensions rowStride:(NSInteger)rowStride channelCount:(NSUInteger)channelCount channelEncoding:(MDLTextureChannelEncoding)channelEncoding isCube:(BOOL)isCube;

Parameters

pixelData

The texture image data. Pass nil for subclasses of MDLTexture that create their own texture data.

topLeftOrigin

If YES, the image data is organized such that its first pixel represents the top left corner of the image. If NO, the first pixel represents the bottom left corner of the image.

name

A descriptive name for the texture. Use the name property to reference this name after initialization.

dimensions

The texel dimensions (width and height) of the texture image.

rowStride

The number of bytes between the first texel in a row of image data and the first texel in the next row. If zero, the texture does not support direct addressing of texels—this is the case for some compressed texture formats.

channelCount

The number of channels per texel—for example, 1 for a grayscale texture, 3 for an RGB color texture, or 4 for RGBA.

channelEncoding

The data format for each channel value per texel—for example, 8-bit integer or 32-bit floating point. For possible values, see MDLTextureChannelEncoding.

isCube

If YES, the image data represents an arrangement of six square images, each of which is a face for a cube texture. If NO, the texture is a single 2D image.

Return Value

A new texture object.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software