mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Merge pull request #1014 from ghost91-/mac-fix
Fixed threaded gfx and building on Mac OS X
This commit is contained in:
commit
8f86ce2600
|
@ -11,6 +11,9 @@
|
||||||
|
|
||||||
void CGraphicsBackend_Threaded::ThreadFunc(void *pUser)
|
void CGraphicsBackend_Threaded::ThreadFunc(void *pUser)
|
||||||
{
|
{
|
||||||
|
#ifdef CONF_PLATFORM_MACOSX
|
||||||
|
CAutoreleasePool AutoreleasePool;
|
||||||
|
#endif
|
||||||
CGraphicsBackend_Threaded *pThis = (CGraphicsBackend_Threaded *)pUser;
|
CGraphicsBackend_Threaded *pThis = (CGraphicsBackend_Threaded *)pUser;
|
||||||
|
|
||||||
while(!pThis->m_Shutdown)
|
while(!pThis->m_Shutdown)
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
static void GL_SwapBuffers(const SGLContext &Context) { SwapBuffers(Context.m_hDC); }
|
static void GL_SwapBuffers(const SGLContext &Context) { SwapBuffers(Context.m_hDC); }
|
||||||
#elif defined(CONF_PLATFORM_MACOSX)
|
#elif defined(CONF_PLATFORM_MACOSX)
|
||||||
|
|
||||||
#include <AGL/agl.h>
|
#include <objc/objc-runtime.h>
|
||||||
|
|
||||||
class semaphore
|
class semaphore
|
||||||
{
|
{
|
||||||
|
@ -42,19 +42,57 @@
|
||||||
|
|
||||||
struct SGLContext
|
struct SGLContext
|
||||||
{
|
{
|
||||||
AGLContext m_Context;
|
id m_Context;
|
||||||
};
|
};
|
||||||
|
|
||||||
static SGLContext GL_GetCurrentContext()
|
static SGLContext GL_GetCurrentContext()
|
||||||
{
|
{
|
||||||
SGLContext Context;
|
SGLContext Context;
|
||||||
Context.m_Context = aglGetCurrentContext();
|
Class NSOpenGLContextClass = (Class) objc_getClass("NSOpenGLContext");
|
||||||
|
SEL selector = sel_registerName("currentContext");
|
||||||
|
Context.m_Context = objc_msgSend((objc_object*) NSOpenGLContextClass, selector);
|
||||||
return Context;
|
return Context;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GL_MakeCurrent(const SGLContext &Context) { aglSetCurrentContext(Context.m_Context); }
|
static void GL_MakeCurrent(const SGLContext &Context)
|
||||||
static void GL_ReleaseContext(const SGLContext &Context) { aglSetCurrentContext(NULL); }
|
{
|
||||||
static void GL_SwapBuffers(const SGLContext &Context) { aglSwapBuffers(Context.m_Context); }
|
SEL selector = sel_registerName("makeCurrentContext");
|
||||||
|
objc_msgSend(Context.m_Context, selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GL_ReleaseContext(const SGLContext &Context)
|
||||||
|
{
|
||||||
|
Class NSOpenGLContextClass = (Class) objc_getClass("NSOpenGLContext");
|
||||||
|
SEL selector = sel_registerName("clearCurrentContext");
|
||||||
|
objc_msgSend((objc_object*) NSOpenGLContextClass, selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GL_SwapBuffers(const SGLContext &Context)
|
||||||
|
{
|
||||||
|
SEL selector = sel_registerName("flushBuffer");
|
||||||
|
objc_msgSend(Context.m_Context, selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
class CAutoreleasePool
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
id m_Pool;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CAutoreleasePool()
|
||||||
|
{
|
||||||
|
Class NSAutoreleasePoolClass = (Class) objc_getClass("NSAutoreleasePool");
|
||||||
|
m_Pool = class_createInstance(NSAutoreleasePoolClass, 0);
|
||||||
|
SEL selector = sel_registerName("init");
|
||||||
|
objc_msgSend(m_Pool, selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
~CAutoreleasePool()
|
||||||
|
{
|
||||||
|
SEL selector = sel_registerName("drain");
|
||||||
|
objc_msgSend(m_Pool, selector);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#elif defined(CONF_FAMILY_UNIX)
|
#elif defined(CONF_FAMILY_UNIX)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue