diff --git a/desmume/src/cocoa/OGLDisplayOutput.cpp b/desmume/src/cocoa/OGLDisplayOutput.cpp index 5923aaf7c..30d5d2730 100644 --- a/desmume/src/cocoa/OGLDisplayOutput.cpp +++ b/desmume/src/cocoa/OGLDisplayOutput.cpp @@ -3820,7 +3820,6 @@ OGLInfo::OGLInfo() _shaderSupport = ShaderSupport_Unsupported; _useShader150 = false; - _isShaderSupported = false; _isVBOSupported = false; _isPBOSupported = false; _isFBOSupported = false; @@ -3848,7 +3847,7 @@ bool OGLInfo::IsPBOSupported() bool OGLInfo::IsShaderSupported() { - return this->_isShaderSupported; + return (this->_shaderSupport != ShaderSupport_Unsupported); } bool OGLInfo::IsFBOSupported() @@ -3867,19 +3866,11 @@ OGLInfo_Legacy::OGLInfo_Legacy() _isVBOSupported = this->IsExtensionPresent(oglExtensionSet, "GL_ARB_vertex_buffer_object"); -#if !defined(GL_ARB_shader_objects) || \ - !defined(GL_ARB_vertex_shader) || \ - !defined(GL_ARB_fragment_shader) || \ - !defined(GL_ARB_vertex_program) - - _isShaderSupported = false; -#else - _isShaderSupported = this->IsExtensionPresent(oglExtensionSet, "GL_ARB_shader_objects") && - this->IsExtensionPresent(oglExtensionSet, "GL_ARB_vertex_shader") && - this->IsExtensionPresent(oglExtensionSet, "GL_ARB_fragment_shader") && - this->IsExtensionPresent(oglExtensionSet, "GL_ARB_vertex_program"); - - if (_isShaderSupported) + bool isShaderSupported = this->IsExtensionPresent(oglExtensionSet, "GL_ARB_shader_objects") && + this->IsExtensionPresent(oglExtensionSet, "GL_ARB_vertex_shader") && + this->IsExtensionPresent(oglExtensionSet, "GL_ARB_fragment_shader") && + this->IsExtensionPresent(oglExtensionSet, "GL_ARB_vertex_program"); + if (isShaderSupported) { if ( _versionMajor < 3 || (_versionMajor == 3 && _versionMinor < 2) ) @@ -3947,22 +3938,12 @@ OGLInfo_Legacy::OGLInfo_Legacy() } } } -#endif -#if !defined(GL_ARB_pixel_buffer_object) && !defined(GL_EXT_pixel_buffer_object) - _isPBOSupported = false; -#else _isPBOSupported = this->IsExtensionPresent(oglExtensionSet, "GL_ARB_vertex_buffer_object") && (this->IsExtensionPresent(oglExtensionSet, "GL_ARB_pixel_buffer_object") || this->IsExtensionPresent(oglExtensionSet, "GL_EXT_pixel_buffer_object")); -#endif - // Don't use ARB versions since we're using the EXT versions for backwards compatibility. -#if !defined(GL_EXT_framebuffer_object) - _isFBOSupported = false; -#else _isFBOSupported = this->IsExtensionPresent(oglExtensionSet, "GL_EXT_framebuffer_object"); -#endif } void OGLInfo_Legacy::GetExtensionSetOGL(std::set *oglExtensionSet) @@ -4715,6 +4696,7 @@ OGLImage::OGLImage(OGLInfo *oglInfo, GLsizei imageWidth, GLsizei imageHeight, GL _pixelScaler = VideoFilterTypeID_None; _useShader150 = oglInfo->IsUsingShader150(); _shaderSupport = oglInfo->GetShaderSupport(); + _canUseShaderOutput = oglInfo->IsShaderSupported(); if (_canUseShaderOutput) { @@ -4734,7 +4716,7 @@ OGLImage::OGLImage(OGLInfo *oglInfo, GLsizei imageWidth, GLsizei imageHeight, GL _finalOutputProgram = NULL; } - _canUseShaderBasedFilters = (_canUseShaderOutput && oglInfo->IsFBOSupported()); + _canUseShaderBasedFilters = (oglInfo->IsShaderSupported() && oglInfo->IsFBOSupported()); if (_canUseShaderBasedFilters) { _filterDeposterize = new OGLFilterDeposterize(_vf->GetSrcWidth(), _vf->GetSrcHeight(), _shaderSupport, _useShader150); diff --git a/desmume/src/cocoa/OGLDisplayOutput.h b/desmume/src/cocoa/OGLDisplayOutput.h index 9c726063f..4cbd92a0f 100644 --- a/desmume/src/cocoa/OGLDisplayOutput.h +++ b/desmume/src/cocoa/OGLDisplayOutput.h @@ -65,7 +65,6 @@ protected: bool _isVBOSupported; bool _isPBOSupported; - bool _isShaderSupported; bool _isFBOSupported; public: diff --git a/desmume/src/cocoa/OGLDisplayOutput_3_2.cpp b/desmume/src/cocoa/OGLDisplayOutput_3_2.cpp index 43ca6dce2..a7e478648 100644 --- a/desmume/src/cocoa/OGLDisplayOutput_3_2.cpp +++ b/desmume/src/cocoa/OGLDisplayOutput_3_2.cpp @@ -46,7 +46,6 @@ void glGenVertexArrays_3_2(GLsizei n, GLuint *vaoIDs) OGLInfo_3_2::OGLInfo_3_2() { _useShader150 = true; - _isShaderSupported = true; _isVBOSupported = true; _isPBOSupported = true; _isFBOSupported = true; diff --git a/desmume/src/cocoa/userinterface/DisplayWindowController.mm b/desmume/src/cocoa/userinterface/DisplayWindowController.mm index 2b49e0aa0..4d227617a 100644 --- a/desmume/src/cocoa/userinterface/DisplayWindowController.mm +++ b/desmume/src/cocoa/userinterface/DisplayWindowController.mm @@ -1316,8 +1316,6 @@ static std::unordered_map _screenMap; // (NSOpenGLPixelFormatAttribute)0, (NSOpenGLPixelFormatAttribute)0, (NSOpenGLPixelFormatAttribute)0 }; - NSOpenGLPixelFormat *format = nil; - #ifdef _OGLDISPLAYOUTPUT_3_2_H_ // If we can support a 3.2 Core Profile context, then request that in our // pixel format attributes. @@ -1326,20 +1324,14 @@ static std::unordered_map _screenMap; // attributes[9] = NSOpenGLPFAOpenGLProfile; attributes[10] = NSOpenGLProfileVersion3_2Core; OGLInfoCreate_Func = &OGLInfoCreate_3_2; - format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; - - if (format == nil) - { - attributes[9] = NSOpenGLPFAOpenGLProfile; - attributes[10] = NSOpenGLProfileVersionLegacy; - OGLInfoCreate_Func = &OGLInfoCreate_Legacy; - format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; - } } #endif + NSOpenGLPixelFormat *format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; if (format == nil) { + // If we can't get a 3.2 Core Profile context, then switch to using a + // legacy context instead. attributes[9] = (NSOpenGLPixelFormatAttribute)0; attributes[10] = (NSOpenGLPixelFormatAttribute)0; OGLInfoCreate_Func = &OGLInfoCreate_Legacy; diff --git a/desmume/src/cocoa/userinterface/preferencesWindowDelegate.mm b/desmume/src/cocoa/userinterface/preferencesWindowDelegate.mm index 9f806d4a5..994422ea2 100644 --- a/desmume/src/cocoa/userinterface/preferencesWindowDelegate.mm +++ b/desmume/src/cocoa/userinterface/preferencesWindowDelegate.mm @@ -58,7 +58,6 @@ NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)8, NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)0, NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)0, - NSOpenGLPFADoubleBuffer, (NSOpenGLPixelFormatAttribute)0, (NSOpenGLPixelFormatAttribute)0, (NSOpenGLPixelFormatAttribute)0 }; @@ -67,14 +66,23 @@ // pixel format attributes. if (IsOSXVersionSupported(10, 7, 0)) { - attributes[9] = kCGLPFAOpenGLProfile; - attributes[10] = (CGLPixelFormatAttribute)kCGLOGLPVersion_3_2_Core; - + attributes[8] = NSOpenGLPFAOpenGLProfile; + attributes[9] = NSOpenGLProfileVersion3_2Core; OGLInfoCreate_Func = &OGLInfoCreate_3_2; } #endif NSOpenGLPixelFormat *format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; + if (format == nil) + { + // If we can't get a 3.2 Core Profile context, then switch to using a + // legacy context instead. + attributes[8] = (NSOpenGLPixelFormatAttribute)0; + attributes[9] = (NSOpenGLPixelFormatAttribute)0; + OGLInfoCreate_Func = &OGLInfoCreate_Legacy; + format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; + } + context = [[NSOpenGLContext alloc] initWithFormat:format shareContext:nil]; [format release]; cglDisplayContext = (CGLContextObj)[context CGLContextObj]; @@ -230,7 +238,7 @@ CGLContextObj prevContext = CGLGetCurrentContext(); CGLSetCurrentContext(cglDisplayContext); oglImage->RenderOGL(); - CGLFlushDrawable(cglDisplayContext); + glFlush(); CGLSetCurrentContext(prevContext); }