File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -433,6 +433,7 @@ class CC_DLL GLView : public Ref
433433
434434#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
435435 virtual id getCocoaWindow () = 0;
436+ virtual id getNSGLContext () = 0; // stevetranby: added
436437#endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) */
437438
438439 /* *
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ class CC_DLL GLViewImpl : public GLView
138138
139139#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
140140 id getCocoaWindow () override { return glfwGetCocoaWindow (_mainWindow); }
141+ id getNSGLContext () override { return glfwGetNSGLContext (_mainWindow); } // stevetranby: added
141142#endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
142143
143144protected:
Original file line number Diff line number Diff line change @@ -79,11 +79,21 @@ static long getCurrentMillSecond()
7979
8080 // Retain glview to avoid glview being released in the while loop
8181 glview->retain ();
82-
82+
83+ unsigned int ctx_updated_count = 0 ;
84+
8385 while (!glview->windowShouldClose ())
8486 {
8587 lastTime = getCurrentMillSecond ();
86-
88+
89+ // hack to fix issue #19080, black screen on macOS 10.14
90+ // stevetranby: look into doing this outside loop to get rid of condition test per frame
91+ if (ctx_updated_count < 2 ) {
92+ ctx_updated_count++;
93+ NSOpenGLContext * ctx = (NSOpenGLContext *)glview->getNSGLContext ();
94+ [ctx update ];
95+ }
96+
8797 director->mainLoop ();
8898 glview->pollEvents ();
8999
You can’t perform that action at this time.
0 commit comments