Type Method

texture(with:options:)

Loads a 2D texture image from a Quartz image and creates a new texture from the data.

Declaration

class func texture(with cgImage: CGImage, options: [String : NSNumber]? = nil) throws -> GLKTextureInfo

Parameters

cgImage

The Quartz image to be turned into a texture.

textureOperations

A dictionary that describes any additional steps you want the texture loader to take when loading the texture. See Texture Loading Options.

outError

If an error occurs, upon return contains an NSError object that describes the problem.

If you are not interested in this information, pass NULL.

Return Value

A texture info object that describes the loaded texture or nil if an error occurred.

Discussion

This class method loads the texture into the sharegroup attached to the current context for the thread this method is called on.

If the image was created using the CGBitmapImageContextCreate function, it must use one of the pixel formats described in Table 1. CGImages loaded from files typically are already in one of these formats.

Table 1

Supported Bitmap Formats

Color Space

Pixel format and bitmap information constant

Null

8 bpp, 8 bpc, CGImageAlphaInfo.alphaOnly

Gray

8 bpp, 8 bpc,CGImageAlphaInfo.none

Gray

8 bpp, 8 bpc,CGImageAlphaInfo.alphaOnly

RGB

32 bpp, 8 bpc, CGImageAlphaInfo.noneSkipFirst

RGB

32 bpp, 8 bpc, CGImageAlphaInfo.premultipliedFirst

See Also

Creating Textures from CGImages

func texture(with: CGImage, options: [String : NSNumber]?, queue: DispatchQueue?, completionHandler: GLKTextureLoaderCallback)

Asynchronously loads a 2D texture image from a Quartz image and creates a new texture from the data.

Deprecated