Update of /cvsroot/simspark/simspark/spark/kerosin/openglserver
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv19820
Modified Files:
Tag: WIN32
openglserver.cpp
Log Message:
- added implementation of NSGLGetProcAddress, the MacOS version of glXGetProcAddressARB()
- in GetExtension(), call NSGLGetProcAddress for MacOS platforms
- for MacOS, OpenGLServer::glActiveTextureARB() has just to call glActiveTextureARB(). Maybe there should be a fix for checking the availability of this function... (?)
Index: openglserver.cpp
===================================================================
RCS file: /cvsroot/simspark/simspark/spark/kerosin/openglserver/openglserver.cpp,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** openglserver.cpp 23 Feb 2007 19:19:15 -0000 1.1.2.2
--- openglserver.cpp 28 Feb 2007 04:33:22 -0000 1.1.2.3
***************
*** 29,32 ****
--- 29,51 ----
using namespace std;
+ #ifdef __APPLE__
+ // code below from http://developer.apple.com/qa/qa2001/qa1188.html
+ #import <mach-o/dyld.h>
+ void *NSGLGetProcAddress(const char *name)
+ {
+ NSSymbol symbol;
+ char *symbolName;
+ // Prepend a '_' for the Unix C symbol mangling convention
+ symbolName = (char*) malloc (strlen (name) + 2);
+ strcpy(symbolName + 1, name);
+ symbolName[0] = '_';
+ symbol = NULL;
+ if (NSIsSymbolNameDefined (symbolName))
+ symbol = NSLookupAndBindSymbol (symbolName);
+ free (symbolName);
+ return symbol ? NSAddressOfSymbol (symbol) : NULL;
+ }
+ #endif
+
namespace kerosin
{
***************
*** 154,161 ****
--- 173,185 ----
}
+ // Maybe see also http://rainwarrior.thenoos.net/dragon/sdl_glsl.html
+ // and http://www.evl.uic.edu/arao/cs594/sdlglsl.html to rework the stuff here more platform independently
+ // The code below uses stuff from the apple developer website (hidden in openglwrapper.h)
void* OpenGLServer::GetExtension(const char* name)
{
#ifdef WIN32
return wglGetProcAddress(name);
+ #elif defined(__APPLE__)
+ return NSGLGetProcAddress(name);
#else
return glXGetProcAddressARB((unsigned char*)name);
***************
*** 168,171 ****
--- 192,199 ----
void OpenGLServer::glActiveTextureARB(unsigned int texture)
{
+ #ifdef __APPLE__
+ // this is ugly, but I don't know where are the function prototypes in mac os X?
+ return ::glActiveTextureARB(texture);
+ #else
PROC_ADDRESS(PFNGLACTIVETEXTUREARBPROC, "glActiveTextureARB");
***************
*** 176,178 ****
--- 204,207 ----
(proc)(static_cast<GLenum>(texture));
+ #endif
}
|