Inherits from NSObject
Declared in SPRenderSupport.h

Overview

A class that contains helper methods simplifying OpenGL rendering.

An SPRenderSupport instance is passed to any render: method. It saves information about the currently bound texture, which allows it to avoid unecessary texture switches.

Furthermore, several static helper methods can be used for different needs whenever some OpenGL processing is required.

Tasks

Methods

Properties

Properties

usingPremultipliedAlpha

Indicates if the bound texture has its alpha channel premultiplied.

@property (nonatomic, readonly) BOOL usingPremultipliedAlpha

Discussion

Indicates if the bound texture has its alpha channel premultiplied.

Declared In

SPRenderSupport.h

Class Methods

checkForOpenGLError

Checks for an OpenGL error. If there is one, it is logged an the error code is returned.

+ (uint)checkForOpenGLError

Discussion

Checks for an OpenGL error. If there is one, it is logged an the error code is returned.

Declared In

SPRenderSupport.h

clearWithColor:alpha:

Clears OpenGL’s color buffer.

+ (void)clearWithColor:(uint)color alpha:(float)alpha

Discussion

Clears OpenGL’s color buffer.

Declared In

SPRenderSupport.h

convertColor:alpha:premultiplyAlpha:

Converts color and alpha into the format needed by OpenGL, optionally premultiplying alpha values.

+ (uint)convertColor:(uint)color alpha:(float)alpha premultiplyAlpha:(BOOL)pma

Discussion

Converts color and alpha into the format needed by OpenGL, optionally premultiplying alpha values.

Declared In

SPRenderSupport.h

setupOrthographicRenderingWithLeft:right:bottom:top:

Sets up OpenGL’s projection matrix for 2D rendering.

+ (void)setupOrthographicRenderingWithLeft:(float)left right:(float)right bottom:(float)bottom top:(float)top

Discussion

Sets up OpenGL’s projection matrix for 2D rendering.

Declared In

SPRenderSupport.h

transformMatrixForObject:

Transforms OpenGL’s matrix into the local coordinate system of the object.

+ (void)transformMatrixForObject:(SPDisplayObject *)object

Discussion

Transforms OpenGL’s matrix into the local coordinate system of the object.

Declared In

SPRenderSupport.h

Instance Methods

bindTexture:

Binds a texture if it is not already bound. Pass nil to unbind any texture.

- (void)bindTexture:(SPTexture *)texture

Discussion

Binds a texture if it is not already bound. Pass nil to unbind any texture.

Declared In

SPRenderSupport.h

convertColor:alpha:

Converts color and alpha into the format needed by OpenGL. Premultiplies alpha depending on state.

- (uint)convertColor:(uint)color alpha:(float)alpha

Discussion

Converts color and alpha into the format needed by OpenGL. Premultiplies alpha depending on state.

Declared In

SPRenderSupport.h

reset

Resets texture binding and alpha settings.

- (void)reset

Discussion

Resets texture binding and alpha settings.

Declared In

SPRenderSupport.h