Cleanup: remove unused macOS GHOST OpenGL code

This commit is contained in:
Brecht Van Lommel 2019-05-24 00:44:32 +02:00
parent 04ad9eab6e
commit 76019139f6
Notes: blender-bot 2023-06-26 11:58:59 +02:00
Referenced by issue #58127, MacOS OpenGL error in initializing offscreen context
4 changed files with 13 additions and 123 deletions

View File

@ -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.

View File

@ -27,47 +27,20 @@
#include <Cocoa/Cocoa.h>
//#define GHOST_MULTITHREADED_OPENGL
#ifdef GHOST_MULTITHREADED_OPENGL
# include <OpenGL/OpenGL.h>
#endif
#include <vector>
#include <cassert>
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<NSOpenGLPixelFormatAttribute> 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];

View File

@ -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

View File

@ -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;