vvopensource
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
Instance Methods | Class Methods
VVBufferPool Class Reference

Creates VVBuffers. Should be the only way you create VVBuffers- most projects will only have a single instance of VVBufferPool, which shares an OpenGL context with other parts of your program so GL resources (specifically textures) may be shared. More...

#import <VVBufferPool.h>

Inherits GLScene.

Instance Methods

(void) - housekeeping
 You have to call this method periodically (once per global render pass is fine, ideally at the end of the pass). Calling this method frees up buffers if they've been sitting unused for a while.
 
(VVBuffer *) - allocFBO
 Allocates and returns a VVBuffer instance that represents an OpenGL framebuffer. Framebuffers have textures or renderbuffers associated with them as color (image) or depth attachments.
 
(VVBuffer *) - allocBGRTexSized:
 Allocates and returns a VVBuffer instance that represents an OpenGL texture. Specifically, returns an 8-bit per channel RECT texture with a BGRA internal format.
 
(VVBuffer *) - allocBGR2DPOTTexSized:
 Allocates and returns a VVBuffer instance that represents an OpenGL texture. Specifically, returns an 8-bit per channel 2D texture with power-of-two dimensions and a BGRA internal format. More...
 
(VVBuffer *) - allocBGRFloatTexSized:
 Allocates and returns a VVBuffer instance that represents an OpenGL texture. Specifically, returns a 32-bit-float-per-channel RECT texture with a BGRA internal format. More...
 
(VVBuffer *) - allocBGRFloat2DPOTTexSized:
 Allocates and returns a VVBuffer instance that represents an OpenGL texture. Specifically, returns a 32-bit-float-per-channel 2D texture with power-of-two dimensions and a BGRA internal format. More...
 
(VVBuffer *) - allocDepthSized:
 Allocates and returns a VVBuffer instance that represents an OpenGL texture used as a depth attachment. More...
 
(VVBuffer *) - allocMSAAColorSized:numOfSamples:
 Allocates and returns a VVBuffer instance that represents an OpenGL renderbuffer suitable for multisample antialiasing as a color (image) attachment. More...
 
(VVBuffer *) - allocMSAADepthSized:numOfSamples:
 Allocates and returns a VVBuffer instance that represents an OpenGL renderbuffer suitable for multisample antialiasing as a depth attachment. More...
 
(VVBuffer *) - allocBufferForNSImage:prefer2DTexture:
 Allocates and returns a VVBuffer instance that represents an 8-bit per channel OpenGL texture. The texture is automaticall populated with the contents of the passed image. More...
 
(VVBuffer *) - allocBufferForBitmapRep:prefer2DTexture:
 Allocates and returns a VVBuffer instance that represents an 8-bit per channel OpenGL texture. The texture is automaticall populated with the contents of the passed NSBitmapImageRep. More...
 
(VVBuffer *) - allocBufferForCVGLTex:
 Allocates and returns a VVBuffer instance that represents the GL texture used by the passed CVOpenGLTextureRef. The VVBuffer actually retains the CV texture, so the underlying CV resource is retained until all VVBuffers referencing it are freed. More...
 
(VVBuffer *) - allocTexRangeForHapCVImageBuffer:
 Special method for working with Hap movie files- uploads the passed image buffer (only accepts hap image buffers) to a GL texture. HapQ movies will still need to be converted from YCoCg to RGBA! More...
 
(VVBuffer *) - allocBufferForTexBackedIOSurfaceSized:
 Allocates and returns a VVBuffer instance backed by an IOSurfaceRef. If you want to pass a texture to another process via an IOSurface, create one of these and then render to it. More...
 
(VVBuffer *) - allocBufferForIOSurfaceID:
 Allocates and returns a VVBuffer instance created from an existing IOSurfaceRef. If you want to receive textures from another process, get the IOSurfaceID from the remote process and then pass it to this method to create the VVBuffer. More...
 
- Instance Methods inherited from GLScene
(id) - initWithSharedContext:
 Init an instance of GLScene using the passed shared context.
 
(id) - initWithSharedContext:sized:
 Init an instance of GLScene using the passed shared context. The GLScene will automatically be configured to render at the passed size.
 
(id) - initWithSharedContext:pixelFormat:
 Init an instance of GLScene using the passed shared context and pixel format.
 
(id) - initWithSharedContext:pixelFormat:sized:
 Init an instance of GLScene using the passed shared context and pixel format. The GLScene will automatically be configured to render at the passed size.
 
(VVBuffer *) - allocAndRenderABuffer
 Allocate a VVBuffer of the appropriate size, renders into this buffer, and then return it. Probably the "main" rendering method.
 
