Horde3D

Next-Generation Graphics Engine
It is currently 28.03.2024, 10:12

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Mac OS X enhancements
PostPosted: 22.04.2011, 20:59 
Offline

Joined: 17.04.2011, 15:13
Posts: 8
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


Top
 Profile  
Reply with quote  
PostPosted: 25.04.2011, 18:14 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
PostPosted: 26.04.2011, 13:54 
Offline

Joined: 17.04.2011, 15:13
Posts: 8
What about this?


Attachments:
getprocaddress.patch [1.17 KiB]
Downloaded 1111 times
Top
 Profile  
Reply with quote  
PostPosted: 07.05.2011, 21:23 
Offline

Joined: 22.06.2010, 19:21
Posts: 26
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group