SPRenderTexture Class Reference
Inherits from | SPSubTexture : SPTexture : NSObject |
Declared in | SPRenderTexture.h |
Overview
An SPRenderTexture is a dynamic texture on which you can draw any display object.
After creating a render texture, just call the drawObject:
method to render an object directly
onto the texture. The object will be drawn onto the texture at its current position, adhering
its current rotation, scale and alpha properties.
Drawing is done very efficiently, as it is happening directly in graphics memory. After you have drawn objects on the texture, the performance will be just like that of a normal texture - no matter how many objects you have drawn.
If you draw lots of objects at once, it is recommended to bundle the drawing calls in a block
via the drawBundled:
method, like shown below. That will speed it up immensely, allowing
you to draw hundreds of objects very quickly.
[renderTexture drawBundled:^
{
for (int i=0; i<numDrawings; ++i)
{
image.rotation = (2 * PI / numDrawings) * i;
[renderTexture drawObject:image];
}
}];
Tasks
Initialization
-
– initWithWidth:height:
Initializes a transparent render texture with the scale factor of the stage. Width and height are expected as points (not pixels).
-
– initWithWidth:height:fillColor:
Initializes a render texture with a certain ARGB color (0xAARRGGBB). Width and height are expected as points (not pixels).
-
– initWithWidth:height:fillColor:scale:
Initializes a render texture with a certain ARGB color (0xAARRGGBB) and a scale factor. Width and height are expected as points (not pixels).
-
+ textureWithWidth:height:
Factory method.
-
+ textureWithWidth:height:fillColor:
Factory method.
Methods
-
– drawObject:
Draws an object onto the texture, adhering its properties for transformation, alpha and blend mode.
-
– drawObject:withMatrix:
Draws an object onto the texture, using the given matrix for its transformation. Alpha and blend mode are used as set on the object.
-
– drawObject:withMatrix:alpha:
Draws an object onto the texture, using custom values for transformation matrix and alpha. The blend mode is used as set on the object.
-
– drawObject:withMatrix:alpha:blendMode:
Draws an object onto the texture, using custom values for transformation matrix, alpha and blend mode.
-
– drawBundled:
Bundles several calls to
drawObject:
together in a block. This avoids framebuffer switches. -
– clearWithColor:alpha:
Clears the texture with a certain color and alpha value.
-
– clear
Clears the texture with fully transparent pixels.
Class Methods
Instance Methods
clear
Clears the texture with fully transparent pixels.
- (void)clear
Discussion
Clears the texture with fully transparent pixels.
Declared In
SPRenderTexture.h
clearWithColor:alpha:
Clears the texture with a certain color and alpha value.
- (void)clearWithColor:(uint)color alpha:(float)alpha
Discussion
Clears the texture with a certain color and alpha value.
Declared In
SPRenderTexture.h
drawBundled:
Bundles several calls to drawObject:
together in a block. This avoids framebuffer switches.
- (void)drawBundled:(SPDrawingBlock)block
Discussion
Bundles several calls to drawObject:
together in a block. This avoids framebuffer switches.
Declared In
SPRenderTexture.h
drawObject:
Draws an object onto the texture, adhering its properties for transformation, alpha and blend mode.
- (void)drawObject:(SPDisplayObject *)object
Discussion
Draws an object onto the texture, adhering its properties for transformation, alpha and blend mode.
Declared In
SPRenderTexture.h
drawObject:withMatrix:
Draws an object onto the texture, using the given matrix for its transformation. Alpha and blend mode are used as set on the object.
- (void)drawObject:(SPDisplayObject *)object withMatrix:(SPMatrix *)matrix
Discussion
Draws an object onto the texture, using the given matrix for its transformation. Alpha and blend mode are used as set on the object.
Declared In
SPRenderTexture.h
drawObject:withMatrix:alpha:
Draws an object onto the texture, using custom values for transformation matrix and alpha. The blend mode is used as set on the object.
- (void)drawObject:(SPDisplayObject *)object withMatrix:(SPMatrix *)matrix alpha:(float)alpha
Discussion
Draws an object onto the texture, using custom values for transformation matrix and alpha. The blend mode is used as set on the object.
Declared In
SPRenderTexture.h
drawObject:withMatrix:alpha:blendMode:
Draws an object onto the texture, using custom values for transformation matrix, alpha and blend mode.
- (void)drawObject:(SPDisplayObject *)object withMatrix:(SPMatrix *)matrix alpha:(float)alpha blendMode:(uint)blendMode
Discussion
Draws an object onto the texture, using custom values for transformation matrix, alpha and blend mode.
Declared In
SPRenderTexture.h
initWithWidth:height:
Initializes a transparent render texture with the scale factor of the stage. Width and height are expected as points (not pixels).
- (instancetype)initWithWidth:(float)width height:(float)height
Discussion
Initializes a transparent render texture with the scale factor of the stage. Width and height are expected as points (not pixels).
Declared In
SPRenderTexture.h
initWithWidth:height:fillColor:
Initializes a render texture with a certain ARGB color (0xAARRGGBB). Width and height are expected as points (not pixels).
- (instancetype)initWithWidth:(float)width height:(float)height fillColor:(uint)argb
Discussion
Initializes a render texture with a certain ARGB color (0xAARRGGBB). Width and height are expected as points (not pixels).
Declared In
SPRenderTexture.h
initWithWidth:height:fillColor:scale:
Initializes a render texture with a certain ARGB color (0xAARRGGBB) and a scale factor. Width and height are expected as points (not pixels).
- (instancetype)initWithWidth:(float)width height:(float)height fillColor:(uint)argb scale:(float)scale
Discussion
Initializes a render texture with a certain ARGB color (0xAARRGGBB) and a scale factor. Width and height are expected as points (not pixels).
Declared In
SPRenderTexture.h