(void) - renderInMSAAFBO:colorRB:depthRB:fbo:colorTex:depthTex:target:
 This is the low-level rendering method- if you want to fool around with MSAA or build a leaner interface, you'll probably want to use this. More...
 
(void) - setClearNSColor:
 Set the clear color from the passed NSColor.
 
(void) - setClearColor:
 Set the clear color from the passed array of GLfloats.
 
(void) - setClearColors::::
 Set the clear color from the passed color values.
 

Class Methods

(int) + msaaMaxSamples
 
(void) + createGlobalVVBufferPoolWithSharedContext:
 Call this method and pass the GL context you wish to share to create the global (singleton) VVBufferPool. Other classes in this framework will automatically try to configure themselves to work with the global pool or its shared context if they exist- a lot of stuff will be easier to use and require less configuration if setting up the global buffer pool is the first thing you do. More...
 
(id) + globalVVBufferPool
 Returns the global buffer pool (singleton). The buffer pool itself should be threadsafe (you can use it from multiple threads at the same time and the pool will handle the details).
 
(void) + timestampThisBuffer:
 Call this method and pass a VVBuffer instance to it to give the passed VVBuffer instance a timestamp. More...
 
- Class Methods inherited from GLScene
(NSMutableArray *) + gpuVendorArray
 Returns an array of the GPUs currently accessible by the renderer accessible being used with this process.
 
(BOOL) + integratedGPUFlag
 Returns a YES if you're using an integrated GPU.
 
(BOOL) + nvidiaGPUFlag
 Returns a YES if you're using an NVIDIA GPU.
 
(GLuint) + glDisplayMaskForAllScreens
 Returns a GL display mask that encompassess all your screens.
 
(NSOpenGLPixelFormat *) + defaultPixelFormat
 Returns a default NSOpenGLPixelFormat instance. If you don't explicitly set a pixel format when creating your instances of GLScene (and its subclasses), this is the pixel format that will be used.
 

Additional Inherited Members

- Properties inherited from GLScene
NSSize size
 Set the size at which this scene should render.
 
id renderTarget
 Every time this scene renders, the "renderSelector" is called on "renderTarget".
 
SEL renderSelector
 Every time this scene renders, the "renderSelector" is called on "renderTarget". You put your drawing code in the "renderSelector".
 

Detailed Description

Creates VVBuffers. Should be the only way you create VVBuffers- most projects will only have a single instance of VVBufferPool, which shares an OpenGL context with other parts of your program so GL resources (specifically textures) may be shared.

The goal of the buffer pool is two-fold: firstly, to simplify the process of creating and working with GL-based resources by treating them as "buffer objects". secondly, to minimize the impact of creating and dealing with gl-based resources; when a VVBuffer is released, it goes back into the pool for a specified period of time. during this time, anything that asks the pool for a matching buffer will be given the pre-existing asset (instead of forcing the creation of a new asset). if nothing requires the resource, it will eventually be freed (again, VVBufferPool is a subclass of GLScene- it has a context, and may free gl resources).

VVBufferPool is a subclass of GLScene. this is important: the buffer pool is essentially its own GL context- the idea is to have a single buffer pool which is capable of creating resources which may be shared among contexts which are being rendered on other threads.

the buffer pool creates VVBuffers; each buffer retains the buffer pool which created it to ensure that the pool sticks around until it has freed every resource it creates. this should be mostly unnecessary- you'll probably only ever need the one global instance of VVBufferPool.

Method Documentation

- (VVBuffer *) allocBGR2DPOTTexSized: (NSSize)  s

Allocates and returns a VVBuffer instance that represents an OpenGL texture. Specifically, returns an 8-bit per channel 2D texture with power-of-two dimensions and a BGRA internal format.

Parameters
sThe size of the texture you want to create, in pixels, as an NSSize structure
sThe size of the texture you want to create, in pixels, as an NSSize structure. Note that the actual texture may be larger (as per the function name, the texture will be power-of-two with equal width and height).
- (VVBuffer *) allocBGRFloat2DPOTTexSized: (NSSize)  s

Allocates and returns a VVBuffer instance that represents an OpenGL texture. Specifically, returns a 32-bit-float-per-channel 2D texture with power-of-two dimensions and a BGRA internal format.

Parameters
sThe size of the texture you want to create, in pixels, as an NSSize structure
- (VVBuffer *) allocBGRFloatTexSized: (NSSize)  s

Allocates and returns a VVBuffer instance that represents an OpenGL texture. Specifically, returns a 32-bit-float-per-channel RECT texture with a BGRA internal format.

