I have been trying for hours to display the Core Animation layer tree in an OpenGL context using CARenderer. Currently, the OpenGL context is provided by the NSOpenGLView subclass set in Interface Builder, with default settings.
This is how I installed CALayers in my example:
l1 = [[CALayer layer] retain];
If I add them to a regular NSView, they will display just fine.
Here is the drawing code from my subclass NSOpenGLView:
- (void) drawRect:(NSRect)dirtyRect { NSRect frame = [self frame];
I confirmed that the view is redrawn after the layers were created, and the view itself seems to work fine - the OpenGL commands that I issue are displayed correctly. CARenderer really comes to life (in fact, if l1 is already tied to a different context at the time this code is run, it will dutifully complain). There simply is no visible way out.
Other things I've tried: wrapping CARenderer code in CATransaction, messing around with NSOpenGLView settings in Interface Builder, passing the whole thing into a manually created OpenGL context and saving it in an image file ... all with the same effect: OpenGL's own commands show a fine CARenderer shows nothing.
I suspect that something is wrong with how my OpenGL context is set up, or that I could even somehow render outside of my viewport ... maybe some really silly little details. Unfortunately, both the documentation and sample code for CARenderer on the Internet are somewhat rare, and although I am fairly experienced with Core Animation, my knowledge of OpenGL is clearly limited.
So, right now, I'm seriously at a dead end and completely out of ideas, so any pointers are really appreciated!
Greetings