I am trying to make the following combination work in a browser plugin on OS X (10.8.5) running Safari (6.2) using Core Animation/Cocoa:
FireBreath + SDL2
I have studied the BasicMediaPlayer example provided by FB and understand that I can access a CALayer via FB::PluginWindowMac::getDrawingPrimitive().
What I would like to accomplish is to use SDL/SDL2 to perform the rendering.
On Windows it is relatively easy because the FB plugin window (FB::PluginWindowWin) provides a HWND, which can be passed to the SDL_CreateWindowFrom API (followed by SDL_CreateRenderer and SDL_CreateTexture to perform the rendering). The void* would correspond to an NSWindow* on the Mac (from what I have learned), which I understand I won't have access to within my plugin (based on other posts I have read).
So the question is: how can I use SDL with an existing CALayer on OS X?
I have done quite a bit of research and also went through the SDL/SDL2 forums:
I appears that it is unfortunately not possible to use SDL in the environment outlined in my question.
The solution I ended up with: I basically decided to mirror the example provided by firebreath called BasicMediaPlayer:
CAOpenGLLayer
, where you place your OpenGL drawing inside the drawInCGLContext
method.FB::AttachedEvent
: the plugin window object you'll receive can be cast to a FB::PluginWindowMac*
, which lets you attach your specialized CA layer via getDrawingPrimitive
.For anyone not familiar with OpenGL and how to render frames: take a look at the following question on stackoverflow, which should get you started.