Inherits from NSObject
Declared in SPBlendMode.h

Overview

A helper class for working with Sparrow’s blend modes.

A blend mode is always defined by two OpenGL blend factors. A blend factor represents a particular value that is multiplied with the source or destination color in the blending formula. The blending formula is:

 result = source × sourceFactor + destination × destinationFactor

In the formula, the source color is the output color of the pixel shader program. The destination color is the color that currently exists in the color buffer, as set by previous clear and draw operations.

Beware that blending factors produce different output depending on the texture type. Textures may contain ‘premultiplied alpha’ (pma), which means that their RGB values were multiplied with their alpha value. (Typically, Xcode will convert your PNGs to use PMA; other texture types remain unmodified.) For this reason, a blending mode may have different factors depending on the pma value.

Tasks

Class Methods

applyBlendFactorsForBlendMode:premultipliedAlpha:

Makes OpenGL use the blend factors that correspond with a certain blend mode.

+ (void)applyBlendFactorsForBlendMode:(uint)blendMode premultipliedAlpha:(BOOL)pma

Discussion

Makes OpenGL use the blend factors that correspond with a certain blend mode.

Declared In

SPBlendMode.h

decodeBlendMode:premultipliedAlpha:intoSourceFactor:destFactor:

Decodes a blend mode into its source and destination factors.

+ (void)decodeBlendMode:(uint)blendMode premultipliedAlpha:(BOOL)pma intoSourceFactor:(uint *)sFactor destFactor:(uint *)destFactor

Discussion

Decodes a blend mode into its source and destination factors.

Declared In

SPBlendMode.h

describeBlendMode:

Returns a string that describes a blend mode.

+ (NSString *)describeBlendMode:(uint)blendMode

Discussion

Returns a string that describes a blend mode.

Declared In

SPBlendMode.h

encodeBlendModeWithSourceFactor:destFactor:

Encodes a set of blend factors into a single unsigned integer, using the same factors regardless of the premultiplied alpha state active on rendering.

+ (uint)encodeBlendModeWithSourceFactor:(uint)sFactor destFactor:(uint)dFactor

Discussion

Encodes a set of blend factors into a single unsigned integer, using the same factors regardless of the premultiplied alpha state active on rendering.

Declared In

SPBlendMode.h

encodeBlendModeWithSourceFactor:destFactor:sourceFactorPMA:destFactorPMA:

Encodes a set of blend factors into a single unsigned integer, using different factors depending on the premultiplied alpha state active on rendering.

+ (uint)encodeBlendModeWithSourceFactor:(uint)sFactor destFactor:(uint)dFactor sourceFactorPMA:(uint)sFactorPMA destFactorPMA:(uint)dFactorPMA

Discussion

Encodes a set of blend factors into a single unsigned integer, using different factors depending on the premultiplied alpha state active on rendering.

Declared In

SPBlendMode.h