Sharing GLContexts
Hit a problem yesterday, how to share GL contexts with OpenCL and several GLCanvas objects. i.e. I have a window with a few output windows and they all need to share OpenCL processing.
I eventually found one of the test cases which did the same thing, and I used a similar approach.
- Create a 1x1 off-screen GLPbuffer object using GLDrawableFactory.
- Add an event listener to that.
- Call display() which will invoke the GLEventListener.init() method synchronously - in which I then create my CLGLContext object.
- A few other bits and pieces like using makeCurrent() on the GLContext taken from the CLGLContext() when creating textures to be shared in the OpenCL code.
Bit tricky to debug as most mistakes just lead to clue-free segfaults. It didn't help that I forgot to initialise a width/height variable at one point, and until I did everything 'worked' except that creating the output texture always failed with an error which didn't make sense.