diff --git a/Make/makedefs b/Make/makedefs index cc58e6e87..a5a26cf50 100644 --- a/Make/makedefs +++ b/Make/makedefs @@ -232,14 +232,14 @@ endif #### MacOS X specific definitions ifeq ($(OS),Darwin) C++ = cc - INC += -I/usr/include -I/sw/include + INC += -I/usr/include DEF += -Wall -D__DARWIN_OSX__ OPTF = -O2 DBGF = -g DEPARG = -M $(DEF) SHARED = -shared ARCHARGS = - LINKARGS = -L/usr/lib -L/sw/lib + LINKARGS = -L/usr/lib DYNAMICLIBRARYLIB = OSG_LIBS = -losgGLUT -losgGA -losgDB -losgUtil -losg FREETYPE_LIB = -lfreetype @@ -248,18 +248,19 @@ ifeq ($(OS),Darwin) GL_LIBS = -framework OpenGL $(CARBON_LIB) X_LIBS = SOCKET_LIBS = - OTHER_LIBS = -lm -ldl -lstdc++ -lobjc + OTHER_LIBS = -lm -lstdc++ -lobjc LIB_EXT = dylib QUICKTIME = -framework QuickTime $(CARBON_LIB) TIFF_LIB = -ltiff - SRC_DIRS = osg osgUtil osgDB osgPlugins \ - osgGA osgGLUT osgParticle \ + SRC_DIRS = osg osgUtil osgDB \ + osgGA osgGLUT \ + osgPlugins osgParticle \ Demos - # Plugins which require external libs: gif jpeg png + # Plugins which require external libs: gif jpeg png tiff PLUGIN_DIRS = bmp dw flt \ lib3ds logos lwo obj \ osg osgtgz pic \ - quicktime rgb tga tgz tiff \ + quicktime rgb tga tgz \ txp zip # Demos which require external libs: osghud osgtext DEMOS_DIRS = osgbillboard osgcallback osgclip \ diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index 54af58cd9..a4d0029e1 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -1,6 +1,8 @@ #if defined(WIN32) #include -#elif !defined macintosh +#elif defined(__DARWIN_OSX__) +#include +#else #include #endif @@ -62,12 +64,14 @@ void* osg::getGLExtensionFuncPtr(const char *funcName) { #if defined(WIN32) return wglGetProcAddress(funcName); -#else -#if defined( __DARWIN_OSX__ ) - static void *lib = dlopen("libGL.dylib", RTLD_LAZY); +#elif defined(__DARWIN_OSX__) + std::string temp( "_" ); + NSSymbol symbol; + temp += funcName; // Mac OS X prepends an underscore on function names + symbol = NSLookupAndBindSymbol( temp.c_str() ); + return NSAddressOfSymbol( symbol ); #else // all other unixes static void *lib = dlopen("libGL.so", RTLD_LAZY); -#endif if (lib) return dlsym(lib, funcName); else diff --git a/src/osgDB/DynamicLibrary.cpp b/src/osgDB/DynamicLibrary.cpp index 922b84b76..3dfebf383 100644 --- a/src/osgDB/DynamicLibrary.cpp +++ b/src/osgDB/DynamicLibrary.cpp @@ -2,7 +2,9 @@ #include #include #include -#elif !defined(macintosh) +#elif defined(__DARWIN_OSX__) +#include +#else // all other unix #include #include #endif @@ -27,7 +29,9 @@ DynamicLibrary::~DynamicLibrary() { #if defined(WIN32) && !defined(__CYGWIN__) FreeLibrary((HMODULE)_handle); -#elif !defined(macintosh) +#elif defined(__DARWIN_OSX__) + NSUnLinkModule(_handle, FALSE); +#else // other unix dlclose(_handle); #endif } @@ -43,7 +47,18 @@ DynamicLibrary* DynamicLibrary::loadLibrary(const std::string& libraryName) HANDLE handle = LoadLibrary( fullLibraryName.c_str() ); if (handle) return osgNew DynamicLibrary(libraryName,handle); notify(WARN) << "DynamicLibrary::failed loading "< +#if 0 // defined(__DARWIN_OSX__) +#include "FileUtils_Mac.cpp" // this is not functional yet -- fix! #else -// implementations for Windows and all Unix's except Mac when TARGET_API_MAC_CARBON defined. +// currently this impl is for _all_ platforms, execpt as defined. +// the mac version will change soon to reflect the path scheme under osx, but +// for now, the above include is commented out, and the below code takes precedence. #if defined(WIN32) && !defined(__CYGWIN__) #include @@ -10,10 +12,8 @@ #include // set up for windows so acts just like unix access(). #define F_OK 4 -#else - // unix. +#else // unix #include - #include #endif #include