diff --git a/include/osg/BlendFunc b/include/osg/BlendFunc index ac5dbe2ce..0c30ce08c 100644 --- a/include/osg/BlendFunc +++ b/include/osg/BlendFunc @@ -157,19 +157,6 @@ class OSG_EXPORT BlendFunc : public StateAttribute virtual void apply(State& state) const; - /** Encapsulates queries of extension availability, obtains extension function pointers. */ - struct OSG_EXPORT Extensions : public osg::Referenced - { - Extensions(unsigned int contextID); - - bool isBlendFuncSeparateSupported; - void (GL_APIENTRY * glBlendFuncSeparate) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) ; - - void (GL_APIENTRY * glBlendFunci) (GLuint buf, GLenum src, GLenum dst); - void (GL_APIENTRY * glBlendFuncSeparatei) (GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) ; - }; - - protected : virtual ~BlendFunc(); diff --git a/include/osg/GL2Extensions b/include/osg/GL2Extensions index 995036967..4c1512368 100644 --- a/include/osg/GL2Extensions +++ b/include/osg/GL2Extensions @@ -742,6 +742,15 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced void (GL_APIENTRY * glMemoryBarrier)( GLbitfield barriers ); + // BlendFunc extensions + bool isBlendFuncSeparateSupported; + void (GL_APIENTRY * glBlendFuncSeparate) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) ; + + void (GL_APIENTRY * glBlendFunci) (GLuint buf, GLenum src, GLenum dst); + void (GL_APIENTRY * glBlendFuncSeparatei) (GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) ; + + + }; } diff --git a/src/osg/BlendFunc.cpp b/src/osg/BlendFunc.cpp index 99169ff9b..7c07c67a8 100644 --- a/src/osg/BlendFunc.cpp +++ b/src/osg/BlendFunc.cpp @@ -17,19 +17,6 @@ using namespace osg; -// Set up extensions -BlendFunc::Extensions::Extensions(unsigned int contextID) -{ - isBlendFuncSeparateSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || - osg::isGLExtensionSupported(contextID, "GL_EXT_blend_func_separate") || - strncmp((const char*)glGetString(GL_VERSION), "1.4", 3) >= 0; - - setGLExtensionFuncPtr(glBlendFuncSeparate, "glBlendFuncSeparate", "glBlendFuncSeparateEXT"); - - setGLExtensionFuncPtr(glBlendFunci, "glBlendFunci", "glBlendFunciARB"); - setGLExtensionFuncPtr(glBlendFuncSeparatei, "glBlendFuncSeparatei", "glBlendFuncSeparateiARB"); -} - BlendFunc::BlendFunc(): _source_factor(SRC_ALPHA), _destination_factor(ONE_MINUS_SRC_ALPHA), @@ -63,7 +50,7 @@ void BlendFunc::apply(State& state) const if (_source_factor != _source_factor_alpha || _destination_factor != _destination_factor_alpha) { - const Extensions* extensions = state.get(); + const GL2Extensions* extensions = state.get(); if (!extensions->isBlendFuncSeparateSupported) { OSG_WARN<<"Warning: BlendFunc::apply(..) failed, BlendFuncSeparate is not support by OpenGL driver, falling back to BlendFunc."<(); + const GL2Extensions* extensions = state.get(); if (_source_factor != _source_factor_alpha || _destination_factor != _destination_factor_alpha) { diff --git a/src/osg/GL2Extensions.cpp b/src/osg/GL2Extensions.cpp index 1b5f8df03..1ad95ac7a 100644 --- a/src/osg/GL2Extensions.cpp +++ b/src/osg/GL2Extensions.cpp @@ -274,6 +274,7 @@ GL2Extensions::GL2Extensions(unsigned int contextID) setGLExtensionFuncPtr(glMemoryBarrier, "glMemoryBarrier", "glMemoryBarrierEXT" ); + // BufferObject extensions setGLExtensionFuncPtr(glGenBuffers, "glGenBuffers","glGenBuffersARB"); setGLExtensionFuncPtr(glBindBuffer, "glBindBuffer","glBindBufferARB"); setGLExtensionFuncPtr(glBufferData, "glBufferData","glBufferDataARB"); @@ -295,6 +296,16 @@ GL2Extensions::GL2Extensions(unsigned int contextID) isTBOSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_texture_buffer_object"); + // BlendFunc extensions + isBlendFuncSeparateSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || + osg::isGLExtensionSupported(contextID, "GL_EXT_blend_func_separate") || + strncmp((const char*)glGetString(GL_VERSION), "1.4", 3) >= 0; + + setGLExtensionFuncPtr(glBlendFuncSeparate, "glBlendFuncSeparate", "glBlendFuncSeparateEXT"); + + setGLExtensionFuncPtr(glBlendFunci, "glBlendFunci", "glBlendFunciARB"); + setGLExtensionFuncPtr(glBlendFuncSeparatei, "glBlendFuncSeparatei", "glBlendFuncSeparateiARB"); + }