Moved osg::BlenFunc::Extensions into osg::GL2Extensions

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14571 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2014-12-04 19:03:16 +00:00
parent d02c0bdc49
commit d83e641fad
5 changed files with 22 additions and 28 deletions

View File

@ -157,19 +157,6 @@ class OSG_EXPORT BlendFunc : public StateAttribute
virtual void apply(State& state) const; 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 : protected :
virtual ~BlendFunc(); virtual ~BlendFunc();

View File

@ -742,6 +742,15 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
void (GL_APIENTRY * glMemoryBarrier)( GLbitfield barriers ); 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) ;
}; };
} }

View File

@ -17,19 +17,6 @@
using namespace osg; 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(): BlendFunc::BlendFunc():
_source_factor(SRC_ALPHA), _source_factor(SRC_ALPHA),
_destination_factor(ONE_MINUS_SRC_ALPHA), _destination_factor(ONE_MINUS_SRC_ALPHA),
@ -63,7 +50,7 @@ void BlendFunc::apply(State& state) const
if (_source_factor != _source_factor_alpha || if (_source_factor != _source_factor_alpha ||
_destination_factor != _destination_factor_alpha) _destination_factor != _destination_factor_alpha)
{ {
const Extensions* extensions = state.get<Extensions>(); const GL2Extensions* extensions = state.get<GL2Extensions>();
if (!extensions->isBlendFuncSeparateSupported) if (!extensions->isBlendFuncSeparateSupported)
{ {
OSG_WARN<<"Warning: BlendFunc::apply(..) failed, BlendFuncSeparate is not support by OpenGL driver, falling back to BlendFunc."<<std::endl; OSG_WARN<<"Warning: BlendFunc::apply(..) failed, BlendFuncSeparate is not support by OpenGL driver, falling back to BlendFunc."<<std::endl;

View File

@ -28,7 +28,7 @@ BlendFunci::~BlendFunci()
void BlendFunci::apply(State& state) const void BlendFunci::apply(State& state) const
{ {
const Extensions* extensions = state.get<Extensions>(); const GL2Extensions* extensions = state.get<GL2Extensions>();
if (_source_factor != _source_factor_alpha || if (_source_factor != _source_factor_alpha ||
_destination_factor != _destination_factor_alpha) _destination_factor != _destination_factor_alpha)
{ {

View File

@ -274,6 +274,7 @@ GL2Extensions::GL2Extensions(unsigned int contextID)
setGLExtensionFuncPtr(glMemoryBarrier, "glMemoryBarrier", "glMemoryBarrierEXT" ); setGLExtensionFuncPtr(glMemoryBarrier, "glMemoryBarrier", "glMemoryBarrierEXT" );
// BufferObject extensions
setGLExtensionFuncPtr(glGenBuffers, "glGenBuffers","glGenBuffersARB"); setGLExtensionFuncPtr(glGenBuffers, "glGenBuffers","glGenBuffersARB");
setGLExtensionFuncPtr(glBindBuffer, "glBindBuffer","glBindBufferARB"); setGLExtensionFuncPtr(glBindBuffer, "glBindBuffer","glBindBufferARB");
setGLExtensionFuncPtr(glBufferData, "glBufferData","glBufferDataARB"); setGLExtensionFuncPtr(glBufferData, "glBufferData","glBufferDataARB");
@ -295,6 +296,16 @@ GL2Extensions::GL2Extensions(unsigned int contextID)
isTBOSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_texture_buffer_object"); 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");
} }