File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ class GLManagerLegacy_MacOS {
6262
6363 Error create_context (GLWindow &win);
6464
65+ bool framework_loaded = false ;
6566 bool use_vsync = false ;
6667 CGLEnablePtr CGLEnable = nullptr ;
6768 CGLSetParameterPtr CGLSetParameter = nullptr ;
Original file line number Diff line number Diff line change 3232
3333#if defined(MACOS_ENABLED) && defined(GLES3_ENABLED)
3434
35+ #include < dlfcn.h>
3536#include < stdio.h>
3637#include < stdlib.h>
3738
156157}
157158
158159Error GLManagerLegacy_MacOS::initialize () {
159- return OK ;
160+ return framework_loaded ? OK : ERR_CANT_CREATE ;
160161}
161162
162163void GLManagerLegacy_MacOS::set_use_vsync (bool p_use) {
186187}
187188
188189GLManagerLegacy_MacOS::GLManagerLegacy_MacOS () {
189- CFBundleRef framework = CFBundleGetBundleWithIdentifier (CFSTR (" com.apple.opengl" ));
190- CFBundleLoadExecutable (framework);
191-
192- CGLEnable = (CGLEnablePtr)CFBundleGetFunctionPointerForName (framework, CFSTR (" CGLEnable" ));
193- CGLSetParameter = (CGLSetParameterPtr)CFBundleGetFunctionPointerForName (framework, CFSTR (" CGLSetParameter" ));
194- CGLGetCurrentContext = (CGLGetCurrentContextPtr)CFBundleGetFunctionPointerForName (framework, CFSTR (" CGLGetCurrentContext" ));
190+ NSBundle *framework = [NSBundle bundleWithPath: @" /System/Library/Frameworks/OpenGL.framework" ];
191+ if (framework) {
192+ void *library_handle = dlopen ([framework.executablePath UTF8String ], RTLD_NOW);
193+ if (library_handle) {
194+ CGLEnable = (CGLEnablePtr)dlsym (library_handle, " CGLEnable" );
195+ CGLSetParameter = (CGLSetParameterPtr)dlsym (library_handle, " CGLSetParameter" );
196+ CGLGetCurrentContext = (CGLGetCurrentContextPtr)dlsym (library_handle, " CGLGetCurrentContext" );
197+
198+ framework_loaded = CGLEnable && CGLSetParameter && CGLGetCurrentContext;
199+ }
200+ }
195201}
196202
197203GLManagerLegacy_MacOS::~GLManagerLegacy_MacOS () {
You can’t perform that action at this time.
0 commit comments