Rendering a CALayer to the QCPluginContext

dust's picture

Im hoping someone knows how to render a CALayer to a QCPluginContext or to the OpenGl cgl_ctx context ? It seems there is plenty of documentation in regards to rendering a QCView or QCComposition to a CA Layer. I thought contexts where interchangeable but I have tried rendering a CALayer to the QCPluginContext but it says non compatible context.

so i have tried this.

CARenderer* car;
 
car =[CARenderer rendererWithCGLContext:cgl_ctx options:arguments];
   car.layer = rootLayer;

also I have tried.

[rootLayer renderInContext:cgl_ctx;]

as well as a few other things like trying to render the CALayer to an image and bind that image to a GL quad etc... which i thought of as a temporary fix but i would like to be able to bind a CALayer right to the QCView not the QCView to layer. This way I can leverage the new emitters and what not in.

i would really like to get this plugin going so far I have 65 inputs, 700+ lines of code with no build errors or GFlog errors. So its pretty heavy with lots of fine controls.

google has not been my friend as on this one. any help would be greatly appreciated. there seems to be lack of documentation in these regards.

PreviewAttachmentSize
Archive.zip54.11 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

dust's picture
Re: Rendering a CALayer to the QCPluginContext

so i was bit tired when i asked this question not sure if i figured this out or not but i obviously tried to running the emitter as a CAOpenGLLayer which was my first thought but i got like 60 warnings about how this and that may not respond to CAOpenGLLayer, so i decided to test on a NSView in a CAOpenGLLayer and everything seems to work so i'm going to try working with CAOpenGLLayer. Still a couple questions as openGL has lots of set up, and i know the CAOpenGLLayer does some of this for you so as fas as time base goes if i'm setting layer to asynchronous is it best to use an external time base mode ? i would prefer to do this. and as far as asynchronous is concerned if running in asynchronous mode is it best to set plugin to external time mode ? and if the plugin is in external time mode and vbl sync = yes does the vbl sync cap time to not be greater than the gpu refresh rate ? and how does one calculate the refresh rate in hz to a time base as in is 60 fps 60hz ?

so does this look right to get a CAOpenGLLayer into cgl_ctx ?

this to check if can draw context ?

- (BOOL)canDrawInCGLContext:(CGLContextObj)glContext
                pixelFormat:(CGLPixelFormatObj)pixelFormat
               forLayerTime:(CFTimeInterval)timeInterval
                displayTime:(const CVTimeStamp *)timeStamp

this to draw context.

- (void)drawInCGLContext:(CGLContextObj)glContext 
             pixelFormat:(CGLPixelFormatObj)pixelFormat 
            forLayerTime:(CFTimeInterval)interval 
             displayTime:(const CVTimeStamp *)timeStamp 

so im not entirely sure if contextual references match here or what is the correct pixel format for QC Context ?

- (void)releaseCGLPixelFormat:(CGLPixelFormatObj)pixelFormat {
  CGLDestroyPixelFormat(pixelFormat);
}
 
- (CGLPixelFormatObj)copyCGLPixelFormatForDisplayMask:(uint32_t)mask {
  CGLPixelFormatAttribute attribs[] =
  {
    kCGLPFAAccelerated,
    kCGLPFADoubleBuffer,
    kCGLPFAColorSize, 24,
    kCGLPFADepthSize, 16,
    0
  };
 
  CGLPixelFormatObj pixelFormatObj = NULL;
  GLint numPixelFormats = 0;
 
  CGLChoosePixelFormat(attribs, &pixelFormatObj, &numPixelFormats);
  return pixelFormatObj;
}

any help will be appreciated. sorry this is my first consumer based image plug-in. once i get through this contextual disparity i think i should be able to do some more cool image based things.

thanks