Skip to content

Commit

Permalink
Added VVBufferPool, VVISFKit, DDMathParser, and JSONKit frameworks. A…
Browse files Browse the repository at this point in the history
…dded test apps demonstrating how to use VVBufferPool and VVISFKit to do a number of common render-to-texture and display tasks.

- the VVBufferPool framework provides a simple API for creating, rendering to, working with/managing, and displaying GL textures and buffers.  Support is included for working with a number of native mac APIs (NSImages, bitmap reps, CIImages, QC compositions, QT movies), and the framework is simple and low-level enough to be used to "wrap" other hardware-accelerated APIs and act as a reasonable common backbone for managing graphic resources and sharing them between APIs.  VDMX is built on these classes.
- the VVISFKit framework is my ISF implementation.  ISF is a simple, minimal image filter format that I made up one day because it was faster and easier than dealing with other similar APIs.  Uses VVBufferPool to create/manage GPU resources for rendering.  More info on ISF- including sample apps and over a hundred filters and generative sources- can be found here: http://vidvox.net/rays_oddsnends/ISF.html
- the JSONKit framework is a venerable bit of code written by John Engelhart (https://github.com/johnezang/JSONKit).  JSONKit is included as a framework in this project to reduce dependencies and make it easier to integrate with projects.  In this project, JSONKit is used by VVISFKit (and anything that uses VVISFKit) to parse JSON data.  Why JSONKit instead of NSJSONSerialization?  Because everything in this project has to run under 10.6, and NSJSONSerialization didn't appear until 10.7...
- the DDMathParser framework is a lovely piece of work by Dave DeLong (https://github.com/davedelong/DDMathParser).  This project is using an old version of DDMathParser (commit 3E6A35 in the repos) to ensure compatibility with 32-bit/non-ARC environments.  In this project, DDMathParser is used by VVISFKit (and anything that uses VVISFKit) to parse and solve basic math expressions in JSON blobs.
- GLScene Test App demonstrates how to do use the VVBufferPool framework to easily render-to-texture with a VVBuffer using generic GL drawing commands, as well as how to create a VVBuffer/GL texture from an image file.
- CIGLScene Test App demonstrates how to use VVBufferPool to convert CIImages to GL textures- this makes it very, very easy to work with CIFilters and GL textures.
- QCGLScene Test App demonstrates how to use VVBufferPool to render QC compositions to GL textures, as well as how to do MSAA rendering for smoother output images under some circumstances
- ISFGLScene Test App demonstrates how to use VVBufferPool and VVISFKit to open, interact with, and render ISF files to GL textures
- QT and Hap Test App demonstrates how to use VVBufferPool to render QuickTime movies to GL textures.  Also shows how to use VVBufferPool to decode Hap video frames.
  • Loading branch information
mrRay committed Aug 2, 2014
1 parent ac2da76 commit 547a57b
Show file tree
Hide file tree
Showing 184 changed files with 41,470 additions and 3,162 deletions.
25 changes: 25 additions & 0 deletions CIGLScene Test App/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#import <Cocoa/Cocoa.h>
#import <VVBasics/VVBasics.h>
#import <VVBufferPool/VVBufferPool.h>




@interface AppDelegate : NSObject <NSApplicationDelegate> {
CVDisplayLinkRef displayLink;
NSOpenGLContext *sharedContext;
IBOutlet VVBufferGLView *bufferView;

CIFilter *checkerboardSrc;
CIGLScene *ciScene; // this renders a CIImage to a GL texture
VVStopwatch *swatch; // used to animate the size of the checkerboard
}

- (void) renderCallback;

@end




CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *inNow, const CVTimeStamp *inOutputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext);
97 changes: 97 additions & 0 deletions CIGLScene Test App/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#import "AppDelegate.h"
#import <OpenGL/CGLMacro.h>




@implementation AppDelegate


- (id) init {
if (self = [super init]) {
// make a shared GL context. other GL contexts created to share this one may share resources (textures, buffers, etc).
sharedContext = [[NSOpenGLContext alloc] initWithFormat:[GLScene defaultPixelFormat] shareContext:nil];

// create the global buffer pool from the shared context
[VVBufferPool createGlobalVVBufferPoolWithSharedContext:sharedContext];
// ...other stuff in the VVBufferPool framework- like the views, the buffer copier, etc- will
// automatically use the global buffer pool's shared context to set themselves up to function with the pool.

// make a checkerboard CIFilter, set its defaults
checkerboardSrc = [[CIFilter filterWithName:@"CICheckerboardGenerator"] retain];
[checkerboardSrc setDefaults];

// make a CIGLScene. this is a GL context that will be used to render CIImages to GL textures.
ciScene = [[CIGLScene alloc] initWithSharedContext:sharedContext];
[ciScene setSize:NSMakeSize(640,480)]; // this sets the render resolution...
// make a stopwatch that we'll use to crudely animate the size of the checkerboard
swatch = [[VVStopwatch alloc] init];
[swatch start];
return self;
}
[self release];
return nil;
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// make the displaylink, which will drive rendering
CVReturn err = kCVReturnSuccess;
CGOpenGLDisplayMask totalDisplayMask = 0;
GLint virtualScreen = 0;
GLint displayMask = 0;
NSOpenGLPixelFormat *format = [GLScene defaultPixelFormat];

for (virtualScreen=0; virtualScreen<[format numberOfVirtualScreens]; ++virtualScreen) {
[format getValues:&displayMask forAttribute:NSOpenGLPFAScreenMask forVirtualScreen:virtualScreen];
totalDisplayMask |= displayMask;
}
err = CVDisplayLinkCreateWithOpenGLDisplayMask(totalDisplayMask, &displayLink);
if (err) {
NSLog(@"\t\terr %d creating display link in %s",err,__func__);
displayLink = NULL;
}
else {
CVDisplayLinkSetOutputCallback(displayLink, displayLinkCallback, self);
CVDisplayLinkStart(displayLink);
}
}
// this method is called from the displaylink callback
- (void) renderCallback {

// determine the size of the square based on the stopwatch, apply it to the CIFilter
double squareSize = (fmod([swatch timeSinceStart], 5.0) / 5.0) * 64.0;
[checkerboardSrc setValue:[NSNumber numberWithDouble:squareSize] forKey:@"inputWidth"];

// get a CIImage from the CIFilter
CIImage *startImg = [checkerboardSrc valueForKey:@"outputImage"];

// tell the CI scene to render a buffer from the CIImage (this renders the CIImage to a GL texture)
VVBuffer *newTex = [ciScene allocAndRenderBufferFromImage:startImg];

// draw the GL texture i just rendered in the buffer view
[bufferView drawBuffer:newTex];

// don't forget to release the buffer we allocated!
VVRELEASE(newTex);

// tell the buffer pool to do its housekeeping (releases any "old" resources in the pool that have been sticking around for a while)
[[VVBufferPool globalVVBufferPool] housekeeping];
}


@end




CVReturn displayLinkCallback(CVDisplayLinkRef displayLink,
const CVTimeStamp *inNow,
const CVTimeStamp *inOutputTime,
CVOptionFlags flagsIn,
CVOptionFlags *flagsOut,
void *displayLinkContext)
{
NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
[(AppDelegate *)displayLinkContext renderCallback];
[pool release];
return kCVReturnSuccess;
}
32 changes: 32 additions & 0 deletions CIGLScene Test App/CIGLScene Test App-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.Vidvox.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
7 changes: 7 additions & 0 deletions CIGLScene Test App/CIGLScene Test App-Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'CIGLScene Test App' target in the 'CIGLScene Test App' project
//

#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
29 changes: 29 additions & 0 deletions CIGLScene Test App/en.lproj/Credits.rtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw9840\paperh8400
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\f0\b\fs24 \cf0 Engineering:
\b0 \
Some people\
\

\b Human Interface Design:
\b0 \
Some other people\
\

\b Testing:
\b0 \
Hopefully not nobody\
\

\b Documentation:
\b0 \
Whoever\
\

\b With special thanks to:
\b0 \
Mom\
}
2 changes: 2 additions & 0 deletions CIGLScene Test App/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

Loading

0 comments on commit 547a57b

Please sign in to comment.