Horde3D http://www.horde3d.org/forums/ |
|
Mac OS X enhancements http://www.horde3d.org/forums/viewtopic.php?f=3&t=1513 |
Page 1 of 1 |
Author: | jacereda [ 22.04.2011, 20:59 ] |
Post subject: | Mac OS X enhancements |
The following patch simplifies platGetProcAddress() in utOpenGL.cpp: Code: Index: Horde3D/Source/Horde3DEngine/utOpenGL.cpp
=================================================================== --- Horde3D/Source/Horde3DEngine/utOpenGL.cpp (revision 763) +++ Horde3D/Source/Horde3DEngine/utOpenGL.cpp (working copy) @@ -15,7 +15,11 @@ #include <cstdlib> #include <cstring> +#if defined PLATFORM_MAC +#include <dlfcn.h> +#endif + namespace glExt { bool EXT_framebuffer_object = false; @@ -239,18 +243,7 @@ #elif defined( PLATFORM_WIN_CE ) return (void *)eglGetProcAddress( funcName ); #elif defined( PLATFORM_MAC ) - CFStringRef functionName = CFStringCreateWithCString( kCFAllocatorDefault, funcName, kCFStringEncodingASCII ); - CFURLRef bundleURL = CFURLCreateWithFileSystemPath( - kCFAllocatorDefault, CFSTR( "/System/Library/Frameworks/OpenGL.framework" ), kCFURLPOSIXPathStyle, true ); - CFBundleRef bundle = CFBundleCreate( kCFAllocatorDefault, bundleURL ); - - void *function = CFBundleGetFunctionPointerForName( bundle, functionName ); - - CFRelease( bundle ); - CFRelease( bundleURL ); - CFRelease( functionName ); - - return function; + return dlsym(RTLD_DEFAULT, funcName); #else return (void *)glXGetProcAddressARB( (const GLubyte *)funcName ); #endif Index: Horde3D/Source/Horde3DEngine/utOpenGL.h =================================================================== --- Horde3D/Source/Horde3DEngine/utOpenGL.h (revision 763) +++ Horde3D/Source/Horde3DEngine/utOpenGL.h (working copy) @@ -37,9 +37,7 @@ # define GLAPI # define GLAPIENTRY # define GLAPIENTRYP * -# ifdef PLATFORM_MAC -# include <Carbon/Carbon.h> -# else +# ifndef PLATFORM_MAC extern "C" void (*glXGetProcAddressARB( const unsigned char *procName ))( void ); # endif #endif |
Author: | marciano [ 25.04.2011, 18:14 ] |
Post subject: | Re: Mac OS X enhancements |
Thanks, that looks a lot nicer. I'm not working on OSX but looking at the man pages, there is a performance warning for RTLD_DEFAULT as it can search through a lot of libs. Not sure if it will really make a noticeable difference, I guess someone would have to profile it before we change the code. |
Author: | jacereda [ 26.04.2011, 13:54 ] | ||
Post subject: | Re: Mac OS X enhancements | ||
What about this?
|
Author: | johannes [ 07.05.2011, 21:23 ] |
Post subject: | Re: Mac OS X enhancements |
While we're at it - here are some warnings that the latest XCode (or rather LLVM GCC 4.2) spews with the current Trunk: Quote: /[...]/Source/Horde3DEngine/egMain.cpp /[...]/Source/Horde3DEngine/egMain.cpp:39: warning: 'void __ValidatePlatform__()' defined but not used /[...]/Source/Horde3DEngine/egRendererBase.cpp /[...]/Source/Horde3DEngine/egRendererBase.cpp:103: warning: unused variable 'time' /[...]/Source/Horde3DEngine/egRendererBase.cpp:428: warning: enumeration value 'Unknown' not handled in switch /[...]/Source/Horde3DEngine/egRendererBase.cpp:428: warning: enumeration value 'BGRA8' not handled in switch /[...]/Source/Horde3DEngine/egRendererBase.cpp:428: warning: enumeration value 'DXT1' not handled in switch /[...]/Source/Horde3DEngine/egRendererBase.cpp:428: warning: enumeration value 'DXT3' not handled in switch /[...]/Source/Horde3DEngine/egRendererBase.cpp:428: warning: enumeration value 'DXT5' not handled in switch /[...]/Source/Horde3DEngine/egRendererBase.cpp:1122: warning: unused variable 'error' /[...]/Source/Horde3DEngine/egRenderer.cpp /[...]/Source/Horde3DEngine/egRenderer.cpp:114: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egRenderer.cpp:120: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egRenderer.cpp:120: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egRenderer.cpp:131: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egRenderer.cpp:131: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egRenderer.cpp:131: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egRenderer.cpp:131: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egRenderer.cpp:131: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egRenderer.cpp:131: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egRenderer.cpp:131: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egRenderer.cpp:137: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egRenderer.cpp:137: warning: missing braces around initializer for 'Horde3D::VertexLayoutAttrib' /[...]/Source/Horde3DEngine/egScene.cpp /[...]/Source/Horde3DEngine/egScene.cpp:379: warning: enumeration value 'None' not handled in switch /[...]/Source/Horde3DEngine/utOpenGL.cpp /[...]/Source/Horde3DEngine/utOpenGL.cpp:13:1: warning: "_CRT_SECURE_NO_WARNINGS" redefined The "_CRT_SECURE_NO_WARNINGS" redefinition is my fault since I manually add that externally via CMake - I can live with that and don't think an extra #ifdef is really necessary. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |