Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/Quartz.framework/Frameworks/QuartzComposer.framework |
Availability | Available in Mac OS X v10.4 and later. |
Declared in | QCRenderer.h |
A QCRenderer
class is designed for low-level rendering of Quartz Composer compositions. This is the class to use if you want to be in charge of rendering a composition to a specific OpenGL context—either using the NSOpenGLContext
class or a CGLContextObj
object. QCRenderer
also allows you to load, play, and control a composition.
To render a composition to a specific OpenGL context:
Create an instance of QCRenderer
using one of the initialization methods, such as initWithOpenGLContext:pixelFormat:file:
.
Render frames by calling the method renderAtTime:arguments:
If you use double buffering in OpenGL, you must swap the OpenGL buffers.
Release the renderer with you no longer need it.
This code snippet shows how to implement these tasks:
NSOpenGLContext* context = [myNSOpenGLView openGLContext]; |
NSOpenGLPixelFormat* format = [myNSOpenGLView pixelFormat]; |
NSString* path = @”/Users/MyName/MyComposition.qtz”; |
QCRenderer* myRenderer; |
// Create a Quartz Composer renderer. |
myRenderer = [[QCRenderer alloc] initWithOpenGLContext:context |
pixelFormat:format |
file:path]; |
// Render the first 10 seconds of the composition with steps of 1/25s. |
for(double t = 0.0; t <= 10.0; t += 1.0/25.0) |
{ |
[myRenderer renderAtTime:t arguments:nil]; |
[context flushBuffer]; //Required on double-buffered contexts |
} |
// Clean up |
[renderer release]; |
– initWithComposition:colorSpace:
– initWithOpenGLContext:pixelFormat:file:
– initWithCGLContext:pixelFormat:colorSpace:composition:
– initOffScreenWithSize:colorSpace:composition:
Returns the composition object associated with the renderer.
- (QCComposition*) composition
The composition object.
QCRenderer.h
Returns the current image in the OpenGL context associated with the renderer, as an image object of the provided image type.
- (id) createSnapshotImageOfType:(NSString*)type
A string that specifies any of the following image types: NSBitmapImageRep
, NSImage
, CIImage
, CGImage
, CVOpenGLBuffer
, CVPixelBuffer
.
The snapshot image in the provided image type. You are responsible for releasing this object when you no longer need it.
QCRenderer.h
Creates an offscreen renderer of a given size with the provided color space and composition object.
- (id) initOffScreenWithSize:(NSSize)size colorSpace:(CGColorSpaceRef)colorSpace composition:(QCComposition*)composition
The size of the offscreen renderer.
A Quartz color space object. This must be an RGB color space. Pass NULL
to use the default RGB color space. For more information on Quartz color spaces, see Quartz 2D Programming Guide.
A QCComposition
object.
The initialized QCRenderer
object or nil
if initialization is not successful.
This method creates an internal OpenGL context and pixel buffer. Because offscreen rendering is performed on the GPU, the maximum rendering size is limited to the GPU capacity. On typical hardware, the limit is at least 2048 by 2048, but is often 4096 by 4096. The available VRAM affects performance.
QCRenderer.h
Creates a renderer object with a CGLContextObj
object, a pixel format, a color space, and a composition object.
- (id) initWithCGLContext:(CGLContextObj)context pixelFormat:(CGLPixelFormatObj)format colorSpace:(CGColorSpaceRef)colorSpace composition:(QCComposition*)composition;
A CGLContextObj
object. The object that you supply must have both a color and a depth buffer.
A CGLPixelFormatObj
object.
A Quartz color space object. This must be an RGB color space. Pass NULL
to use the default RGB color space. For more information on Quartz color spaces, see Quartz 2D Programming Guide.
A QCComposition
object.
The initialized QCRenderer
object or nil
if initialization is not successful.
QCRenderer.h
Creates a renderer object with a composition object and a color space.
- (id) initWithComposition:(QCComposition*)composition colorSpace:(CGColorSpaceRef)colorSpace;
A QCComposition
object. The composition must not contain any consumer patches. That is, the composition can receive data, process it, and produce output values, but it cannot perform any rendering.
A Quartz color space object. This must be an RGB color space. Pass NULL
to use the default RGB color space. The color space is used only for the images produced by the output image ports of the composition. For more information on Quartz color spaces, see Quartz 2D Programming Guide.
The initialized QCRenderer
object or nil
if initialization is not successful.
Note that snapshotImage
and createSnapshotImageOfType:
always returns nil
on such QCRenderer
instances.
QCRenderer.h
Creates a renderer object with an NSOpenGLContext
object and a composition file.
- (id)initWithOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)format file:(NSString *)path
An NSOpenGLContext
object. The object that you supply must have both a color and a depth buffer.
An NSOpenGLPixelFormat
object.
A string that specifies the location of a composition(.qtz
) file.
An initialized QCRenderer
object or nil
if initialization is not successful.
QCRenderer.h
Renders a frame of a composition at the specified time.
- (BOOL)renderAtTime:(NSTimeInterval)time arguments:(NSDictionary *)arguments
The time, in seconds, at which to render a composition frame. The time must be a positive value or zero.
An optional dictionary that can have any of the entries defined in “Rendering Arguments”
.
YES
if successful.
You need to call this method each time you want to render a frame of the composition.
All OpenGL states are preserved except the following:
States defined by GL_CURRENT_BIT
Textures on each unit and the environment mode
Matrix mode
If you are using double buffers, keep in mind that the renderAtTime:arguments:
method does not swap the front and back buffers of the OpenGL context. You must perform the swap yourself by calling the OpenGL command flushBuffer
on the context associated with the renderer.
If you are interleaving OpenGL code with rendering of a composition, make sure that the OpenGL context is current. If you are using the NSOpenGLContext
class, call the makeCurrentContext
method prior to rendering. If you are using the CGL API, call the function CGLSetCurrentContext
.
QCRenderer.h
Returns an NSImage
object of the current image in the OpenGL context associated with the renderer.
- (NSImage*) snapshotImage
The snapshot image.
QCRenderer.h
Arguments that you can pass to the renderAtTime:arguments:
method.
extern NSString* const QCRendererEventKey; extern NSString* const QCRendererMouseLocationKey;
QCRendererEventKey
A key for a renderer event. The associated value is an NSEvent
object.
Available in Mac OS X v10.4 and later.
Declared in QCRenderer.h
.
QCRendererMouseLocationKey
A key for the mouse location. The associated value is an NSPoint
object stored in an NSValue
object. The mouse location is in normalized coordinates relative to the OpenGL context viewport ([0,1]x[0,1]
with the origin (0,0)
at the lower-left corner).
Available in Mac OS X v10.4 and later.
Declared in QCRenderer.h
.
QCRenderer.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-05-09)