From Alok Priyadarshi, "1. Replaced APIENTRY to GL_APIENTRY which is used by OpenGL ES

headers. For desktop GL GL_APIENTRY has been defined as APIENTRY."
This commit is contained in:
Robert Osfield
2010-04-28 21:22:44 +00:00
parent c019e2f76d
commit a6c7fee246
25 changed files with 433 additions and 415 deletions

View File

@@ -22,16 +22,16 @@ namespace osg
{
#if defined(OSG_GLES1_AVAILABLE)
inline void APIENTRY glColor4ubv(const GLubyte* c) { glColor4ub(c[0], c[1], c[2], c[3]); }
inline void APIENTRY glColor3fv(const GLfloat* c) { glColor4f(c[0], c[1], c[2], 1.0f); }
inline void APIENTRY glColor4fv(const GLfloat* c) { glColor4f(c[0], c[1], c[2], c[3]); }
inline void APIENTRY glColor3dv(const GLdouble* c) { glColor4f(c[0], c[1], c[2], 1.0f); }
inline void APIENTRY glColor4dv(const GLdouble* c) { glColor4f(c[0], c[1], c[2], c[3]); }
inline void GL_APIENTRY glColor4ubv(const GLubyte* c) { glColor4ub(c[0], c[1], c[2], c[3]); }
inline void GL_APIENTRY glColor3fv(const GLfloat* c) { glColor4f(c[0], c[1], c[2], 1.0f); }
inline void GL_APIENTRY glColor4fv(const GLfloat* c) { glColor4f(c[0], c[1], c[2], c[3]); }
inline void GL_APIENTRY glColor3dv(const GLdouble* c) { glColor4f(c[0], c[1], c[2], 1.0f); }
inline void GL_APIENTRY glColor4dv(const GLdouble* c) { glColor4f(c[0], c[1], c[2], c[3]); }
inline void APIENTRY glNormal3bv(const GLbyte* n) { const float div = 1.0f/128.0f; glNormal3f(float(n[0])*div, float(n[1])*div, float(n[3])*div); }
inline void APIENTRY glNormal3sv(const GLshort* n) { const float div = 1.0f/32768.0f; glNormal3f(float(n[0])*div, float(n[1])*div, float(n[3])*div); }
inline void APIENTRY glNormal3fv(const GLfloat* n) { glNormal3f(n[0], n[1], n[3]); }
inline void APIENTRY glNormal3dv(const GLdouble* n) { glNormal3f(n[0], n[1], n[3]); }
inline void GL_APIENTRY glNormal3bv(const GLbyte* n) { const float div = 1.0f/128.0f; glNormal3f(float(n[0])*div, float(n[1])*div, float(n[3])*div); }
inline void GL_APIENTRY glNormal3sv(const GLshort* n) { const float div = 1.0f/32768.0f; glNormal3f(float(n[0])*div, float(n[1])*div, float(n[3])*div); }
inline void GL_APIENTRY glNormal3fv(const GLfloat* n) { glNormal3f(n[0], n[1], n[3]); }
inline void GL_APIENTRY glNormal3dv(const GLdouble* n) { glNormal3f(n[0], n[1], n[3]); }
#endif
template<typename T>
@@ -39,7 +39,7 @@ class TemplateAttributeDispatch : public AttributeDispatch
{
public:
typedef void (APIENTRY * F) (const T*);
typedef void (GL_APIENTRY * F) (const T*);
TemplateAttributeDispatch(F functionPtr, unsigned int stride):
_functionPtr(functionPtr), _stride(stride), _array(0) {}
@@ -64,7 +64,7 @@ class TemplateAttributeWithIndicesDispatch : public AttributeDispatch
{
public:
typedef void (APIENTRY * F) (const T*);
typedef void (GL_APIENTRY * F) (const T*);
TemplateAttributeWithIndicesDispatch(F functionPtr, unsigned int stride):
_functionPtr(functionPtr), _stride(stride), _array(0), _indices(0) {}
@@ -148,7 +148,7 @@ class TemplateTargetAttributeDispatch : public AttributeDispatch
{
public:
typedef void (APIENTRY * F) (I, const T*);
typedef void (GL_APIENTRY * F) (I, const T*);
TemplateTargetAttributeDispatch(I target, F functionPtr, unsigned int stride):
_functionPtr(functionPtr), _target(target), _stride(stride), _array(0) {}
@@ -175,7 +175,7 @@ class TemplateTargetAttributeWithIndicesDispatch : public AttributeDispatch
{
public:
typedef void (APIENTRY * F) (I, const T*);
typedef void (GL_APIENTRY * F) (I, const T*);
TemplateTargetAttributeWithIndicesDispatch(I target, F functionPtr, unsigned int stride):
_functionPtr(functionPtr), _target(target), _stride(stride), _array(0), _indices(0) {}
@@ -265,7 +265,7 @@ public:
_glBeginEndAdapter(glBeginEndAdapter) {}
template<typename T>
void assign(Array::Type type, void (APIENTRY *functionPtr) (const T*), unsigned int stride)
void assign(Array::Type type, void (GL_APIENTRY *functionPtr) (const T*), unsigned int stride)
{
if ((unsigned int)type >= _attributeDispatchList.size()) _attributeDispatchList.resize(type+1);
_attributeDispatchList[type] = functionPtr ? new TemplateAttributeDispatch<T>(functionPtr, stride) : 0;
@@ -275,7 +275,7 @@ public:
}
template<typename I, typename T>
void targetAssign(I target, Array::Type type, void (APIENTRY *functionPtr) (I, const T*), unsigned int stride)
void targetAssign(I target, Array::Type type, void (GL_APIENTRY *functionPtr) (I, const T*), unsigned int stride)
{
if ((unsigned int)type >= _attributeDispatchList.size()) _attributeDispatchList.resize(type+1);
_attributeDispatchList[type] = functionPtr ? new TemplateTargetAttributeDispatch<I,T>(target, functionPtr, stride) : 0;

View File

@@ -38,6 +38,7 @@
#cmakedefine OSG_GL3_AVAILABLE
#cmakedefine OSG_GLES1_AVAILABLE
#cmakedefine OSG_GLES2_AVAILABLE
#cmakedefine OSG_GL_LIBRARY_STATIC
#cmakedefine OSG_GL_DISPLAYLISTS_AVAILABLE
#cmakedefine OSG_GL_MATRICES_AVAILABLE
#cmakedefine OSG_GL_VERTEX_FUNCS_AVAILABLE

View File

@@ -100,7 +100,7 @@ bool osg::isGLExtensionOrVersionSupported(unsigned int contextID, const char *ex
// Get extensions using new indexed string interface.
typedef const GLubyte * APIENTRY PFNGLGETSTRINGIPROC( GLenum, GLuint );
typedef const GLubyte * GL_APIENTRY PFNGLGETSTRINGIPROC( GLenum, GLuint );
PFNGLGETSTRINGIPROC* glGetStringi = 0;
setGLExtensionFuncPtr( glGetStringi, "glGetStringi");
@@ -342,113 +342,121 @@ std::string& osg::getGLExtensionDisableString()
}
#endif
#ifdef OSG_GL_LIBRARY_STATIC
void* osg::getGLExtensionFuncPtr(const char *funcName)
{
OSG_NOTICE<<"osg::getGLExtensionFuncPtr("<<functName") mapping not implemented for static GL lib yet."<<std::endl;
return 0;
}
#if defined(WIN32)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif // WIN32_LEAN_AND_MEAN
#ifndef NOMINMAX
#define NOMINMAX
#endif // NOMINMAX
#include <windows.h>
#elif defined(__APPLE__)
// The NS*Symbol* stuff found in <mach-o/dyld.h> is deprecated.
// Since 10.3 (Panther) OS X has provided the dlopen/dlsym/dlclose
// family of functions under <dlfcn.h>. Since 10.4 (Tiger), Apple claimed
// the dlfcn family was significantly faster than the NS*Symbol* family.
// Since 'deprecated' needs to be taken very seriously with the
// coming of 10.5 (Leopard), it makes sense to use the dlfcn family when possible.
#include <AvailabilityMacros.h>
#if !defined(MAC_OS_X_VERSION_10_3) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3)
#define USE_APPLE_LEGACY_NSSYMBOL
#include <mach-o/dyld.h>
#else
#if defined(WIN32)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif // WIN32_LEAN_AND_MEAN
#ifndef NOMINMAX
#define NOMINMAX
#endif // NOMINMAX
#include <windows.h>
#elif defined(__APPLE__)
// The NS*Symbol* stuff found in <mach-o/dyld.h> is deprecated.
// Since 10.3 (Panther) OS X has provided the dlopen/dlsym/dlclose
// family of functions under <dlfcn.h>. Since 10.4 (Tiger), Apple claimed
// the dlfcn family was significantly faster than the NS*Symbol* family.
// Since 'deprecated' needs to be taken very seriously with the
// coming of 10.5 (Leopard), it makes sense to use the dlfcn family when possible.
#include <AvailabilityMacros.h>
#if !defined(MAC_OS_X_VERSION_10_3) || (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3)
#define USE_APPLE_LEGACY_NSSYMBOL
#include <mach-o/dyld.h>
#else
#include <dlfcn.h>
#endif
#else
#include <dlfcn.h>
#endif
#else
#include <dlfcn.h>
#endif
void* osg::getGLExtensionFuncPtr(const char *funcName)
{
// OSG_NOTIFY(osg::NOTICE)<<"osg::getGLExtensionFuncPtr("<<funcName<<")"<<std::endl;
#if defined(WIN32)
void* osg::getGLExtensionFuncPtr(const char *funcName)
{
// OSG_NOTIFY(osg::NOTICE)<<"osg::getGLExtensionFuncPtr("<<funcName<<")"<<std::endl;
#if defined(OSG_GLES2_AVAILABLE)
static HMODULE hmodule = GetModuleHandle(TEXT("libGLESv2.dll"));
return convertPointerType<void*, PROC>(GetProcAddress(hmodule, funcName));
#elif defined(OSG_GLES1_AVAILABLE)
static HMODULE hmodule = GetModuleHandleA(TEXT("libgles_cm.dll"));
return convertPointerType<void*, PROC>(GetProcAddress(hmodule, funcName));
#else
return convertPointerType<void*, PROC>(wglGetProcAddress(funcName));
#endif
#if defined(WIN32)
#elif defined(__APPLE__)
#if defined(OSG_GLES2_AVAILABLE)
static HMODULE hmodule = GetModuleHandle(TEXT("libGLESv2.dll"));
return convertPointerType<void*, PROC>(GetProcAddress(hmodule, funcName));
#elif defined(OSG_GLES1_AVAILABLE)
static HMODULE hmodule = GetModuleHandleA(TEXT("libgles_cm.dll"));
return convertPointerType<void*, PROC>(GetProcAddress(hmodule, funcName));
#else
return convertPointerType<void*, PROC>(wglGetProcAddress(funcName));
#endif
#if defined(USE_APPLE_LEGACY_NSSYMBOL)
std::string temp( "_" );
temp += funcName; // Mac OS X prepends an underscore on function names
if ( NSIsSymbolNameDefined( temp.c_str() ) )
{
NSSymbol symbol = NSLookupAndBindSymbol( temp.c_str() );
return NSAddressOfSymbol( symbol );
} else
return NULL;
#else
// I am uncertain of the correct and ideal usage of dlsym here.
// On the surface, it would seem that the FreeBSD implementation
// would be the ideal one to copy, but ELF and Mach-o are different
// and Apple's man page says the following about using RTLD_DEFAULT:
// "This can be a costly search and should be avoided."
// The documentation mentions nothing about passing in 0 so I must
// assume the behavior is undefined.
// So I could try copying the Sun method which I think all this
// actually originated from.
#elif defined(__APPLE__)
#if defined(USE_APPLE_LEGACY_NSSYMBOL)
std::string temp( "_" );
temp += funcName; // Mac OS X prepends an underscore on function names
if ( NSIsSymbolNameDefined( temp.c_str() ) )
{
NSSymbol symbol = NSLookupAndBindSymbol( temp.c_str() );
return NSAddressOfSymbol( symbol );
} else
return NULL;
#else
// I am uncertain of the correct and ideal usage of dlsym here.
// On the surface, it would seem that the FreeBSD implementation
// would be the ideal one to copy, but ELF and Mach-o are different
// and Apple's man page says the following about using RTLD_DEFAULT:
// "This can be a costly search and should be avoided."
// The documentation mentions nothing about passing in 0 so I must
// assume the behavior is undefined.
// So I could try copying the Sun method which I think all this
// actually originated from.
// return dlsym( RTLD_DEFAULT, funcName );
static void *handle = dlopen((const char *)0L, RTLD_LAZY);
return dlsym(handle, funcName);
#endif
#elif defined (__sun)
// return dlsym( RTLD_DEFAULT, funcName );
static void *handle = dlopen((const char *)0L, RTLD_LAZY);
return dlsym(handle, funcName);
#elif defined (__sgi)
static void *handle = dlopen((const char *)0L, RTLD_LAZY);
return dlsym(handle, funcName);
#elif defined (__FreeBSD__)
return dlsym( RTLD_DEFAULT, funcName );
#elif defined (__linux__)
typedef void (*__GLXextFuncPtr)(void);
typedef __GLXextFuncPtr (*GetProcAddressARBProc)(const char*);
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
static GetProcAddressARBProc s_glXGetProcAddressARB = convertPointerType<GetProcAddressARBProc, void*>(dlsym(0, "glXGetProcAddressARB"));
if (s_glXGetProcAddressARB)
{
return convertPointerType<void*, __GLXextFuncPtr>((s_glXGetProcAddressARB)(funcName));
}
#endif
return dlsym(0, funcName);
#elif defined (__QNX__)
return dlsym(RTLD_DEFAULT, funcName);
#else // all other unixes
return dlsym(0, funcName);
#endif
#elif defined (__sun)
static void *handle = dlopen((const char *)0L, RTLD_LAZY);
return dlsym(handle, funcName);
#elif defined (__sgi)
static void *handle = dlopen((const char *)0L, RTLD_LAZY);
return dlsym(handle, funcName);
#elif defined (__FreeBSD__)
return dlsym( RTLD_DEFAULT, funcName );
#elif defined (__linux__)
typedef void (*__GLXextFuncPtr)(void);
typedef __GLXextFuncPtr (*GetProcAddressARBProc)(const char*);
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
static GetProcAddressARBProc s_glXGetProcAddressARB = convertPointerType<GetProcAddressARBProc, void*>(dlsym(0, "glXGetProcAddressARB"));
if (s_glXGetProcAddressARB)
{
return convertPointerType<void*, __GLXextFuncPtr>((s_glXGetProcAddressARB)(funcName));
}
#endif
return dlsym(0, funcName);
#elif defined (__QNX__)
return dlsym(RTLD_DEFAULT, funcName);
#else // all other unixes
return dlsym(0, funcName);
#endif
}

View File

@@ -15,7 +15,7 @@
#include <osg/State>
#include <osg/GLU>
typedef void (APIENTRY * MyCompressedTexImage1DArbProc) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (GL_APIENTRY * MyCompressedTexImage1DArbProc) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
using namespace osg;

View File

@@ -2182,7 +2182,7 @@ void GraphicsWindowWin32::setSyncToVBlank( bool on )
// we ought to properly check if the extension is listed as supported rather than just
// if the function pointer resolves through wglGetProcAddress, but in practice everything
// supports this extension
typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int );
typedef BOOL (GL_APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int );
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress( "wglSwapIntervalEXT" );