[GLExtensions] Remove AGL GetProcAddress. Change dlsym to using RTLD_NEXT. Enable dlsym fallback for OS X

This commit is contained in:
Ryan Houdek 2014-01-06 22:16:03 -06:00 committed by degasus
parent ca96274936
commit 34c9a33807
3 changed files with 2 additions and 32 deletions

View File

@ -21,37 +21,16 @@
#include "ConfigManager.h" #include "ConfigManager.h"
#include <wx/panel.h> #include <wx/panel.h>
#import <mach-o/dyld.h>
#include "VertexShaderManager.h" #include "VertexShaderManager.h"
#include "../GLInterface.h" #include "../GLInterface.h"
#include "AGL.h" #include "AGL.h"
// Copied from
// https://developer.apple.com/library/mac/documentation/graphicsimaging/conceptual/opengl-macprogguide/opengl_entrypts/opengl_entrypts.html
void* NSGLGetProcAddress (const char *name)
{
NSSymbol symbol;
char* symbolName;
symbolName = (char*)malloc(strlen (name) + 2); // 1
strcpy(symbolName + 1, name); // 2
symbolName[0] = '_'; // 3
symbol = NULL;
if (NSIsSymbolNameDefined (symbolName)) // 4
symbol = NSLookupAndBindSymbol (symbolName);
free (symbolName); // 5
return symbol ? NSAddressOfSymbol (symbol) : NULL; // 6
}
void cInterfaceAGL::Swap() void cInterfaceAGL::Swap()
{ {
[GLWin.cocoaCtx flushBuffer]; [GLWin.cocoaCtx flushBuffer];
} }
void* cInterfaceAGL::GetProcAddress(std::string name)
{
return NSGLGetProcAddress(name.c_str());
}
// Create rendering window. // Create rendering window.
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize() // Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool cInterfaceAGL::Create(void *&window_handle) bool cInterfaceAGL::Create(void *&window_handle)

View File

@ -27,7 +27,6 @@ class cInterfaceAGL : public cInterfaceBase
{ {
public: public:
void Swap(); void Swap();
void* GetProcAddress(std::string name);
bool Create(void *&window_handle); bool Create(void *&window_handle);
bool MakeCurrent(); bool MakeCurrent();
bool ClearCurrent(); bool ClearCurrent();

View File

@ -773,7 +773,6 @@ PFNGLNAMEDBUFFERSTORAGEEXTPROC glNamedBufferStorageEXT;
namespace GLExtensions namespace GLExtensions
{ {
// Private members and functions // Private members and functions
void *_dlsym;
bool _isES3; bool _isES3;
bool _isES; bool _isES;
u32 _GLVersion; u32 _GLVersion;
@ -846,10 +845,9 @@ namespace GLExtensions
*func = GLInterface->GetProcAddress(name); *func = GLInterface->GetProcAddress(name);
if (*func == NULL) if (*func == NULL)
{ {
#if defined(__linux__) #if defined(__linux__) || defined(__APPLE__)
// Give it a second try with dlsym // Give it a second try with dlsym
if (_dlsym) // Just in case dlopen fails *func = dlsym(RTLD_NEXT, name.c_str());
*func = dlsym(_dlsym, name.c_str());
#endif #endif
if (*func == NULL && _isES) if (*func == NULL && _isES)
*func = (void*)0xFFFFFFFF; // Easy to determine invalid function, just so we continue on *func = (void*)0xFFFFFFFF; // Easy to determine invalid function, just so we continue on
@ -869,9 +867,6 @@ namespace GLExtensions
bool Init() bool Init()
{ {
bool success = true; bool success = true;
#if defined(__linux__)
_dlsym = dlopen(NULL, RTLD_LAZY);
#endif
_isES3 = GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3; _isES3 = GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3;
_isES = GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3 || GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES2; _isES = GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES3 || GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGLES2;
@ -913,9 +908,6 @@ namespace GLExtensions
if (success && !init_khr_debug()) success = false; if (success && !init_khr_debug()) success = false;
if (success && !init_arb_buffer_storage()) success = false; if (success && !init_arb_buffer_storage()) success = false;
#if defined(__linux__)
dlclose(_dlsym);
#endif
return success; return success;
} }