vvopensource
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
SampleVVBufferPoolAdditions.h
1 /* this is sample code demonstrating how to use the VVBufferPool framework to "wrap"
2 graphic/image resources generated by other APIs. in these examples (Syphon and VVFFGL), this is
3 very nearly a zero-cost operation: VVBuffer is basically just retaining the underlying graphic
4 resource, and is merely populated with its properties. */
5 #import <Cocoa/Cocoa.h>
6 #import <VVBufferPool/VVBufferPool.h>
7 #import <Syphon/Syphon.h>
8 #ifndef __LP64__
9 #import <VVFFGL/VVFFGL.h>
10 #endif
11 
12 
13 
14 
15 /* the 'VVBufferBackID' typedef is used purely for identification of the source of a VVBuffer (as
16 buffers are frequently wrappers for resources created by or underlying other graphics APIs). these
17 values are purely referential- they aren't functional at all, and are mainly used so you can
18 avoid ping-ponging between graphics formats. since these are purely a reference, you can define
19 your own values- just start at 100 or whatever, and make sure that these values are unique within
20 all the code you're compiling. */
21 #define VVBufferBackID_Syphon 100
22 #define VVBufferBackID_VVFFGL 101
23 
24 
25 
26 
27 /* these are class additions to VVBuffer- we're adding methods to VVBufferPool to create VVBuffer
28 instances from syphon resources, here are some methods to retrieve the underlying syphon resources
29 from VVBuffers (where appropriate */
30 @interface VVBuffer (VVBufferAdditions)
31 
32 - (SyphonImage *) syphonImage;
33 #ifndef __LP64__ // FFGL is a 32-bit API/VVFFGL is a 32-bit-only framework
34 - (FFGLImage *) ffglImage;
35 #endif
36 
37 @end
38 
39 
40 
41 
42 /* these are callbacks we're defining; they're called when a VVBuffer wrapping a syphon or ffgl
43 resource is freed (the point of the callback is to release the underlying syphon/ffgl resource) */
44 void VVBuffer_ReleaseSyphonImage(id b, void *c);
45 #ifndef __LP64__ // FFGL is a 32-bit API/VVFFGL is a 32-bit-only framework
46 void VVBuffer_ReleaseFFGLImage(id b, void *c);
47 #endif
48 
49 
50 
51 
52 /* these are class additions to VVBufferPool- these are how you create VVBuffer resources from
53 Syphon or VVFFGL resources. going the "other way"- creating syphon/VVFFGL image resources from
54 VVBuffer instances- is beyond the scope of this example, but quite painless since VVBuffer is just a
55 wrapper around GL resources. wrap the VVBuffer with your image format of choice, and when you're
56 done, free the VVBuffer instance- the underlying resources will be pooled or freed by the buffer pool. */
57 @interface VVBufferPool (VVBufferPoolAdditions)
58 
59 - (VVBuffer *) allocBufferForSyphonClient:(SyphonClient *)c;
60 #ifndef __LP64__ // FFGL is a 32-bit API/VVFFGL is a 32-bit-only framework
61 - (VVBuffer *) allocBufferForFFGLImage:(FFGLImage *)i;
62 #endif
63 
64 @end
VVBuffer represents a buffer- almost always in VRAM as a GL texture or renderbuffer- created and mana...
Definition: VVBuffer.h:134