Parameters
sThe size of the texture you want to create, in pixels, as an NSSize structure
- (VVBuffer *) allocBufferForBitmapRep: (NSBitmapImageRep *)  rep
prefer2DTexture: (BOOL)  prefer2D 

Allocates and returns a VVBuffer instance that represents an 8-bit per channel OpenGL texture. The texture is automaticall populated with the contents of the passed NSBitmapImageRep.

Parameters
repthe NSBitmapImageRep instance you want to turn into a GL texture
prefer2Dif YES, the buffer pool will try to generate a 2D texture (instead of a RECT texture)
- (VVBuffer *) allocBufferForCVGLTex: (CVOpenGLTextureRef)  cvt

Allocates and returns a VVBuffer instance that represents the GL texture used by the passed CVOpenGLTextureRef. The VVBuffer actually retains the CV texture, so the underlying CV resource is retained until all VVBuffers referencing it are freed.

Parameters
cvtthe CVOpenGLTextureRef you want to create the VVBuffer from. the VVBuffer will just be a "wrapper"- it will retain the passed CVOpenGLTextureRef, this is close to a zero-cost operation
- (VVBuffer *) allocBufferForIOSurfaceID: (IOSurfaceID)  n

Allocates and returns a VVBuffer instance created from an existing IOSurfaceRef. If you want to receive textures from another process, get the IOSurfaceID from the remote process and then pass it to this method to create the VVBuffer.

Parameters
nthe IOSurfaceID you want to create a texture from
- (VVBuffer *) allocBufferForNSImage: (NSImage *)  img
prefer2DTexture: (BOOL)  prefer2D 

Allocates and returns a VVBuffer instance that represents an 8-bit per channel OpenGL texture. The texture is automaticall populated with the contents of the passed image.

Parameters
imgthe NSImage instance you want to turn into a GL texture
prefer2Dif YES, the buffer pool will try to generate a 2D texture (instead of a RECT texture)
- (VVBuffer *) allocBufferForTexBackedIOSurfaceSized: (NSSize)  s

Allocates and returns a VVBuffer instance backed by an IOSurfaceRef. If you want to pass a texture to another process via an IOSurface, create one of these and then render to it.

Parameters
sThe size of the texture/IOSUrface you want to create, in pixels, as an NSSize structure
- (VVBuffer *) allocDepthSized: (NSSize)  s

Allocates and returns a VVBuffer instance that represents an OpenGL texture used as a depth attachment.

Parameters
sThe size of the texture you want to create, in pixels, as an NSSize structure
- (VVBuffer *) allocMSAAColorSized: (NSSize)  s
numOfSamples: (int)  n 

Allocates and returns a VVBuffer instance that represents an OpenGL renderbuffer suitable for multisample antialiasing as a color (image) attachment.

Parameters
sThe size of the renderbuffer you want to create, in pixels, as an NSSize structure
- (VVBuffer *) allocMSAADepthSized: (NSSize)  s
numOfSamples: (int)  n 

Allocates and returns a VVBuffer instance that represents an OpenGL renderbuffer suitable for multisample antialiasing as a depth attachment.

Parameters
sThe size of the renderbuffer you want to create, in pixels, as an NSSize structure
- (VVBuffer *) allocTexRangeForHapCVImageBuffer: (CVImageBufferRef)  img

Special method for working with Hap movie files- uploads the passed image buffer (only accepts hap image buffers) to a GL texture. HapQ movies will still need to be converted from YCoCg to RGBA!

Parameters
imgthe CVImageBufferRef you want to create the VVBuffer from. Note that this will only work with Hap-format image buffers! If you're working with a HapQ movie, this buffer will need to be converted from YCoCg to RGBA, as demonstrated in the test app
+ (void) createGlobalVVBufferPoolWithSharedContext: (NSOpenGLContext *)  n

Call this method and pass the GL context you wish to share to create the global (singleton) VVBufferPool. Other classes in this framework will automatically try to configure themselves to work with the global pool or its shared context if they exist- a lot of stuff will be easier to use and require less configuration if setting up the global buffer pool is the first thing you do.

Parameters
nThe NSOpenGLContext you want the buffer pool to share. This context should not be freed as long as VVBufferPool exists!
+ (int) msaaMaxSamples

Returns the max number of MSAA samples that can be taken with the GL renderer currently in use by your application

+ (void) timestampThisBuffer: (id)  n

Call this method and pass a VVBuffer instance to it to give the passed VVBuffer instance a timestamp.

Parameters
nThe VVBuffer instance you want to timestamp

The documentation for this class was generated from the following files: