From 76019139f620a41839860e27abf9f02f9a7bc28b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 24 May 2019 00:44:32 +0200 Subject: Cleanup: remove unused macOS GHOST OpenGL code --- intern/ghost/intern/GHOST_ContextCGL.h | 18 +------ intern/ghost/intern/GHOST_ContextCGL.mm | 85 ++++---------------------------- intern/ghost/intern/GHOST_SystemCocoa.mm | 17 +------ intern/ghost/intern/GHOST_WindowCocoa.mm | 16 +----- 4 files changed, 13 insertions(+), 123 deletions(-) (limited to 'intern') diff --git a/intern/ghost/intern/GHOST_ContextCGL.h b/intern/ghost/intern/GHOST_ContextCGL.h index fd760837d45..b808effc795 100644 --- a/intern/ghost/intern/GHOST_ContextCGL.h +++ b/intern/ghost/intern/GHOST_ContextCGL.h @@ -26,15 +26,6 @@ #include "GHOST_Context.h" -#ifndef GHOST_OPENGL_CGL_CONTEXT_FLAGS -# define GHOST_OPENGL_CGL_CONTEXT_FLAGS 0 -#endif - -#ifndef GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY -# define GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY 0 -#endif - -@class NSWindow; @class NSOpenGLView; @class NSOpenGLContext; @@ -43,14 +34,7 @@ class GHOST_ContextCGL : public GHOST_Context { /** * Constructor. */ - GHOST_ContextCGL(bool stereoVisual, - NSWindow *window, - NSOpenGLView *openGLView, - int contextProfileMask, - int contextMajorVersion, - int contextMinorVersion, - int contextFlags, - int contextResetNotificationStrategy); + GHOST_ContextCGL(bool stereoVisual, NSOpenGLView *openGLView); /** * Destructor. diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm index 5b8bb643751..cfad6034be7 100644 --- a/intern/ghost/intern/GHOST_ContextCGL.mm +++ b/intern/ghost/intern/GHOST_ContextCGL.mm @@ -27,47 +27,20 @@ #include -//#define GHOST_MULTITHREADED_OPENGL - -#ifdef GHOST_MULTITHREADED_OPENGL -# include -#endif - #include #include NSOpenGLContext *GHOST_ContextCGL::s_sharedOpenGLContext = nil; int GHOST_ContextCGL::s_sharedCount = 0; -GHOST_ContextCGL::GHOST_ContextCGL(bool stereoVisual, - NSWindow *window, - NSOpenGLView *openGLView, - int contextProfileMask, - int contextMajorVersion, - int contextMinorVersion, - int contextFlags, - int contextResetNotificationStrategy) - : GHOST_Context(stereoVisual), - m_openGLView(openGLView), - m_openGLContext(nil), - m_debug(contextFlags) +GHOST_ContextCGL::GHOST_ContextCGL(bool stereoVisual, NSOpenGLView *openGLView) + : GHOST_Context(stereoVisual), m_openGLView(openGLView), m_openGLContext(nil), m_debug(false) { - // for now be very strict about OpenGL version requested - switch (contextMajorVersion) { - case 2: - assert(contextMinorVersion == 1); - assert(contextProfileMask == 0); - m_coreProfile = false; - break; - case 3: - // Apple didn't implement 3.0 or 3.1 - assert(contextMinorVersion == 3); - assert(contextProfileMask == GL_CONTEXT_CORE_PROFILE_BIT); - m_coreProfile = true; - break; - default: - assert(false); - } +#if defined(WITH_GL_PROFILE_CORE) + m_coreProfile = true; +#else + m_coreProfile = false; +#endif } GHOST_ContextCGL::~GHOST_ContextCGL() @@ -233,8 +206,6 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext() std::vector attribs; attribs.reserve(40); - NSOpenGLContext *prev_openGLContext = (m_openGLView) ? [m_openGLView openGLContext] : NULL; - #ifdef GHOST_OPENGL_ALPHA static const bool needAlpha = true; #else @@ -265,38 +236,6 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext() fprintf(stderr, "Renderer: %s\n", glGetString(GL_RENDERER)); } - if (major < 2 || (major == 2 && minor < 1)) { - // fall back to software renderer if GL < 2.1 - fprintf(stderr, "OpenGL 2.1 is not supported on your hardware, falling back to software"); - softwareGL = true; - - // discard hardware GL context - [NSOpenGLContext clearCurrentContext]; - [m_openGLContext release]; - - // create software GL context - makeAttribList(attribs, m_coreProfile, m_stereoVisual, needAlpha, softwareGL); - pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attribs[0]]; - m_openGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat - shareContext:s_sharedOpenGLContext]; - [pixelFormat release]; - - [m_openGLContext makeCurrentContext]; - - getVersion(&major, &minor); - if (m_debug) { - fprintf(stderr, "OpenGL version %d.%d%s\n", major, minor, softwareGL ? " (software)" : ""); - fprintf(stderr, "Renderer: %s\n", glGetString(GL_RENDERER)); - } - } - -#ifdef GHOST_MULTITHREADED_OPENGL - // Switch openGL to multhreaded mode - if (CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine) == kCGLNoError) - if (m_debug) - fprintf(stderr, "\nSwitched OpenGL to multithreaded mode\n"); -#endif - #ifdef GHOST_WAIT_FOR_VSYNC { GLint swapInt = 1; @@ -310,26 +249,22 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext() if (m_openGLView) { [m_openGLView setOpenGLContext:m_openGLContext]; [m_openGLContext setView:m_openGLView]; + initClearGL(); } + [m_openGLContext flushBuffer]; + if (s_sharedCount == 0) s_sharedOpenGLContext = m_openGLContext; s_sharedCount++; - initClearGL(); - [m_openGLContext flushBuffer]; - [pool drain]; return GHOST_kSuccess; error: - if (m_openGLView) { - [m_openGLView setOpenGLContext:prev_openGLContext]; - } - [pixelFormat release]; [pool drain]; diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 49e01a983a0..f13c9d470a5 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -762,22 +762,7 @@ GHOST_IWindow *GHOST_SystemCocoa::createWindow(const STR_String &title, */ GHOST_IContext *GHOST_SystemCocoa::createOffscreenContext() { - GHOST_Context *context = new GHOST_ContextCGL(false, - NULL, - NULL, - -#if defined(WITH_GL_PROFILE_CORE) - GL_CONTEXT_CORE_PROFILE_BIT, - 3, - 3, -#else - 0, // no profile bit - 2, - 1, -#endif - GHOST_OPENGL_CGL_CONTEXT_FLAGS, - GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY); - + GHOST_Context *context = new GHOST_ContextCGL(false, NULL); if (context->initializeDrawingContext()) return context; else diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index f257399fc9c..fc4ad3dba74 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -1018,21 +1018,7 @@ GHOST_Context *GHOST_WindowCocoa::newDrawingContext(GHOST_TDrawingContextType ty { if (type == GHOST_kDrawingContextTypeOpenGL) { - GHOST_Context *context = new GHOST_ContextCGL(m_wantStereoVisual, - m_window, - m_openGLView, - -#if defined(WITH_GL_PROFILE_CORE) - GL_CONTEXT_CORE_PROFILE_BIT, - 3, - 3, -#else - 0, // no profile bit - 2, - 1, -#endif - GHOST_OPENGL_CGL_CONTEXT_FLAGS, - GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY); + GHOST_Context *context = new GHOST_ContextCGL(m_wantStereoVisual, m_openGLView); if (context->initializeDrawingContext()) return context; -- cgit v1.2.3