Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Viljens Triumf fix

  • Loading branch information...
commit af478a783613830148b2b10b91a3f596e6ed1822 1 parent 448adf9
Jonas Jongejan authored
3  Project.xcconfig
View
@@ -2,7 +2,6 @@
//THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
OFX_PATH = $(SOURCE_ROOT)/
OF_PATH = $(OFX_PATH)ofxCocoaPlugins/libs/openFrameworks
-HEADER_OLAD = "/opt/local/include"
//THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
#include "ofxCocoaPlugins/libs/openFrameworks/libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
@@ -14,4 +13,4 @@ HEADER_OPENCV = "$(OF_PATH)/addons/ofxOpenCv/libs/opencv/include/" "$(OF_PATH)/a
OTHER_LDFLAGS = $(OF_CORE_LIBS) $(LIB_OPENCV) -headerpad_max_install_names
HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)
-USER_HEADER_SEARCH_PATHS = $(HEADER_OPENCV) $(HEADER_OLAD)
+USER_HEADER_SEARCH_PATHS = $(HEADER_OPENCV)
30 ofxCocoaPlugins copy-Info.plist
View
@@ -0,0 +1,30 @@
+<?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>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>org.halfdanj.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>FMWK</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>Copyright © 2011 __MyCompanyName__. All rights reserved.</string>
+ <key>NSPrincipalClass</key>
+ <string></string>
+</dict>
+</plist>
1,301 ofxCocoaPlugins.xcodeproj/project.pbxproj
View
1,251 additions, 50 deletions not shown
2  ofxCocoaPlugins/libs/openframeworks
@@ -1 +1 @@
-Subproject commit 19b2388040bca76064a85825ed69f2c0c42d206b
+Subproject commit bec6dd7149c0fe515fba0e8ccd3a7e3d69c5e267
2  ofxCocoaPlugins/src/CorePlugins/CorePluginsIncludes.h
View
@@ -5,7 +5,7 @@
#import <ofxCocoaPlugins/Midi.h>
#import <ofxCocoaPlugins/BlobTracker2d.h>
#import <ofxCocoaPlugins/CameraCalibration.h>
-#import <ofxCocoaPlugins/OpenDMX.h>
+//#import <ofxCocoaPlugins/OpenDMX.h>
#import <ofxCocoaPlugins/Tracker.h>
#import <ofxCocoaPlugins/OSCControl.h>
102 ofxCocoaPlugins/src/Helpers/QTKitMovieRenderer.h
View
@@ -0,0 +1,102 @@
+/*
+ * ofxQTKitMoviePlayer example
+ *
+ * Created by James George, http://www.jamesgeorge.org
+ * over a long period of time for a few different projects in collaboration with
+ * FlightPhase http://www.flightphase.com
+ * and the rockwell group lab http://lab.rockwellgroup.com
+ *
+ **********************************************************
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------
+ *
+ * ofxQTKitVideoPlayer provides QTKit/CoreVideo accelerated movie playback
+ * for openFrameworks on OS X
+ *
+ * This class replaces almost all of the functionality of ofVideoPlayer on OS X
+ * and uses the modern QTKit and CoreVideo libraries for playback
+ *
+ * Special Thanks to Marek Bereza for his initial QTKitVideoTexture
+ * http://www.mrkbrz.com/
+ *
+ * Thanks to Anton Marini for help wrangling buffer contexts
+ * http://vade.info/
+ */
+
+#import <Cocoa/Cocoa.h>
+#import <Quartz/Quartz.h>
+#import <QTKit/QTKit.h>
+#import <OpenGL/OpenGL.h>
+
+
+@interface QTKitMovieRenderer : NSObject
+{
+ QTMovie* _movie;
+ QTVisualContextRef _visualContext;
+
+ CVOpenGLTextureCacheRef _textureCache;
+ CVOpenGLTextureRef _latestTextureFrame;
+ CVPixelBufferRef _latestPixelFrame;
+
+ NSSize movieSize;
+ QTTime movieDuration;
+ NSInteger frameCount;
+ NSInteger frameStep;
+
+ BOOL frameUpdated;
+ BOOL useTexture;
+ BOOL usePixels;
+
+}
+
+@property(nonatomic, readonly) NSSize movieSize;
+@property(nonatomic, readonly) BOOL useTexture;
+@property(nonatomic, readonly) BOOL usePixels;
+@property(nonatomic, readonly) NSTimeInterval duration; //duration in seconds
+@property(nonatomic, readonly) NSInteger frameCount; //total frames
+@property(nonatomic, readonly) BOOL isFinished; //returns true if the movie is not looping and over
+
+@property(nonatomic, readwrite) float rate;
+@property(nonatomic, readwrite) float volume;
+@property(nonatomic, readwrite) CGFloat position; //set and get frame position by percent
+@property(nonatomic, readwrite) NSInteger frame; //set and get frame position by percent
+@property(nonatomic, readwrite) BOOL loops; //set and get loopstate
+
+@property(nonatomic, readonly) BOOL textureAllocated;
+@property(nonatomic, readonly) GLuint textureID;
+@property(nonatomic, readonly) GLenum textureTarget;
+
+- (void) draw:(NSRect)drawRect;
+- (BOOL) loadMovie:(NSString*)moviePath allowTexture:(BOOL)useTexture allowPixels:(BOOL)usePixels;
+- (BOOL) update;
+
+- (void) bindTexture;
+- (void) unbindTexture;
+
+//copies ARGB pixels to RGBA into the outbuf
+- (void) pixels:(unsigned char*) outbuf;
+
+- (void) setBalance:(float) balance;
+
+@end
453 ofxCocoaPlugins/src/Helpers/QTKitMovieRenderer.m
View
@@ -0,0 +1,453 @@
+/*
+ * ofxQTKitMoviePlayer example
+ *
+ * Created by James George, http://www.jamesgeorge.org
+ * over a long period of time for a few different projects in collaboration with
+ * FlightPhase http://www.flightphase.com
+ * and the rockwell group lab http://lab.rockwellgroup.com
+ *
+ **********************************************************
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------
+ *
+ * ofxQTKitVideoPlayer provides QTKit/CoreVideo accelerated movie playback
+ * for openFrameworks on OS X
+ *
+ * This class replaces almost all of the functionality of ofVideoPlayer on OS X
+ * and uses the modern QTKit and CoreVideo libraries for playback
+ *
+ * Special Thanks to Marek Bereza for his initial QTKitVideoTexture
+ * http://www.mrkbrz.com/
+ *
+ * Thanks to Anton Marini for help wrangling buffer contexts
+ * http://vade.info/
+ */
+
+#import "QTKitMovieRenderer.h"
+
+//secret methods!
+@interface QTMovie (QTFrom763)
+- (QTTime)frameStartTime: (QTTime)atTime;
+- (QTTime)frameEndTime: (QTTime)atTime;
+- (QTTime)keyframeStartTime:(QTTime)atTime;
+@end
+
+struct OpenGLTextureCoordinates
+{
+ GLfloat topLeft[2];
+ GLfloat topRight[2];
+ GLfloat bottomRight[2];
+ GLfloat bottomLeft[2];
+};
+
+typedef struct OpenGLTextureCoordinates OpenGLTextureCoordinates;
+
+@implementation QTKitMovieRenderer
+@synthesize movieSize;
+@synthesize useTexture;
+@synthesize usePixels;
+@synthesize frameCount;
+
+- (BOOL) loadMovie:(NSString*)moviePath allowTexture:(BOOL)doUseTexture allowPixels:(BOOL)doUsePixels
+{
+ if(![[NSFileManager defaultManager] fileExistsAtPath:moviePath])
+ {
+ NSLog(@"No movie file found at %@", moviePath);
+ return NO;
+ }
+
+ //create visual context
+ useTexture = doUseTexture;
+ usePixels = doUsePixels;
+
+ NSError* error;
+ NSMutableDictionary* movieAttributes = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ [NSURL fileURLWithPath:[moviePath stringByStandardizingPath]], QTMovieURLAttribute,
+ [NSNumber numberWithBool:NO], QTMovieOpenAsyncOKAttribute,
+ nil];
+
+ //opt into Quicktime X
+ //this will give some speed up for texture-only rendering on 10.6 machines
+ //but sometimes will slow it down alot!
+ // #ifdef MAC_OS_X_VERSION_10_6
+ // if(self.useTexture && !self.usePixels){
+ // [movieAttributes setObject:[NSNumber numberWithBool:YES] forKey:QTMovieOpenForPlaybackAttribute];
+ // }
+ // #endif
+
+ _movie = [[QTMovie alloc] initWithAttributes:movieAttributes
+ error: &error];
+
+ if(error || _movie == NULL){
+ NSLog(@"Error Loading Movie: %@", error);
+ return NO;
+ }
+
+ movieSize = [[_movie attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
+ NSLog(@"movie size %f %f", movieSize.width, movieSize.height);
+
+ movieDuration = [_movie duration];
+
+ if ([_movie respondsToSelector: @selector(frameEndTime:)]) {
+ // Only on QT 7.6.3
+ QTTime qtStep = (QTTime)[_movie frameEndTime: QTMakeTime(0, _movie.duration.timeScale)];
+ frameStep = qtStep.timeValue;
+ }
+
+ frameCount = movieDuration.timeValue / frameStep;
+ NSLog(@" movie has %d frames ", frameCount);
+
+
+ //if we are using pixels, make the visual context
+ //a pixel buffer context with ARGB textures
+ if(self.usePixels){
+ NSDictionary *pixelBufferAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
+ //if we have a texture, make the pixel buffer OpenGL compatible
+ [NSNumber numberWithBool:self.useTexture], (NSString*)kCVPixelBufferOpenGLCompatibilityKey,
+ //in general this shouldn't be forced. but in order to ensure we get good pixels use this one
+ [NSNumber numberWithInt: kCVPixelFormatType_32ARGB], (NSString*)kCVPixelBufferPixelFormatTypeKey,
+ //specifying width and height can't hurt since we know
+ nil];
+
+ NSMutableDictionary *ctxAttributes = [NSMutableDictionary dictionaryWithObject:pixelBufferAttributes
+ forKey:(NSString*)kQTVisualContextPixelBufferAttributesKey];
+
+ OSStatus err = QTPixelBufferContextCreate(kCFAllocatorDefault, (CFDictionaryRef)ctxAttributes, &_visualContext);
+ if(err){
+ NSLog(@"error %i creating OpenPixelBufferContext", err);
+ return NO;
+ }
+
+ // if we also have a texture, create a texture cache for it
+ if(self.useTexture){
+ //create a texture cache
+ err = CVOpenGLTextureCacheCreate(kCFAllocatorDefault, NULL,
+ CGLGetCurrentContext(), CGLGetPixelFormat(CGLGetCurrentContext()),
+ (CFDictionaryRef)ctxAttributes, &_textureCache);
+ if(err){
+ NSLog(@"error %i creating CVOpenGLTextureCacheCreate", err);
+ return NO;
+ }
+ }
+ }
+ //if we are using a texture, just create an OpenGL visual context and call it a day
+ else if(self.useTexture){
+ OSStatus err = QTOpenGLTextureContextCreate(kCFAllocatorDefault,
+ CGLGetCurrentContext(), CGLGetPixelFormat(CGLGetCurrentContext()),
+ (CFDictionaryRef)NULL, &_visualContext);
+ if(err){
+ NSLog(@"error %i creating QTOpenGLTextureContextCreate", err);
+ return NO;
+ }
+ }
+ else {
+ NSLog(@"Error - QTKitMovieRenderer - Must specify either Pixels or Texture as rendering strategy");
+ return NO;
+ }
+
+ [_movie setVisualContext:_visualContext];
+
+ self.volume = 1.0;
+ self.loops = YES;
+
+ return YES;
+}
+
+- (void) dealloc
+{
+
+ if(_latestTextureFrame != NULL){
+ CVOpenGLTextureRelease(_latestTextureFrame);
+ _latestTextureFrame = NULL;
+ }
+
+ if(_latestPixelFrame != NULL){
+ CVPixelBufferRelease(_latestPixelFrame);
+ _latestPixelFrame = NULL;
+ }
+
+ if(_movie != NULL){
+ [_movie release];
+ _movie = NULL;
+ }
+
+ if(_visualContext != NULL){
+ QTVisualContextRelease(_visualContext);
+ _visualContext = NULL;
+ }
+
+ if(_textureCache != NULL){
+ CVOpenGLTextureCacheRelease(_textureCache);
+ _textureCache = NULL;
+ }
+
+
+ [super dealloc];
+}
+
+//JG Note, in the OF wrapper this does not get used since we have a modified ofTexture taht we use to draw
+//this is here in case you want to use this renderer outside of openFrameworks
+- (void) draw:(NSRect)drawRect
+{
+
+ if(!self.useTexture || _latestTextureFrame == NULL){
+ return;
+ }
+
+ OpenGLTextureCoordinates texCoords;
+
+ CVOpenGLTextureGetCleanTexCoords(_latestTextureFrame,
+ texCoords.bottomLeft,
+ texCoords.bottomRight,
+ texCoords.topRight,
+ texCoords.topLeft);
+
+ [self bindTexture];
+
+ glBegin(GL_QUADS);
+
+ glTexCoord2fv(texCoords.topLeft);
+ glVertex2f(NSMinX(drawRect), NSMinY(drawRect));
+
+ glTexCoord2fv(texCoords.topRight);
+ glVertex2f(NSMaxX(drawRect), NSMinY(drawRect));
+
+ glTexCoord2fv(texCoords.bottomRight);
+ glVertex2f(NSMaxX(drawRect), NSMaxY(drawRect));
+
+ glTexCoord2fv(texCoords.bottomLeft);
+ glVertex2f(NSMinX(drawRect), NSMaxY(drawRect));
+
+ glEnd();
+
+ [self unbindTexture];
+
+}
+
+
+- (BOOL) update
+{
+
+ if (_visualContext == NULL || !QTVisualContextIsNewImageAvailable(_visualContext, NULL)){
+ return NO;
+ }
+ QTVisualContextTask(_visualContext);
+ if(self.usePixels){
+ if(_latestPixelFrame != NULL){
+ CVPixelBufferRelease(_latestPixelFrame);
+ _latestPixelFrame = NULL;
+ }
+
+ OSStatus error = QTVisualContextCopyImageForTime(_visualContext, NULL, NULL, &_latestPixelFrame);
+ //In general this shouldn't happen, but just in case...
+ if (error != noErr) {
+ CVPixelBufferRelease(_latestPixelFrame);
+ return NO;
+ }
+
+ //if we are using a texture, create one from the texture cache
+ if(self.useTexture){
+ if(_latestTextureFrame != NULL){
+ CVOpenGLTextureRelease(_latestTextureFrame);
+ _latestTextureFrame = NULL;
+ CVOpenGLTextureCacheFlush(_textureCache, 0);
+ }
+
+ OSErr err = CVOpenGLTextureCacheCreateTextureFromImage(NULL, _textureCache, _latestPixelFrame, NULL, &_latestTextureFrame);
+ if(err != noErr){
+ NSLog(@"Error creating OpenGL texture");
+ return NO;
+ }
+ }
+ }
+ //just get the texture
+ else if(self.useTexture){
+ if(_latestTextureFrame != NULL){
+ CVOpenGLTextureRelease(_latestTextureFrame);
+ _latestTextureFrame = NULL;
+ }
+
+ OSStatus error = QTVisualContextCopyImageForTime(_visualContext, NULL, NULL, &_latestTextureFrame);
+ if (error != noErr) {
+ CVOpenGLTextureRelease(_latestTextureFrame);
+ return NO;
+ }
+ }
+
+ return YES;
+}
+
+
+//writes out the pixels in RGBA format to outbuf
+- (void) pixels:(unsigned char*) outbuf
+{
+ if(!self.usePixels || _latestPixelFrame == NULL){
+ return;
+ }
+
+ CVPixelBufferLockBaseAddress(_latestPixelFrame, 0);
+ unsigned char* pix = CVPixelBufferGetBaseAddress(_latestPixelFrame);
+
+ //NOTE:
+ //CoreVideo works on ARGB, and openFrameworks is RGBA so we need to swizzle the buffer
+ //before we return it to an openFrameworks app.
+ //this is a bit tricky since CV pixel buffer's bytes per row are not always the same as movieWidth*4.
+ //We have to use the BPR given by CV for the input buffer, and the movie size for the output buffer
+ int x,y, bpr, width, height;
+ bpr = CVPixelBufferGetBytesPerRow(_latestPixelFrame);
+ width = movieSize.width;
+ height = movieSize.height;
+ for(y = 0; y < movieSize.height; y++){
+ for(x = 0; x < movieSize.width*4; x+=4){
+ //copy out the rgb
+ memcpy(outbuf+(y*width*4 + x), pix + (y*bpr+x+1), 3);
+ //swizzle in the alpha.
+ outbuf[(y*width*4 + x)+3] = pix[y*bpr+x];
+ }
+ }
+
+ CVPixelBufferUnlockBaseAddress(_latestPixelFrame, 0);
+}
+
+
+static inline void argb_to_rgb(unsigned char* src, unsigned char* dst, int numPix)
+{
+ int i;
+ for(i = 0; i < numPix; i++){
+ memcpy(dst, src+1, 3);
+ src+=4;
+ dst+=3;
+ }
+}
+
+- (BOOL) textureAllocated
+{
+ return self.useTexture && _latestTextureFrame != NULL;
+}
+
+- (GLuint) textureID
+{
+ return CVOpenGLTextureGetName(_latestTextureFrame);
+}
+
+- (GLenum) textureTarget
+{
+ return CVOpenGLTextureGetTarget(_latestTextureFrame);
+}
+
+- (void) bindTexture
+{
+ if(!self.textureAllocated) return;
+
+ GLuint texID = 0;
+ texID = CVOpenGLTextureGetName(_latestTextureFrame);
+
+ GLenum target = GL_TEXTURE_RECTANGLE_ARB;
+ target = CVOpenGLTextureGetTarget(_latestTextureFrame);
+
+ glEnable(target);
+ glBindTexture(target, texID);
+
+}
+
+- (void) unbindTexture
+{
+ if(!self.textureAllocated) return;
+
+ GLenum target = GL_TEXTURE_RECTANGLE_ARB;
+ target = CVOpenGLTextureGetTarget(_latestTextureFrame);
+ glDisable(target);
+}
+
+- (void) setRate:(float) rate
+{
+ [_movie setRate:rate];
+}
+
+- (float) rate
+{
+ return _movie.rate;
+}
+
+- (void) setVolume:(float) volume
+{
+ [_movie setVolume:volume];
+}
+
+- (float) volume
+{
+ return [_movie volume];
+}
+
+- (void) setBalance:(float) balance
+{
+ SetMovieAudioBalance([_movie quickTimeMovie], balance, 0);
+}
+
+- (void) setPosition:(CGFloat) position
+{
+ _movie.currentTime = QTMakeTime(position*movieDuration.timeValue, movieDuration.timeScale);
+}
+
+- (CGFloat) position
+{
+ return 1.0*_movie.currentTime.timeValue / movieDuration.timeValue;
+}
+
+- (void) setFrame:(NSInteger) frame
+{
+ QTTime qtt = QTMakeTime(frame*frameStep, movieDuration.timeScale);
+ //_movie.currentTime = QTMakeTime(frame*frameStep, movieDuration.timeScale);
+ TimeRecord tr;
+ QTGetTimeRecord(qtt, &tr);
+ SetMovieTime([_movie quickTimeMovie], &tr);
+}
+
+- (NSInteger) frame
+{
+ return _movie.currentTime.timeValue / frameStep;
+}
+
+- (NSTimeInterval) duration
+{
+ return 1.0*movieDuration.timeValue / movieDuration.timeScale;
+}
+
+- (void) setLoops:(BOOL)loops
+{
+ [_movie setAttribute:[NSNumber numberWithBool:loops]
+ forKey:QTMovieLoopsAttribute];
+}
+
+- (BOOL) loops
+{
+ return [[_movie attributeForKey:QTMovieLoopsAttribute] boolValue];
+}
+
+- (BOOL) isFinished
+{
+ return !self.loops && _movie.currentTime.timeValue == movieDuration.timeValue;
+}
+
+@end
2  ofxCocoaPlugins/src/OpenGL/PluginOpenGLControlView.mm
View
@@ -45,7 +45,7 @@ -(void) awakeFromNib{
NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFADepthSize, 24,
-
+
// NSOpenGLPFAAccelerated,
21 ofxCocoaPlugins/src/OpenGL/PluginOpenGLView.mm
View
@@ -130,18 +130,33 @@ -(void)prepareOpenGL{
// GLint swapInt = 1;
// [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
//
+ CGDirectDisplayID displayID = (CGDirectDisplayID)[[[[[self window] screen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
+
+ /* if ((displayID != 0) && (viewDisplayID != displayID) && [[self window] screen] == [window screen]) {
+ if (NULL != displayLink) {
+ NSLog(@"New DisplayID %i on outputview %i",displayID,viewNumber);
+ CVDisplayLinkSetCurrentCGDisplay(displayLink, displayID);
+ }
+ viewDisplayID = displayID;
+ }
+ */
+
+ NSLog(@"Init with display %i",displayID);
// create display link for the main display
if (NULL == displayLink) {
- CVDisplayLinkCreateWithCGDisplay(kCGDirectMainDisplay, &displayLink);
+ CVDisplayLinkCreateWithCGDisplay(displayID, &displayLink);
if (NULL != displayLink) {
// set the current display of a display link.
- CVDisplayLinkSetCurrentCGDisplay(displayLink, kCGDirectMainDisplay);
+ //CVDisplayLinkSetCurrentCGDisplay(displayLink, kCGDirectMainDisplay);
+ CVDisplayLinkSetCurrentCGDisplay(displayLink, displayID);
// set the renderer output callback function
CVDisplayLinkSetOutputCallback(displayLink, &MyDisplayLinkCallback, self);
// activates a display link.
CVDisplayLinkStart(displayLink);
+
+ viewDisplayID = displayID;
} else {
NSLog(@"ERROR could not create displayLink");
}
@@ -319,7 +334,7 @@ - (void) updateDisplayIDWithWindow:(NSWindow*)window
if ((displayID != 0) && (viewDisplayID != displayID) && [[self window] screen] == [window screen]) {
if (NULL != displayLink) {
NSLog(@"New DisplayID %i on outputview %i",displayID,viewNumber);
- CVDisplayLinkSetCurrentCGDisplay(displayLink, displayID);
+ CVDisplayLinkSetCurrentCGDisplay(displayLink, displayID);
}
viewDisplayID = displayID;
}
Please sign in to comment.
Something went wrong with that request. Please try again.