Intoduced a new setGLExtensions template method to do a copy of void* pointer to

local function pointer to avoid compiler warnings related to case void*.

Moved various OSG classes across to using setGLExtensions instead of getGLExtensions,
and changed them to use typedef declarations in the headers rather than casts in
the .cpp.

Updated wrappers
This commit is contained in:
Robert Osfield
2007-09-10 15:19:23 +00:00
parent b9a4752694
commit 409cdd0b28
31 changed files with 259 additions and 213 deletions

View File

@@ -68,6 +68,40 @@ inline void* getGLExtensionFuncPtr(const char *funcName,const char *fallbackFunc
return getGLExtensionFuncPtr(fallbackFuncName);
}
template<typename T>
bool setGLExtensionFuncPtr(T& t, const char* str1)
{
void* data = osg::getGLExtensionFuncPtr(str1);
if (data)
{
memcpy(&t, &data, sizeof(T));
return false;
}
else
{
t = 0;
return false;
}
}
template<typename T>
bool setGLExtensionFuncPtr(T& t, const char* str1, const char* str2)
{
void* data = osg::getGLExtensionFuncPtr(str1,str2);
if (data)
{
memcpy(&t, &data, sizeof(T));
return false;
}
else
{
t = 0;
return false;
}
}
/** Return true if OpenGL "extension" is supported.
* Note: Must only be called within a valid OpenGL context,
* undefined behavior may occur otherwise.