Changeset 9469

Show
Ignore:
Timestamp:
01/08/09 12:19:21 (6 years ago)
Author:
robert
Message:

Added checked from the ARG version of glDraw*Instanced().

Location:
OpenSceneGraph/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osg/GLExtensions

    r9380 r9469  
    7979} 
    8080 
     81/** Return the address of the specified OpenGL function. If not found then 
     82  * check a second function name, if this fails then return NULL as function is 
     83  * not supported by OpenGL library. This is used for checking something 
     84  * like glActiveTexture (which is in OGL1.3) or glActiveTextureARB. 
     85*/ 
     86inline void* getGLExtensionFuncPtr(const char *funcName1, const char *funcName2, const char *funcName3) 
     87{ 
     88    void* ptr = getGLExtensionFuncPtr(funcName1); 
     89    if (ptr) return ptr; 
     90 
     91    ptr = getGLExtensionFuncPtr(funcName2); 
     92    if (ptr) return ptr; 
     93 
     94    return getGLExtensionFuncPtr(funcName3); 
     95} 
     96 
    8197template<typename T, typename R> 
    8298T convertPointerType(R src) 
     
    119135} 
    120136 
     137template<typename T> 
     138bool setGLExtensionFuncPtr(T& t, const char* str1, const char* str2, const char* str3) 
     139{ 
     140    void* data = osg::getGLExtensionFuncPtr(str1,str2,str3); 
     141    if (data) 
     142    { 
     143        memcpy(&t, &data, sizeof(T)); 
     144        return true;         
     145    } 
     146    else 
     147    { 
     148        t = 0; 
     149        return false;         
     150    } 
     151} 
     152 
    121153 
    122154/** Return true if OpenGL "extension" is supported. 
  • OpenSceneGraph/trunk/src/osg/State.cpp

    r9447 r9469  
    757757    setGLExtensionFuncPtr(_glBindBuffer, "glBindBuffer","glBindBufferARB"); 
    758758 
    759     setGLExtensionFuncPtr(_glDrawArraysInstanced, "glDrawArraysInstanced","glDrawArraysInstancedEXT"); 
    760     setGLExtensionFuncPtr(_glDrawElementsInstanced, "glDrawElementsInstanced","glDrawElementsInstancedEXT"); 
     759    setGLExtensionFuncPtr(_glDrawArraysInstanced, "glDrawArraysInstanced","glDrawArraysInstancedARB","glDrawArraysInstancedEXT"); 
     760    setGLExtensionFuncPtr(_glDrawElementsInstanced, "glDrawElementsInstanced","glDrawElementsInstancedARB","glDrawElementsInstancedEXT"); 
    761761 
    762762    if ( osg::getGLVersionNumber() >= 2.0 || osg::isGLExtensionSupported(_contextID,"GL_ARB_vertex_shader") )