SPRenderSupport Class Reference
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
-
– bindTexture:
Binds a texture if it is not already bound. Pass
nil
to unbind any texture. -
– convertColor:alpha:
Converts color and alpha into the format needed by OpenGL. Premultiplies alpha depending on state.
-
– reset
Resets texture binding and alpha settings.
-
+ convertColor:alpha:premultiplyAlpha:
Converts color and alpha into the format needed by OpenGL, optionally premultiplying alpha values.
-
+ clearWithColor:alpha:
Clears OpenGL’s color buffer.
-
+ transformMatrixForObject:
Transforms OpenGL’s matrix into the local coordinate system of the object.
-
+ setupOrthographicRenderingWithLeft:right:bottom:top:
Sets up OpenGL’s projection matrix for 2D rendering.
-
+ checkForOpenGLError
Checks for an OpenGL error. If there is one, it is logged an the error code is returned.
Properties
-
usingPremultipliedAlpha
Indicates if the bound texture has its alpha channel premultiplied.
property
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
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