[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23789] trunk/blender/intern/ghost/intern: Cocoa : fix secondary window display bug issue

Damien Plisson damien.plisson at yahoo.fr
Mon Oct 12 18:51:36 CEST 2009


Revision: 23789
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23789
Author:   damien78
Date:     2009-10-12 18:51:36 +0200 (Mon, 12 Oct 2009)

Log Message:
-----------
Cocoa : fix secondary window display bug issue

Modified Paths:
--------------
    trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.h
    trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm

Modified: trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.h	2009-10-12 16:34:55 UTC (rev 23788)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.h	2009-10-12 16:51:36 UTC (rev 23789)
@@ -275,6 +275,9 @@
 	/** The mother SystemCocoa class to send events */
 	GHOST_SystemCocoa *m_systemCocoa;
 			
+	/** The first created OpenGL context (for sharing display lists) */
+	static NSOpenGLContext *s_firstOpenGLcontext;
+	
 	NSCursor*	m_customCursor;
 
 	GHOST_TabletData m_tablet;

Modified: trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm	2009-10-12 16:34:55 UTC (rev 23788)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm	2009-10-12 16:51:36 UTC (rev 23789)
@@ -149,6 +149,8 @@
 
 #pragma mark initialization / finalization
 
+NSOpenGLContext* GHOST_WindowCocoa::s_firstOpenGLcontext = nil;
+
 GHOST_WindowCocoa::GHOST_WindowCocoa(
 	GHOST_SystemCocoa *systemCocoa,
 	const STR_String& title,
@@ -197,7 +199,7 @@
 	
 	[pixelFormat release];
 	
-	m_openGLContext = [m_openGLView openGLContext];
+	m_openGLContext = [m_openGLView openGLContext]; //This context will be replaced by the proper one just after
 	
 	[m_window setContentView:m_openGLView];
 	[m_window setInitialFirstResponder:m_openGLView];
@@ -229,9 +231,6 @@
 {
 	if (m_customCursor) delete m_customCursor;
 
-	/*if(ugly_hack==m_windowRef) ugly_hack= NULL;
-	
-	if(ugly_hack==NULL) setDrawingContextType(GHOST_kDrawingContextTypeNone);*/
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 	[m_openGLView release];
 	
@@ -670,12 +669,15 @@
 		case GHOST_kDrawingContextTypeOpenGL:
 			if (!getValid()) break;
             				
-				pixelFormat = [m_openGLView pixelFormat];
-				tmpOpenGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
-															  shareContext:m_openGLContext];
-				if (tmpOpenGLContext == nil)
-					success = GHOST_kFailure;
-					break;
+			pixelFormat = [m_openGLView pixelFormat];
+			tmpOpenGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
+															  shareContext:s_firstOpenGLcontext];
+			if (tmpOpenGLContext == nil) {
+				success = GHOST_kFailure;
+				break;
+			}
+			
+			if (!s_firstOpenGLcontext) s_firstOpenGLcontext = tmpOpenGLContext;
 #ifdef WAIT_FOR_VSYNC
 				/* wait for vsync, to avoid tearing artifacts */
 				[tmpOpenGLContext setValues:1 forParameter:NSOpenGLCPSwapInterval];
@@ -683,7 +685,6 @@
 				[m_openGLView setOpenGLContext:tmpOpenGLContext];
 				[tmpOpenGLContext setView:m_openGLView];
 				
-				[m_openGLContext release];
 				m_openGLContext = tmpOpenGLContext;
 			break;
 		
@@ -704,7 +705,12 @@
 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 	switch (m_drawingContextType) {
 		case GHOST_kDrawingContextTypeOpenGL:
-			[m_openGLView clearGLContext];
+			if (m_openGLContext)
+			{
+				[m_openGLView clearGLContext];
+				if (s_firstOpenGLcontext == m_openGLContext) s_firstOpenGLcontext = nil;
+				m_openGLContext = nil;
+			}
 			[pool drain];
 			return GHOST_kSuccess;
 		case GHOST_kDrawingContextTypeNone:





More information about the Bf-blender-cvs mailing list