1

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?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Andreas
  • 31
  • 5
  • I doubt anyone knows, but good luck =] – taxilian Jan 15 '15 at 21:28
  • I appreciate your taking a look at it though. Would you instead recommend using OpenGL and handle rendering that way? I am basically just trying to render YUV420P frames, which on other platforms I can feed to an SDL renderer, except on OSX. – Andreas Jan 16 '15 at 22:31

1 Answers1

0

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:

  1. You basically have to specialize CAOpenGLLayer, where you place your OpenGL drawing inside the drawInCGLContext method.
  2. Listen for the 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.

Community
  • 1
  • 1
Andreas
  • 31
  • 5