write a plugin on firebreath (mac os), which draws a video Creates a window to get the context, now I would want that in the window drew my library, which is running in another thread.
How do I do?
You can use an OpenGL context from multiple threads, as long as you never use it simultaneously from more than one thread at a time. E.g.
Thread A:
[myContext makeCurrentContext];
// Do something with the context...
// ... then release it on the thread.
[NSOpenGLContext clearCurrentContext];
// Tell Thread B that we released the context.
// Wait for Thread B to finish...
// Grab the context again.
[myContext makeCurrentContext];
// Do something with the context...
Thread B:
// Wait for Thread A to release the context...
[myContext makeCurrentContext];
// Do something with the context...
// ... then release it on the thread.
[NSOpenGLContext clearCurrentContext];
// Let Thread A know, that we are done with the context.
Another possibility is to use a secondary shared context. A shared context shares the same resources with its parent context, so you can create a texture in a shared context (used on the secondary thread), render your video to that texture on the secondary thread, then make the main thread render the texture (which is also available in the parent context on the main thread) to the screen, before you render the next frame to the texture on the secondary thread.
Same Code as above with CGL framework:
Thread A:
err = CGLSetCurrentContext(myContext);
// Do something with the context...
// ... then release it on the thread.
err = CGLSetCurrentContext(NULL);
// Tell Thread B that we released the context.
// Wait for Thread B to finish...
// Grab the context again.
err = CGLSetCurrentContext(myContext);
// Do something with the context...
Thread B:
// Wait for Thread A to release the context...
err = CGLSetCurrentContext(myContext);
// Do something with the context...
// ... then release it on the thread.
err = CGLSetCurrentContext(NULL);
// Let Thread A know, that we are done with the context.