Cocoa: Allow sharing OpenGL context data between instances of TOpenGLControl
Adds support for sharing OpenGL context data between multiple instances of TOpenGLControl
, in case of Cocoa widgetset.
Similar to !95 (merged) , this time for Cocoa widgetset.
Tested on macOS 12.3.1, Intel-based. Tested with Castle Game Engine editor, that can create multiple contexts (when you open both main design, and some preview) and relies on TOpenGLControl
ability to share data between all open contexts. Afer this PR, it works OK.
Note: The code already had some unfinished attempts at this sharing. I just cleaned them up and made working :)
-
TCocoaOpenGLView.nsGL
(was only in the comments) does not seem a good approach, you should just useTCocoaOpenGLView.openGLContext
that is ready fromNSOpenGLView
( https://developer.apple.com/documentation/appkit/nsopenglview/ ). You can get and setTCocoaOpenGLView.openGLContext
. -
Before this PR,
aNSOpenGLContext
creation was actually useless, nothing was using it. After this PR,aNSOpenGLContext
is used byView.setOpenGLContext(aNSOpenGLContext)
. And it is crucial that it is used, as this seems to be the only way to get context sharing with NSOpenGLView / NSOpenGLContext combination. -
I also removed unused
CGLContext
variable. Other comments in the file suggest thatCGLContextObj
approach was abandoned.