mirror of
https://github.com/mamedev/mame.git
synced 2024-11-16 07:48:32 +01:00
bgfx: fix leak of autoreleased objects and support OS X 10.6 Snow Leopard
This commit is contained in:
parent
d055017fa2
commit
397265f2fc
1 changed files with 22 additions and 0 deletions
22
3rdparty/bgfx/src/glcontext_nsgl.mm
vendored
22
3rdparty/bgfx/src/glcontext_nsgl.mm
vendored
|
@ -7,6 +7,7 @@
|
|||
|
||||
#if BX_PLATFORM_OSX && (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL)
|
||||
# include "renderer_gl.h"
|
||||
# include <AvailabilityMacros.h>
|
||||
# include <Cocoa/Cocoa.h>
|
||||
# include <bx/os.h>
|
||||
|
||||
|
@ -36,6 +37,22 @@ namespace bgfx { namespace gl
|
|||
}
|
||||
};
|
||||
|
||||
class AutoreleasePoolHolder
|
||||
{
|
||||
public:
|
||||
AutoreleasePoolHolder() : pool([[NSAutoreleasePool alloc] init])
|
||||
{
|
||||
}
|
||||
|
||||
~AutoreleasePoolHolder()
|
||||
{
|
||||
[pool release];
|
||||
}
|
||||
|
||||
private:
|
||||
NSAutoreleasePool* pool;
|
||||
};
|
||||
|
||||
static void* s_opengl = NULL;
|
||||
|
||||
void GlContext::create(uint32_t _width, uint32_t _height)
|
||||
|
@ -45,11 +62,13 @@ namespace bgfx { namespace gl
|
|||
s_opengl = bx::dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL");
|
||||
BX_CHECK(NULL != s_opengl, "OpenGL dynamic library is not found!");
|
||||
|
||||
const AutoreleasePoolHolder pool;
|
||||
NSWindow* nsWindow = (NSWindow*)g_bgfxNSWindow;
|
||||
m_context = g_bgfxNSGL;
|
||||
|
||||
if (NULL == g_bgfxNSGL)
|
||||
{
|
||||
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
||||
NSOpenGLPixelFormatAttribute profile =
|
||||
#if BGFX_CONFIG_RENDERER_OPENGL >= 31
|
||||
NSOpenGLProfileVersion3_2Core
|
||||
|
@ -57,9 +76,12 @@ namespace bgfx { namespace gl
|
|||
NSOpenGLProfileVersionLegacy
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
|
||||
;
|
||||
#endif // defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
||||
|
||||
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = {
|
||||
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
||||
NSOpenGLPFAOpenGLProfile, profile,
|
||||
#endif // defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
||||
NSOpenGLPFAColorSize, 24,
|
||||
NSOpenGLPFAAlphaSize, 8,
|
||||
NSOpenGLPFADepthSize, 24,
|
||||
|
|
Loading…
Reference in a new issue