/* Copyright (c) 2004-2006, Marcus Müller . Copyright (c) 2006, Michael Maier . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of Mulle kybernetiK nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __MulleSight_OpenGLView_H #define __MulleSight_OpenGLView_H #import #import #import #import #import @class LiveVideo; /** * This is a base class for OpenGL, CoreImage, Display Link support. */ @interface OpenGLView : NSView { @protected NSOpenGLContext *context; /** the openGL context */ NSOpenGLPixelFormat *pixelFormat; /** the pixelformat within the context */ CIContext *ciContext; /** CoreImage context base on context */ CVImageBufferRef currentFrame; /** current frame from CoreVideo display link */ NSRecursiveLock *lock; /** openGL is not threadsafe */ LiveVideo *liveVideo; /** the grabber */ CVDisplayLinkRef displayLink; /** the display link for the main display */ QTVisualContextRef textureContext; /** the texture context is used to get the grabbed image as a texture */ BOOL flipImage; } /** * Initialization methods, subclasser can overwrite it */ - (void)initOpenGL; - (void)initDisplayLink; /** * Returns the CoreImage context. */ - (CIContext*)ciContext; /** * How to render? Return YES for OpenGL. */ - (BOOL)useOpenGLForDrawing; /** * This method draws the content. It is called threadsafe from the * drawRect method. All initializations are done. */ - (void)openGLdrawRect:(NSRect)rect; /** * Called by the display link thread */ - (CVReturn)outputForTime:(const CVTimeStamp*)timeStamp; /** * Dispose the LiveVideo object. */ - (void)disposeVideo; /** * This method is called if the view's size is changed. */ -(void)update:(NSNotification*)notification; /** * Called after rendering to cleanup */ - (void)flush; /** * */ - (void)drawRect:(NSRect)rect; /** * Start the LiveVideo */ - (IBAction)startVideo:(id)sender; /** * Stops the LiveVideo, the method calls disposeVideo. */ - (IBAction)stopVideo:(id)sender; - (void)setShouldFlipImage:(BOOL)_yn; - (BOOL)shouldFlipImage; @end #endif /* __MulleSight_OpenGLView_H */