Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2021-09-10 22:53:33 +0300
committerClément Foucault <foucault.clem@gmail.com>2021-10-12 17:47:41 +0300
commit6535779c92b90035870047f178cf3eff95f0bdf0 (patch)
tree3dc5a4704750f2b6fdb9952e5ec11d3ba3fbedcf /intern/ghost/intern/GHOST_SystemCocoa.mm
parenta2daf92a57e45039fe928a9bc6251e8f8fc2bd6d (diff)
GHOST: Unify behavior of offscreen context creation
This makes sure the previously bound context is restored after creating a new context. This follows what is already happening on windows. All system backend are patched. This also removes the goto and some code duplication. Differential Revision: https://developer.blender.org/D12455
Diffstat (limited to 'intern/ghost/intern/GHOST_SystemCocoa.mm')
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm15
1 files changed, 10 insertions, 5 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 189e663f91a..5a7d6ef2c01 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -767,13 +767,18 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const char *title,
*/
GHOST_IContext *GHOST_SystemCocoa::createOffscreenContext(GHOST_GLSettings glSettings)
{
+ NSOpenGLContext *prevContext = [NSOpenGLContext currentContext];
+
GHOST_Context *context = new GHOST_ContextCGL(false, NULL, NULL, NULL);
- if (context->initializeDrawingContext())
- return context;
- else
+ if (context->initializeDrawingContext() == false) {
delete context;
-
- return NULL;
+ context = nullptr;
+ }
+ /* Restore previously bound context. This is just to follow the win32 behavior. */
+ if (prevContext) {
+ [prevContext makeCurrentContext];
+ }
+ return context;
}
/**