Contents

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.

  • options:

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

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 the table below. CGImages loaded from files typically are already in one of these formats.

Color Space

Pixel format and bitmap information constant

Null

8 bpp, 8 bpc, Alphaonly

Gray

8 bpp, 8 bpc, None

Gray

8 bpp, 8 bpc, Alphaonly

RGB

32 bpp, 8 bpc, Noneskipfirst

RGB

32 bpp, 8 bpc, Premultipliedfirst

See Also

Creating Textures from CGImages