From 50186191d998d6ab51b547d94461c8d0625f3ce0 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Fri, 21 Jan 2011 09:56:41 +0000 Subject: enabled multithread GL engine + minor cleanup --- intern/ghost/intern/GHOST_SystemCocoa.h | 6 +++--- intern/ghost/intern/GHOST_WindowCocoa.mm | 37 +++++++++++--------------------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index de835ad7768..09af9387951 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -53,7 +53,7 @@ public: * Constructor. */ GHOST_SystemCocoa(); - + /** * Destructor. */ @@ -263,7 +263,7 @@ protected: * @return Indication whether the event was handled. */ GHOST_TSuccess handleTabletEvent(void *eventPtr); - + /** * Helps handleTabletEvent function. */ @@ -336,7 +336,7 @@ protected: /** Multitouch gesture in progress, useful to distinguish trackpad from mouse scroll events */ bool m_isGestureInProgress; - + NSAutoreleasePool* m_pool; }; diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index aea59de51cd..5bb85eaf1e7 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -34,7 +34,7 @@ #include #endif -#include +#include // standard OpenGL + Mac CGL #include "GHOST_WindowCocoa.h" #include "GHOST_SystemCocoa.h" @@ -321,7 +321,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa( return; } - [m_window setSystemAndWindowCocoa:ghostSystem windowCocoa:this]; + [m_window setSystem:ghostSystem ghostWindow:this]; // Forbid to resize the window below the blender defined minimum one [m_window setContentMinSize:NSMakeSize(320,240)]; @@ -400,7 +400,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa( activateDrawingContext(); CocoaWindowDelegate *windowDelegate = [[CocoaWindowDelegate alloc] init]; - [windowDelegate setSystemAndWindowCocoa:ghostSystem windowCocoa:this]; + [windowDelegate setSystem:ghostSystem ghostWindow:this]; [m_window setDelegate:windowDelegate]; [m_window setAcceptsMouseMovedEvents:YES]; @@ -419,7 +419,6 @@ GHOST_WindowCocoa::~GHOST_WindowCocoa() { if (m_customCursor) delete m_customCursor; -// NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [m_openGLView release]; if (m_window) { @@ -434,8 +433,6 @@ GHOST_WindowCocoa::~GHOST_WindowCocoa() if ([windowsList count]) { [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil]; } - -// [pool drain]; } #pragma mark accessors @@ -851,7 +848,6 @@ GHOST_TSuccess GHOST_WindowCocoa::swapBuffers() } } -// [m_pool drain]; // needed to put this in a function that is called regularly return success; } @@ -872,12 +868,10 @@ GHOST_TSuccess GHOST_WindowCocoa::activateDrawingContext() { if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) { if (m_openGLContext != nil) { -// NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [m_openGLContext makeCurrentContext]; // Disable AA by default if (m_numOfAASamples > 0) glDisable(GL_MULTISAMPLE_ARB); -// [pool drain]; return GHOST_kSuccess; } } @@ -889,15 +883,9 @@ GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextTyp { GHOST_TSuccess success = GHOST_kFailure; -// NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSOpenGLPixelFormat *pixelFormat; NSOpenGLContext *tmpOpenGLContext; - /***** Multithreaded opengl code : uncomment for enabling - CGLContextObj cglCtx; - */ - switch (type) { case GHOST_kDrawingContextTypeOpenGL: if (!getValid()) break; @@ -910,20 +898,21 @@ GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextTyp break; } - //Switch openGL to multhreaded mode - /******* Multithreaded opengl code : uncomment for enabling */ - cglCtx = (CGLContextObj)[tmpOpenGLContext CGLContextObj]; + /******* Multithreaded OpenGL code : uncomment for enabling */ + CGLContextObj cglCtx = (CGLContextObj)[tmpOpenGLContext CGLContextObj]; if (CGLEnable(cglCtx, kCGLCEMPEngine) == kCGLNoError) - printf("\nSwitched openGL to multithreaded mode"); + printf("\nUsing multithreaded OpenGL engine.\n"); if (!s_firstOpenGLcontext) s_firstOpenGLcontext = tmpOpenGLContext; -#ifdef WAIT_FOR_VSYNC - { + + #ifdef WAIT_FOR_VSYNC + { GLint swapInt = 1; /* wait for vsync, to avoid tearing artifacts */ [tmpOpenGLContext setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; - } -#endif + } + #endif + [m_openGLView setOpenGLContext:tmpOpenGLContext]; [tmpOpenGLContext setView:m_openGLView]; @@ -937,7 +926,7 @@ GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextTyp default: break; } -// [pool drain]; + return success; } -- cgit v1.2.3