Moved GL2Extensions functionality into the include/osg/GLExtensions header and new GLExtensions object.

Moved the #defines into new include/osg/GLDefines
Converted all GL2Extensions usage to GLExtensions usage


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14593 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-12-10 10:38:12 +00:00
parent 09205544b7
commit 485709f708
66 changed files with 1355 additions and 155 deletions

View File

@@ -196,7 +196,7 @@ void ArrayDispatchers::init()
#ifdef OSG_GL_VERTEX_FUNCS_AVAILABLE
GL2Extensions* extensions = _state->get<GL2Extensions>();
GLExtensions* extensions = _state->get<GLExtensions>();
#ifndef OSG_GLES1_AVAILABLE
_vertexDispatchers->assign<GLfloat>(Array::Vec2ArrayType, glVertex2fv, 2);
@@ -281,7 +281,7 @@ AttributeDispatch* ArrayDispatchers::vertexAttribDispatcher(unsigned int unit, A
void ArrayDispatchers::assignTexCoordDispatchers(unsigned int unit)
{
#if defined(OSG_GL_VERTEX_FUNCS_AVAILABLE) && !defined(OSG_GLES1_AVAILABLE)
GL2Extensions* extensions = _state->get<GL2Extensions>();
GLExtensions* extensions = _state->get<GLExtensions>();
#endif
for(unsigned int i=_texCoordDispatchers.size(); i<=unit; ++i)
@@ -312,7 +312,7 @@ void ArrayDispatchers::assignTexCoordDispatchers(unsigned int unit)
void ArrayDispatchers::assignVertexAttribDispatchers(unsigned int unit)
{
GL2Extensions* extensions = _state->get<GL2Extensions>();
GLExtensions* extensions = _state->get<GLExtensions>();
for(unsigned int i=_vertexAttribDispatchers.size(); i<=unit; ++i)
{

View File

@@ -35,7 +35,7 @@ BlendColor::~BlendColor()
void BlendColor::apply(State& state) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isBlendColorSupported)
{
OSG_WARN<<"Warning: BlendColor::apply(..) failed, BlendColor is not support by OpenGL driver."<<std::endl;

View File

@@ -43,7 +43,7 @@ BlendEquation::~BlendEquation()
void BlendEquation::apply(State& state) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isBlendEquationSupported)
{

View File

@@ -28,7 +28,7 @@ BlendEquationi::~BlendEquationi()
void BlendEquationi::apply(State& state) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (_equationRGB == _equationAlpha)
{
if (extensions->glBlendEquationi)

View File

@@ -50,7 +50,7 @@ void BlendFunc::apply(State& state) const
if (_source_factor != _source_factor_alpha ||
_destination_factor != _destination_factor_alpha)
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isBlendFuncSeparateSupported)
{
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
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (_source_factor != _source_factor_alpha ||
_destination_factor != _destination_factor_alpha)
{

View File

@@ -18,7 +18,7 @@
#include <osg/BufferObject>
#include <osg/Notify>
#include <osg/GLExtensions>
#include <osg/GL2Extensions>
#include <osg/GLExtensions>
#include <osg/Timer>
#include <osg/Image>
#include <osg/State>
@@ -64,7 +64,7 @@ GLBufferObject::GLBufferObject(unsigned int contextID, BufferObject* bufferObjec
{
assign(bufferObject);
_extensions = GL2Extensions::Get(contextID, true);
_extensions = GLExtensions::Get(contextID, true);
if (glObjectID==0)
{
@@ -1494,7 +1494,7 @@ void PixelDataBufferObject::bindBufferInWriteMode(State& state)
//--------------------------------------------------------------------------------
void PixelDataBufferObject::unbindBuffer(unsigned int contextID) const
{
GL2Extensions* extensions = GL2Extensions::Get(contextID, true);
GLExtensions* extensions = GLExtensions::Get(contextID, true);
switch(_mode[contextID])
{

View File

@@ -78,6 +78,7 @@ SET(TARGET_H
${HEADER_PATH}/Geode
${HEADER_PATH}/Geometry
${HEADER_PATH}/GL2Extensions
${HEADER_PATH}/GLDefines
${HEADER_PATH}/GLExtensions
${HEADER_PATH}/GLBeginEndAdapter
${HEADER_PATH}/GLObjects

View File

@@ -38,7 +38,7 @@ Capabilityi::~Capabilityi()
void Enablei::apply(State& state) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (extensions->glEnablei)
{
OSG_INFO<<"extensions->glEnablei("<<_capability<<", "<<_index<<")"<<std::endl;
@@ -52,7 +52,7 @@ void Enablei::apply(State& state) const
void Disablei::apply(State& state) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (extensions->glDisablei)
{
OSG_INFO<<"extensions->glDisablei("<<_capability<<", "<<_index<<")"<<std::endl;

View File

@@ -42,7 +42,7 @@ void ClampColor::apply(State& state) const
// get the contextID (user defined ID of 0 upwards) for the
// current OpenGL context.
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isClampColorSupported)
{
OSG_WARN<<"Warning: ClampColor::apply(..) failed, ClampColor is not support by OpenGL driver."<<std::endl;

View File

@@ -27,7 +27,7 @@ ColorMaski::~ColorMaski()
void ColorMaski::apply(State& state) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (extensions->glColorMaski)
{
extensions->glColorMaski((GLboolean)_index, (GLboolean)_red,(GLboolean)_green,(GLboolean)_blue,(GLboolean)_alpha);

View File

@@ -56,7 +56,7 @@ void FragmentProgram::flushDeletedFragmentProgramObjects(unsigned int contextID,
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedFragmentProgramObjectCache);
const GL2Extensions* extensions = GL2Extensions::Get(contextID,true);
const GLExtensions* extensions = GLExtensions::Get(contextID,true);
FragmentProgramObjectList& vpol = s_deletedFragmentProgramObjectCache[contextID];
@@ -127,7 +127,7 @@ void FragmentProgram::apply(State& state) const
{
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isFragmentProgramSupported)
return;

View File

@@ -59,7 +59,7 @@ void RenderBuffer::flushDeletedRenderBuffers(unsigned int contextID,double /*cur
// if no time available don't try to flush objects.
if (availableTime<=0.0) return;
const GL2Extensions* extensions = GL2Extensions::Get(contextID,true);
const GLExtensions* extensions = GLExtensions::Get(contextID,true);
if(!extensions || !extensions->isFrameBufferObjectSupported ) return;
const osg::Timer& timer = *osg::Timer::instance();
@@ -129,7 +129,7 @@ RenderBuffer::~RenderBuffer()
}
}
int RenderBuffer::getMaxSamples(unsigned int contextID, const GL2Extensions* ext)
int RenderBuffer::getMaxSamples(unsigned int contextID, const GLExtensions* ext)
{
static osg::buffered_value<GLint> maxSamplesList;
@@ -143,7 +143,7 @@ int RenderBuffer::getMaxSamples(unsigned int contextID, const GL2Extensions* ext
return maxSamples;
}
GLuint RenderBuffer::getObjectID(unsigned int contextID, const GL2Extensions* ext) const
GLuint RenderBuffer::getObjectID(unsigned int contextID, const GLExtensions* ext) const
{
GLuint &objectID = _objectID[contextID];
@@ -450,7 +450,7 @@ bool FrameBufferAttachment::isMultisample() const
return false;
}
void FrameBufferAttachment::createRequiredTexturesAndApplyGenerateMipMap(State &state, const GL2Extensions* ext) const
void FrameBufferAttachment::createRequiredTexturesAndApplyGenerateMipMap(State &state, const GLExtensions* ext) const
{
unsigned int contextID = state.getContextID();
@@ -481,7 +481,7 @@ void FrameBufferAttachment::createRequiredTexturesAndApplyGenerateMipMap(State &
}
}
void FrameBufferAttachment::attach(State &state, GLenum target, GLenum attachment_point, const GL2Extensions* ext) const
void FrameBufferAttachment::attach(State &state, GLenum target, GLenum attachment_point, const GLExtensions* ext) const
{
unsigned int contextID = state.getContextID();
@@ -641,7 +641,7 @@ void FrameBufferObject::flushDeletedFrameBufferObjects(unsigned int contextID,do
// if no time available don't try to flush objects.
if (availableTime<=0.0) return;
const GL2Extensions* extensions = GL2Extensions::Get(contextID,true);
const GLExtensions* extensions = GLExtensions::Get(contextID,true);
if(!extensions || !extensions->isFrameBufferObjectSupported ) return;
const osg::Timer& timer = *osg::Timer::instance();
@@ -772,7 +772,7 @@ void FrameBufferObject::apply(State &state, BindTarget target) const
return;
GL2Extensions* ext = state.get<GL2Extensions>();
GLExtensions* ext = state.get<GLExtensions>();
if (!ext->isFrameBufferObjectSupported)
{
_unsupported[contextID] = 1;
@@ -828,7 +828,7 @@ void FrameBufferObject::apply(State &state, BindTarget target) const
{
if (_drawBuffers.size() > 0)
{
GL2Extensions *gl2e = state.get<GL2Extensions>();
GLExtensions *gl2e = state.get<GLExtensions>();
if (gl2e && gl2e->glDrawBuffers)
{
gl2e->glDrawBuffers(_drawBuffers.size(), &(_drawBuffers[0]));

View File

@@ -51,6 +51,8 @@
#include <dlfcn.h>
#endif
using namespace osg;
typedef std::set<std::string> ExtensionSet;
static osg::buffered_object<ExtensionSet> s_glExtensionSetList;
static osg::buffered_object<std::string> s_glRendererList;
@@ -406,3 +408,745 @@ OSG_INIT_SINGLETON_PROXY(GLExtensionDisableStringInitializationProxy, osg::getGL
#endif
}
#endif
///////////////////////////////////////////////////////////////////////////
// Static array of percontext osg::GLExtensions instances
typedef osg::buffered_object< osg::ref_ptr<GLExtensions> > BufferedExtensions;
static BufferedExtensions s_extensions;
GLExtensions* GLExtensions::Get(unsigned int contextID, bool createIfNotInitalized)
{
if (!s_extensions[contextID] && createIfNotInitalized)
s_extensions[contextID] = new GLExtensions(contextID);
return s_extensions[contextID].get();
}
void GLExtensions::Set(unsigned int contextID, GLExtensions* extensions)
{
s_extensions[contextID] = extensions;
}
///////////////////////////////////////////////////////////////////////////
// Extension function pointers for OpenGL v2.x
GLExtensions::GLExtensions(unsigned int contextID)
{
const char* version = (const char*) glGetString( GL_VERSION );
if (!version)
{
OSG_NOTIFY(osg::FATAL)<<"Error: OpenGL version test failed, requires valid graphics context."<<std::endl;
return;
}
glVersion = findAsciiToFloat( version );
glslLanguageVersion = 0.0f;
bool shadersBuiltIn = OSG_GLES2_FEATURES || OSG_GL3_FEATURES;
isShaderObjectsSupported = shadersBuiltIn || osg::isGLExtensionSupported(contextID,"GL_ARB_shader_objects");
isVertexShaderSupported = shadersBuiltIn || osg::isGLExtensionSupported(contextID,"GL_ARB_vertex_shader");
isFragmentShaderSupported = shadersBuiltIn || osg::isGLExtensionSupported(contextID,"GL_ARB_fragment_shader");
isLanguage100Supported = shadersBuiltIn || osg::isGLExtensionSupported(contextID,"GL_ARB_shading_language_100");
isGeometryShader4Supported = osg::isGLExtensionSupported(contextID,"GL_EXT_geometry_shader4");
isGpuShader4Supported = osg::isGLExtensionSupported(contextID,"GL_EXT_gpu_shader4");
areTessellationShadersSupported = osg::isGLExtensionSupported(contextID, "GL_ARB_tessellation_shader");
isUniformBufferObjectSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_uniform_buffer_object");
isGetProgramBinarySupported = osg::isGLExtensionSupported(contextID,"GL_ARB_get_program_binary");
isGpuShaderFp64Supported = osg::isGLExtensionSupported(contextID,"GL_ARB_gpu_shader_fp64");
isShaderAtomicCountersSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_shader_atomic_counters");
isRectangleSupported = OSG_GL3_FEATURES ||
isGLExtensionSupported(contextID,"GL_ARB_texture_rectangle") ||
isGLExtensionSupported(contextID,"GL_EXT_texture_rectangle") ||
isGLExtensionSupported(contextID,"GL_NV_texture_rectangle");
isCubeMapSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES ||
isGLExtensionSupported(contextID,"GL_ARB_texture_cube_map") ||
isGLExtensionSupported(contextID,"GL_EXT_texture_cube_map") ||
strncmp((const char*)glGetString(GL_VERSION),"1.3",3)>=0;;
isGlslSupported = ( glVersion >= 2.0f ) ||
( isShaderObjectsSupported &&
isVertexShaderSupported &&
isFragmentShaderSupported &&
isLanguage100Supported );
if( isGlslSupported )
{
// If glGetString raises an error, assume initial release "1.00"
while(glGetError() != GL_NO_ERROR) {} // reset error flag
const char* langVerStr = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
if( (glGetError() == GL_NO_ERROR) && langVerStr )
{
glslLanguageVersion = (findAsciiToFloat(langVerStr));
}
else
glslLanguageVersion = 1.0f;
}
OSG_INFO
<< "glVersion=" << glVersion << ", "
<< "isGlslSupported=" << (isGlslSupported ? "YES" : "NO") << ", "
<< "glslLanguageVersion=" << glslLanguageVersion
<< std::endl;
setGLExtensionFuncPtr(glDrawBuffers, "glDrawBuffers", "glDrawBuffersARB");
setGLExtensionFuncPtr(glAttachShader, "glAttachShader", "glAttachObjectARB");
setGLExtensionFuncPtr(glBindAttribLocation, "glBindAttribLocation", "glBindAttribLocationARB");
setGLExtensionFuncPtr(glCompileShader, "glCompileShader", "glCompileShaderARB");
setGLExtensionFuncPtr(glCreateProgram, "glCreateProgram", "glCreateProgramObjectARB");
setGLExtensionFuncPtr(glCreateShader, "glCreateShader", "glCreateShaderObjectARB");
setGLExtensionFuncPtr(glDeleteProgram, "glDeleteProgram");
setGLExtensionFuncPtr(glDeleteShader, "glDeleteShader");
setGLExtensionFuncPtr(glDetachShader, "glDetachShader", "glDetachObjectARB");
setGLExtensionFuncPtr(glDisableVertexAttribArray, "glDisableVertexAttribArray");
setGLExtensionFuncPtr(glEnableVertexAttribArray, "glEnableVertexAttribArray");
setGLExtensionFuncPtr(glGetActiveAttrib, "glGetActiveAttrib", "glGetActiveAttribARB");
setGLExtensionFuncPtr(glGetActiveUniform, "glGetActiveUniform", "glGetActiveUniformARB");
setGLExtensionFuncPtr(glGetAttachedShaders, "glGetAttachedShaders", "glGetAttachedObjectsARB");
setGLExtensionFuncPtr(glGetAttribLocation, "glGetAttribLocation", "glGetAttribLocationARB");
setGLExtensionFuncPtr(glGetProgramiv, "glGetProgramiv");
setGLExtensionFuncPtr(glGetProgramInfoLog, "glGetProgramInfoLog");
setGLExtensionFuncPtr(glGetShaderiv, "glGetShaderiv");
setGLExtensionFuncPtr(glGetShaderInfoLog, "glGetShaderInfoLog");
setGLExtensionFuncPtr(glGetShaderSource, "glGetShaderSource", "glGetShaderSourceARB");
setGLExtensionFuncPtr(glGetUniformLocation, "glGetUniformLocation", "glGetUniformLocationARB");
setGLExtensionFuncPtr(glGetUniformfv, "glGetUniformfv", "glGetUniformfvARB");
setGLExtensionFuncPtr(glGetUniformiv, "glGetUniformiv", "glGetUniformivARB");
setGLExtensionFuncPtr(glGetVertexAttribdv, "glGetVertexAttribdv");
setGLExtensionFuncPtr(glGetVertexAttribfv, "glGetVertexAttribfv");
setGLExtensionFuncPtr(glGetVertexAttribiv, "glGetVertexAttribiv");
setGLExtensionFuncPtr(glGetVertexAttribPointerv, "glGetVertexAttribPointerv");
setGLExtensionFuncPtr(glIsProgram, "glIsProgram");
setGLExtensionFuncPtr(glIsShader, "glIsShader");
setGLExtensionFuncPtr(glLinkProgram, "glLinkProgram", "glLinkProgramARB");
setGLExtensionFuncPtr(glShaderSource, "glShaderSource", "glShaderSourceARB");
setGLExtensionFuncPtr(glUseProgram, "glUseProgram", "glUseProgramObjectARB");
setGLExtensionFuncPtr(glUniform1f, "glUniform1f", "glUniform1fARB");
setGLExtensionFuncPtr(glUniform2f, "glUniform2f", "glUniform2fARB");
setGLExtensionFuncPtr(glUniform3f, "glUniform3f", "glUniform3fARB");
setGLExtensionFuncPtr(glUniform4f, "glUniform4f", "glUniform4fARB");
setGLExtensionFuncPtr(glUniform1i, "glUniform1i", "glUniform1iARB");
setGLExtensionFuncPtr(glUniform2i, "glUniform2i", "glUniform2iARB");
setGLExtensionFuncPtr(glUniform3i, "glUniform3i", "glUniform3iARB");
setGLExtensionFuncPtr(glUniform4i, "glUniform4i", "glUniform4iARB");
setGLExtensionFuncPtr(glUniform1fv, "glUniform1fv", "glUniform1fvARB");
setGLExtensionFuncPtr(glUniform2fv, "glUniform2fv", "glUniform2fvARB");
setGLExtensionFuncPtr(glUniform3fv, "glUniform3fv", "glUniform3fvARB");
setGLExtensionFuncPtr(glUniform4fv, "glUniform4fv", "glUniform4fvARB");
setGLExtensionFuncPtr(glUniform1iv, "glUniform1iv", "glUniform1ivARB");
setGLExtensionFuncPtr(glUniform2iv, "glUniform2iv", "glUniform2ivARB");
setGLExtensionFuncPtr(glUniform3iv, "glUniform3iv", "glUniform3ivARB");
setGLExtensionFuncPtr(glUniform4iv, "glUniform4iv", "glUniform4ivARB");
setGLExtensionFuncPtr(glUniformMatrix2fv, "glUniformMatrix2fv", "glUniformMatrix2fvARB");
setGLExtensionFuncPtr(glUniformMatrix3fv, "glUniformMatrix3fv", "glUniformMatrix3fvARB");
setGLExtensionFuncPtr(glUniformMatrix4fv, "glUniformMatrix4fv", "glUniformMatrix4fvARB");
setGLExtensionFuncPtr(glValidateProgram, "glValidateProgram", "glValidateProgramARB");
setGLExtensionFuncPtr(glVertexAttrib1d, "glVertexAttrib1d");
setGLExtensionFuncPtr(glVertexAttrib1dv, "glVertexAttrib1dv");
setGLExtensionFuncPtr(glVertexAttrib1f, "glVertexAttrib1f");
setGLExtensionFuncPtr(glVertexAttrib1fv, "glVertexAttrib1fv");
setGLExtensionFuncPtr(glVertexAttrib1s, "glVertexAttrib1s");
setGLExtensionFuncPtr(glVertexAttrib1sv, "glVertexAttrib1sv");
setGLExtensionFuncPtr(glVertexAttrib2d, "glVertexAttrib2d");
setGLExtensionFuncPtr(glVertexAttrib2dv, "glVertexAttrib2dv");
setGLExtensionFuncPtr(glVertexAttrib2f, "glVertexAttrib2f");
setGLExtensionFuncPtr(glVertexAttrib2fv, "glVertexAttrib2fv");
setGLExtensionFuncPtr(glVertexAttrib2s, "glVertexAttrib2s");
setGLExtensionFuncPtr(glVertexAttrib2sv, "glVertexAttrib2sv");
setGLExtensionFuncPtr(glVertexAttrib3d, "glVertexAttrib3d");
setGLExtensionFuncPtr(glVertexAttrib3dv, "glVertexAttrib3dv");
setGLExtensionFuncPtr(glVertexAttrib3f, "glVertexAttrib3f");
setGLExtensionFuncPtr(glVertexAttrib3fv, "glVertexAttrib3fv");
setGLExtensionFuncPtr(glVertexAttrib3s, "glVertexAttrib3s");
setGLExtensionFuncPtr(glVertexAttrib3sv, "glVertexAttrib3sv");
setGLExtensionFuncPtr(glVertexAttrib4Nbv, "glVertexAttrib4Nbv");
setGLExtensionFuncPtr(glVertexAttrib4Niv, "glVertexAttrib4Niv");
setGLExtensionFuncPtr(glVertexAttrib4Nsv, "glVertexAttrib4Nsv");
setGLExtensionFuncPtr(glVertexAttrib4Nub, "glVertexAttrib4Nub");
setGLExtensionFuncPtr(glVertexAttrib4Nubv, "glVertexAttrib4Nubv");
setGLExtensionFuncPtr(glVertexAttrib4Nuiv, "glVertexAttrib4Nuiv");
setGLExtensionFuncPtr(glVertexAttrib4Nusv, "glVertexAttrib4Nusv");
setGLExtensionFuncPtr(glVertexAttrib4bv, "glVertexAttrib4bv");
setGLExtensionFuncPtr(glVertexAttrib4d, "glVertexAttrib4d");
setGLExtensionFuncPtr(glVertexAttrib4dv, "glVertexAttrib4dv");
setGLExtensionFuncPtr(glVertexAttrib4f, "glVertexAttrib4f");
setGLExtensionFuncPtr(glVertexAttrib4fv, "glVertexAttrib4fv");
setGLExtensionFuncPtr(glVertexAttrib4iv, "glVertexAttrib4iv");
setGLExtensionFuncPtr(glVertexAttrib4s, "glVertexAttrib4s");
setGLExtensionFuncPtr(glVertexAttrib4sv, "glVertexAttrib4sv");
setGLExtensionFuncPtr(glVertexAttrib4ubv, "glVertexAttrib4ubv");
setGLExtensionFuncPtr(glVertexAttrib4uiv, "glVertexAttrib4uiv");
setGLExtensionFuncPtr(glVertexAttrib4usv, "glVertexAttrib4usv");
setGLExtensionFuncPtr(glVertexAttribPointer, "glVertexAttribPointer");
setGLExtensionFuncPtr(glVertexAttribDivisor, "glVertexAttribDivisor");
// v1.5-only ARB entry points, in case they're needed for fallback
setGLExtensionFuncPtr(glGetInfoLogARB, "glGetInfoLogARB");
setGLExtensionFuncPtr(glGetObjectParameterivARB, "glGetObjectParameterivARB");
setGLExtensionFuncPtr(glDeleteObjectARB, "glDeleteObjectARB");
setGLExtensionFuncPtr(glGetHandleARB, "glGetHandleARB");
// GL 2.1
setGLExtensionFuncPtr(glUniformMatrix2x3fv, "glUniformMatrix2x3fv" );
setGLExtensionFuncPtr(glUniformMatrix3x2fv, "glUniformMatrix3x2fv" );
setGLExtensionFuncPtr(glUniformMatrix2x4fv, "glUniformMatrix2x4fv" );
setGLExtensionFuncPtr(glUniformMatrix4x2fv, "glUniformMatrix4x2fv" );
setGLExtensionFuncPtr(glUniformMatrix3x4fv, "glUniformMatrix3x4fv" );
setGLExtensionFuncPtr(glUniformMatrix4x3fv, "glUniformMatrix4x3fv" );
// EXT_geometry_shader4
setGLExtensionFuncPtr(glProgramParameteri, "glProgramParameteri", "glProgramParameteriEXT" );
// ARB_tesselation_shader
setGLExtensionFuncPtr(glPatchParameteri, "glPatchParameteri" );
setGLExtensionFuncPtr(glPatchParameterfv, "glPatchParameterfv");
// EXT_gpu_shader4
setGLExtensionFuncPtr(glGetUniformuiv, "glGetUniformuiv", "glGetUniformuivEXT" );
setGLExtensionFuncPtr(glBindFragDataLocation, "glBindFragDataLocation", "glBindFragDataLocationEXT" );
setGLExtensionFuncPtr(glGetFragDataLocation, "glGetFragDataLocation", "glGetFragDataLocationEXT" );
setGLExtensionFuncPtr(glUniform1ui, "glUniform1ui", "glUniform1uiEXT" );
setGLExtensionFuncPtr(glUniform2ui, "glUniform2ui", "glUniform2uiEXT" );
setGLExtensionFuncPtr(glUniform3ui, "glUniform3ui", "glUniform3uiEXT" );
setGLExtensionFuncPtr(glUniform4ui, "glUniform4ui", "glUniform4uiEXT" );
setGLExtensionFuncPtr(glUniform1uiv, "glUniform1uiv", "glUniform1uivEXT" );
setGLExtensionFuncPtr(glUniform2uiv, "glUniform2uiv", "glUniform2uivEXT" );
setGLExtensionFuncPtr(glUniform3uiv, "glUniform3uiv", "glUniform3uivEXT" );
setGLExtensionFuncPtr(glUniform4uiv, "glUniform4uiv", "glUniform4uivEXT" );
// ARB_uniform_buffer_object
setGLExtensionFuncPtr(glGetUniformIndices, "glGetUniformIndices");
setGLExtensionFuncPtr(glGetActiveUniformsiv, "glGetActiveUniformsiv");
setGLExtensionFuncPtr(glGetActiveUniformName, "glGetActiveUniformName");
setGLExtensionFuncPtr(glGetUniformBlockIndex, "glGetUniformBlockIndex");
setGLExtensionFuncPtr(glGetActiveUniformBlockiv, "glGetActiveUniformBlockiv");
setGLExtensionFuncPtr(glGetActiveUniformBlockName, "glGetActiveUniformBlockName");
setGLExtensionFuncPtr(glUniformBlockBinding, "glUniformBlockBinding");
// ARB_get_program_binary
setGLExtensionFuncPtr(glGetProgramBinary, "glGetProgramBinary");
setGLExtensionFuncPtr(glProgramBinary, "glProgramBinary");
// ARB_gpu_shader_fp64
setGLExtensionFuncPtr(glUniform1d, "glUniform1d" );
setGLExtensionFuncPtr(glUniform2d, "glUniform2d" );
setGLExtensionFuncPtr(glUniform3d, "glUniform3d" );
setGLExtensionFuncPtr(glUniform4d, "glUniform4d" );
setGLExtensionFuncPtr(glUniform1dv, "glUniform1dv" );
setGLExtensionFuncPtr(glUniform2dv, "glUniform2dv" );
setGLExtensionFuncPtr(glUniform3dv, "glUniform3dv" );
setGLExtensionFuncPtr(glUniform4dv, "glUniform4dv" );
setGLExtensionFuncPtr(glUniformMatrix2dv, "glUniformMatrix2dv" );
setGLExtensionFuncPtr(glUniformMatrix3dv, "glUniformMatrix3dv" );
setGLExtensionFuncPtr(glUniformMatrix4dv, "glUniformMatrix4dv" );
setGLExtensionFuncPtr(glUniformMatrix2x3dv, "glUniformMatrix2x3dv" );
setGLExtensionFuncPtr(glUniformMatrix3x2dv, "glUniformMatrix3x2dv" );
setGLExtensionFuncPtr(glUniformMatrix2x4dv, "glUniformMatrix2x4dv" );
setGLExtensionFuncPtr(glUniformMatrix4x2dv, "glUniformMatrix4x2dv" );
setGLExtensionFuncPtr(glUniformMatrix3x4dv, "glUniformMatrix3x4dv" );
setGLExtensionFuncPtr(glUniformMatrix4x3dv, "glUniformMatrix4x3dv" );
// ARB_shader_atomic_counters
setGLExtensionFuncPtr(glGetActiveAtomicCounterBufferiv, "glGetActiveAtomicCounterBufferiv" );
// ARB_compute_shader
setGLExtensionFuncPtr(glDispatchCompute, "glDispatchCompute" );
setGLExtensionFuncPtr(glMemoryBarrier, "glMemoryBarrier", "glMemoryBarrierEXT" );
// BufferObject extensions
setGLExtensionFuncPtr(glGenBuffers, "glGenBuffers","glGenBuffersARB");
setGLExtensionFuncPtr(glBindBuffer, "glBindBuffer","glBindBufferARB");
setGLExtensionFuncPtr(glBufferData, "glBufferData","glBufferDataARB");
setGLExtensionFuncPtr(glBufferSubData, "glBufferSubData","glBufferSubDataARB");
setGLExtensionFuncPtr(glDeleteBuffers, "glDeleteBuffers","glDeleteBuffersARB");
setGLExtensionFuncPtr(glIsBuffer, "glIsBuffer","glIsBufferARB");
setGLExtensionFuncPtr(glGetBufferSubData, "glGetBufferSubData","glGetBufferSubDataARB");
setGLExtensionFuncPtr(glMapBuffer, "glMapBuffer","glMapBufferARB");
setGLExtensionFuncPtr(glMapBufferRange, "glMapBufferRange" );
setGLExtensionFuncPtr(glUnmapBuffer, "glUnmapBuffer","glUnmapBufferARB");
setGLExtensionFuncPtr(glGetBufferParameteriv, "glGetBufferParameteriv","glGetBufferParameterivARB");
setGLExtensionFuncPtr(glGetBufferPointerv, "glGetBufferPointerv","glGetBufferPointervARB");
setGLExtensionFuncPtr(glBindBufferRange, "glBindBufferRange");
setGLExtensionFuncPtr(glBindBufferBase, "glBindBufferBase", "glBindBufferBaseEXT", "glBindBufferBaseNV" );
setGLExtensionFuncPtr(glTexBuffer, "glTexBuffer","glTexBufferARB" );
isPBOSupported = OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID,"GL_ARB_pixel_buffer_object");
isUniformBufferObjectSupported = osg::isGLExtensionSupported(contextID, "GL_ARB_uniform_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");
// Vertex Array extensions
isSecondaryColorSupported = isGLExtensionSupported(contextID,"GL_EXT_secondary_color");
isFogCoordSupported = isGLExtensionSupported(contextID,"GL_EXT_fog_coord");
isMultiTexSupported = isGLExtensionSupported(contextID,"GL_ARB_multitexture");
isOcclusionQuerySupported = osg::isGLExtensionSupported(contextID, "GL_NV_occlusion_query" );
isARBOcclusionQuerySupported = OSG_GL3_FEATURES || osg::isGLExtensionSupported(contextID, "GL_ARB_occlusion_query" );
isTimerQuerySupported = osg::isGLExtensionSupported(contextID, "GL_EXT_timer_query" );
isARBTimerQuerySupported = osg::isGLExtensionSupported(contextID, "GL_ARB_timer_query");
setGLExtensionFuncPtr(glFogCoordfv, "glFogCoordfv","glFogCoordfvEXT");
setGLExtensionFuncPtr(glSecondaryColor3ubv, "glSecondaryColor3ubv","glSecondaryColor3ubvEXT");
setGLExtensionFuncPtr(glSecondaryColor3fv, "glSecondaryColor3fv","glSecondaryColor3fvEXT");
setGLExtensionFuncPtr(glMultiTexCoord1f, "glMultiTexCoord1f","glMultiTexCoord1fARB");
setGLExtensionFuncPtr(glMultiTexCoord1fv, "glMultiTexCoord1fv","glMultiTexCoord1fvARB");
setGLExtensionFuncPtr(glMultiTexCoord2fv, "glMultiTexCoord2fv","glMultiTexCoord2fvARB");
setGLExtensionFuncPtr(glMultiTexCoord3fv, "glMultiTexCoord3fv","glMultiTexCoord3fvARB");
setGLExtensionFuncPtr(glMultiTexCoord4fv, "glMultiTexCoord4fv","glMultiTexCoord4fvARB");
setGLExtensionFuncPtr(glMultiTexCoord1d, "glMultiTexCoord1d","glMultiTexCoorddfARB");
setGLExtensionFuncPtr(glMultiTexCoord2dv, "glMultiTexCoord2dv","glMultiTexCoord2dvARB");
setGLExtensionFuncPtr(glMultiTexCoord3dv, "glMultiTexCoord3dv","glMultiTexCoord3dvARB");
setGLExtensionFuncPtr(glMultiTexCoord4dv, "glMultiTexCoord4dv","glMultiTexCoord4dvARB");
setGLExtensionFuncPtr(glVertexAttrib1s, "glVertexAttrib1s","glVertexAttrib1sARB");
setGLExtensionFuncPtr(glVertexAttrib1f, "glVertexAttrib1f","glVertexAttrib1fARB");
setGLExtensionFuncPtr(glVertexAttrib1d, "glVertexAttrib1d","glVertexAttrib1dARB");
setGLExtensionFuncPtr(glVertexAttrib1fv, "glVertexAttrib1fv","glVertexAttrib1fvARB");
setGLExtensionFuncPtr(glVertexAttrib2fv, "glVertexAttrib2fv","glVertexAttrib2fvARB");
setGLExtensionFuncPtr(glVertexAttrib3fv, "glVertexAttrib3fv","glVertexAttrib3fvARB");
setGLExtensionFuncPtr(glVertexAttrib4fv, "glVertexAttrib4fv","glVertexAttrib4fvARB");
setGLExtensionFuncPtr(glVertexAttrib2dv, "glVertexAttrib2dv","glVertexAttrib2dvARB");
setGLExtensionFuncPtr(glVertexAttrib3dv, "glVertexAttrib3dv","glVertexAttrib3dvARB");
setGLExtensionFuncPtr(glVertexAttrib4dv, "glVertexAttrib4dv","glVertexAttrib4dvARB");
setGLExtensionFuncPtr(glVertexAttrib4ubv, "glVertexAttrib4ubv","glVertexAttrib4ubvARB");
setGLExtensionFuncPtr(glVertexAttrib4Nubv, "glVertexAttrib4Nubv","glVertexAttrib4NubvARB");
setGLExtensionFuncPtr(glGenBuffers, "glGenBuffers","glGenBuffersARB");
setGLExtensionFuncPtr(glBindBuffer, "glBindBuffer","glBindBufferARB");
setGLExtensionFuncPtr(glBufferData, "glBufferData","glBufferDataARB");
setGLExtensionFuncPtr(glBufferSubData, "glBufferSubData","glBufferSubDataARB");
setGLExtensionFuncPtr(glDeleteBuffers, "glDeleteBuffers","glDeleteBuffersARB");
setGLExtensionFuncPtr(glIsBuffer, "glIsBuffer","glIsBufferARB");
setGLExtensionFuncPtr(glGetBufferSubData, "glGetBufferSubData","glGetBufferSubDataARB");
setGLExtensionFuncPtr(glMapBuffer, "glMapBuffer","glMapBufferARB");
setGLExtensionFuncPtr(glUnmapBuffer, "glUnmapBuffer","glUnmapBufferARB");
setGLExtensionFuncPtr(glGetBufferParameteriv, "glGetBufferParameteriv","glGetBufferParameterivARB");
setGLExtensionFuncPtr(glGetBufferPointerv, "glGetBufferPointerv","glGetBufferPointervARB");
setGLExtensionFuncPtr(glGenOcclusionQueries, "glGenOcclusionQueries","glGenOcclusionQueriesNV");
setGLExtensionFuncPtr(glDeleteOcclusionQueries, "glDeleteOcclusionQueries","glDeleteOcclusionQueriesNV");
setGLExtensionFuncPtr(glIsOcclusionQuery, "glIsOcclusionQuery","_glIsOcclusionQueryNV");
setGLExtensionFuncPtr(glBeginOcclusionQuery, "glBeginOcclusionQuery","glBeginOcclusionQueryNV");
setGLExtensionFuncPtr(glEndOcclusionQuery, "glEndOcclusionQuery","glEndOcclusionQueryNV");
setGLExtensionFuncPtr(glGetOcclusionQueryiv, "glGetOcclusionQueryiv","glGetOcclusionQueryivNV");
setGLExtensionFuncPtr(glGetOcclusionQueryuiv, "glGetOcclusionQueryuiv","glGetOcclusionQueryuivNV");
setGLExtensionFuncPtr(glGenQueries, "glGenQueries", "glGenQueriesARB");
setGLExtensionFuncPtr(glDeleteQueries, "glDeleteQueries", "glDeleteQueriesARB");
setGLExtensionFuncPtr(glIsQuery, "glIsQuery", "glIsQueryARB");
setGLExtensionFuncPtr(glBeginQuery, "glBeginQuery", "glBeginQueryARB");
setGLExtensionFuncPtr(glEndQuery, "glEndQuery", "glEndQueryARB");
setGLExtensionFuncPtr(glGetQueryiv, "glGetQueryiv", "glGetQueryivARB");
setGLExtensionFuncPtr(glGetQueryObjectiv, "glGetQueryObjectiv","glGetQueryObjectivARB");
setGLExtensionFuncPtr(glGetQueryObjectuiv, "glGetQueryObjectuiv","glGetQueryObjectuivARB");
setGLExtensionFuncPtr(glGetQueryObjectui64v, "glGetQueryObjectui64v","glGetQueryObjectui64vEXT");
setGLExtensionFuncPtr(glQueryCounter, "glQueryCounter");
setGLExtensionFuncPtr(glGetInteger64v, "glGetInteger64v");
// SampleMaski functionality
isTextureMultisampleSupported = isGLExtensionSupported(contextID, "GL_ARB_texture_multisample");
isOpenGL32upported = getGLVersionNumber() >= 3.2;
// function pointers
setGLExtensionFuncPtr(glSampleMaski, "glSampleMaski");
// protect against buggy drivers (maybe not necessary)
isSampleMaskiSupported = glSampleMaski!=0;
// old styple Vertex/Fragment Programs
isVertexProgramSupported = isGLExtensionSupported(contextID,"GL_ARB_vertex_program");
isFragmentProgramSupported = isGLExtensionSupported(contextID,"GL_ARB_fragment_program");
setGLExtensionFuncPtr(glBindProgram,"glBindProgramARB");
setGLExtensionFuncPtr(glGenPrograms, "glGenProgramsARB");
setGLExtensionFuncPtr(glDeletePrograms, "glDeleteProgramsARB");
setGLExtensionFuncPtr(glProgramString, "glProgramStringARB");
setGLExtensionFuncPtr(glProgramLocalParameter4fv, "glProgramLocalParameter4fvARB");
// Texture extensions
const char* renderer = (const char*) glGetString(GL_RENDERER);
std::string rendererString(renderer ? renderer : "");
bool radeonHardwareDetected = (rendererString.find("Radeon")!=std::string::npos || rendererString.find("RADEON")!=std::string::npos);
bool fireGLHardwareDetected = (rendererString.find("FireGL")!=std::string::npos || rendererString.find("FIREGL")!=std::string::npos);
bool builtInSupport = OSG_GLES2_FEATURES || OSG_GL3_FEATURES;
isMultiTexturingSupported = builtInSupport || OSG_GLES1_FEATURES ||
isGLExtensionOrVersionSupported( contextID,"GL_ARB_multitexture", 1.3f) ||
isGLExtensionOrVersionSupported(contextID,"GL_EXT_multitexture", 1.3f);
isTextureFilterAnisotropicSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_filter_anisotropic");
isTextureSwizzleSupported = isGLExtensionSupported(contextID,"GL_ARB_texture_swizzle");
isTextureCompressionARBSupported = builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_compression", 1.3f);
isTextureCompressionS3TCSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_compression_s3tc");
isTextureCompressionPVRTC2BPPSupported = isGLExtensionSupported(contextID,"GL_IMG_texture_compression_pvrtc");
isTextureCompressionPVRTC4BPPSupported = isTextureCompressionPVRTC2BPPSupported;//covered by same extension
isTextureCompressionETCSupported = isGLExtensionSupported(contextID,"GL_OES_compressed_ETC1_RGB8_texture");
isTextureCompressionETC2Supported = isGLExtensionSupported(contextID,"GL_ARB_ES3_compatibility");
isTextureCompressionRGTCSupported = isGLExtensionSupported(contextID,"GL_EXT_texture_compression_rgtc");
isTextureCompressionPVRTCSupported = isGLExtensionSupported(contextID,"GL_IMG_texture_compression_pvrtc");
isTextureMirroredRepeatSupported = builtInSupport ||
isGLExtensionOrVersionSupported(contextID,"GL_IBM_texture_mirrored_repeat", 1.4f) ||
isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_mirrored_repeat", 1.4f);
isTextureEdgeClampSupported = builtInSupport ||
isGLExtensionOrVersionSupported(contextID,"GL_EXT_texture_edge_clamp", 1.2f) ||
isGLExtensionOrVersionSupported(contextID,"GL_SGIS_texture_edge_clamp", 1.2f);
isTextureBorderClampSupported = OSG_GL3_FEATURES || ((OSG_GL1_FEATURES || OSG_GL2_FEATURES) && isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_border_clamp", 1.3f));
isGenerateMipMapSupported = builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_SGIS_generate_mipmap", 1.4f);
preferGenerateMipmapSGISForPowerOfTwo = (radeonHardwareDetected||fireGLHardwareDetected) ? false : true;
isTextureMultisampledSupported = isGLExtensionSupported(contextID,"GL_ARB_texture_multisample");
isShadowSupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_ARB_shadow");
isShadowAmbientSupported = isGLExtensionSupported(contextID,"GL_ARB_shadow_ambient");
isClientStorageSupported = isGLExtensionSupported(contextID,"GL_APPLE_client_storage");
isNonPowerOfTwoTextureNonMipMappedSupported = builtInSupport || isGLExtensionOrVersionSupported(contextID,"GL_ARB_texture_non_power_of_two", 2.0) || isGLExtensionSupported(contextID,"GL_APPLE_texture_2D_limited_npot");
isNonPowerOfTwoTextureMipMappedSupported = builtInSupport || isNonPowerOfTwoTextureNonMipMappedSupported;
isTextureIntegerEXTSupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID, "GL_EXT_texture_integer");
if (rendererString.find("GeForce FX")!=std::string::npos)
{
isNonPowerOfTwoTextureMipMappedSupported = false;
OSG_INFO<<"Disabling _isNonPowerOfTwoTextureMipMappedSupported for GeForce FX hardware."<<std::endl;
}
maxTextureSize=0;
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&maxTextureSize);
char *ptr;
if( (ptr = getenv("OSG_MAX_TEXTURE_SIZE")) != 0)
{
GLint osg_max_size = atoi(ptr);
if (osg_max_size<maxTextureSize)
{
maxTextureSize = osg_max_size;
}
}
setGLExtensionFuncPtr(glTexStorage2D,"glTexStorage2D","glTexStorage2DARB");
setGLExtensionFuncPtr(glCompressedTexImage2D,"glCompressedTexImage2D","glCompressedTexImage2DARB");
setGLExtensionFuncPtr(glCompressedTexSubImage2D,"glCompressedTexSubImage2D","glCompressedTexSubImage2DARB");
setGLExtensionFuncPtr(glGetCompressedTexImage,"glGetCompressedTexImage","glGetCompressedTexImageARB");;
setGLExtensionFuncPtr(glTexImage2DMultisample, "glTexImage2DMultisample", "glTexImage2DMultisampleARB");
setGLExtensionFuncPtr(glTexParameterIiv, "glTexParameterIiv", "glTexParameterIivARB");
setGLExtensionFuncPtr(glTexParameterIuiv, "glTexParameterIuiv", "glTexParameterIuivARB");
if (glTexParameterIiv == NULL) setGLExtensionFuncPtr(glTexParameterIiv, "glTexParameterIivEXT");
if (glTexParameterIuiv == NULL) setGLExtensionFuncPtr(glTexParameterIuiv, "glTexParameterIuivEXT");
setGLExtensionFuncPtr(glBindImageTexture, "glBindImageTexture", "glBindImageTextureARB");
isTextureMaxLevelSupported = ( getGLVersionNumber() >= 1.2f );
isTextureStorageEnabled = isTexStorage2DSupported();
if ( (ptr = getenv("OSG_GL_TEXTURE_STORAGE")) != 0 && isTexStorage2DSupported())
{
if (strcmp(ptr,"OFF")==0 || strcmp(ptr,"DISABLE")==0 ) isTextureStorageEnabled = false;
else isTextureStorageEnabled = true;
}
// Texture3D extensions
isTexture3DFast = OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_EXT_texture3D");
if (isTexture3DFast) isTexture3DSupported = true;
else isTexture3DSupported = strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0;
maxTexture3DSize = 0;
glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &maxTexture3DSize);
setGLExtensionFuncPtr(glTexImage3D, "glTexImage3D","glTexImage3DEXT");
setGLExtensionFuncPtr(glTexSubImage3D, "glTexSubImage3D","glTexSubImage3DEXT");
setGLExtensionFuncPtr(glCompressedTexImage3D, "glCompressedTexImage3D","glCompressedTexImage3DARB");
setGLExtensionFuncPtr(glCompressedTexSubImage3D, "glCompressedTexSubImage3D","glCompressedTexSubImage3DARB");
setGLExtensionFuncPtr(glCopyTexSubImage3D, "glCopyTexSubImage3D","glCopyTexSubImage3DEXT");
// Texture2DArray extensions
isTexture2DArraySupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_EXT_texture_array");
max2DSize = 0;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max2DSize);
maxLayerCount = 0;
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, &maxLayerCount);
// Blending
isBlendColorSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES ||
isGLExtensionSupported(contextID,"GL_EXT_blend_color") ||
strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0;
setGLExtensionFuncPtr(glBlendColor, "glBlendColor", "glBlendColorEXT");
bool bultInSupport = OSG_GLES2_FEATURES || OSG_GL3_FEATURES;
isBlendEquationSupported = bultInSupport ||
isGLExtensionSupported(contextID, "GL_EXT_blend_equation") ||
strncmp((const char*)glGetString(GL_VERSION), "1.2", 3) >= 0;
isBlendEquationSeparateSupported = bultInSupport ||
isGLExtensionSupported(contextID, "GL_EXT_blend_equation_separate") ||
strncmp((const char*)glGetString(GL_VERSION), "2.0", 3) >= 0;
isSGIXMinMaxSupported = isGLExtensionSupported(contextID, "GL_SGIX_blend_alpha_minmax");
isLogicOpSupported = isGLExtensionSupported(contextID, "GL_EXT_blend_logic_op");
setGLExtensionFuncPtr(glBlendEquation, "glBlendEquation", "glBlendEquationEXT");
setGLExtensionFuncPtr(glBlendEquationSeparate, "glBlendEquationSeparate", "glBlendEquationSeparateEXT");
setGLExtensionFuncPtr(glBlendEquationi, "glBlendEquationi", "glBlendEquationiARB");
setGLExtensionFuncPtr(glBlendEquationSeparatei, "glBlendEquationSeparatei", "glBlendEquationSeparateiARB");
// glEnablei/glDisabli
setGLExtensionFuncPtr(glEnablei, "glEnablei");
setGLExtensionFuncPtr(glDisablei, "glDisablei");
// Stencil`
isStencilWrapSupported = isGLExtensionOrVersionSupported(contextID, "GL_EXT_stencil_wrap", 1.4f);
isStencilTwoSidedSupported = isGLExtensionSupported(contextID, "GL_EXT_stencil_two_side");
isOpenGL20Supported = getGLVersionNumber() >= 2.0;
isSeparateStencilSupported = isGLExtensionSupported(contextID, "GL_ATI_separate_stencil");
// function pointers
setGLExtensionFuncPtr(glActiveStencilFace, "glActiveStencilFaceEXT");
setGLExtensionFuncPtr(glStencilOpSeparate, "glStencilOpSeparate", "glStencilOpSeparateATI");
setGLExtensionFuncPtr(glStencilMaskSeparate, "glStencilMaskSeparate");
setGLExtensionFuncPtr(glStencilFuncSeparate, "glStencilFuncSeparate", "glStencilFuncSeparateATI");
setGLExtensionFuncPtr(glStencilFuncSeparateATI, "glStencilFuncSeparateATI");
// Color Mask
setGLExtensionFuncPtr(glColorMaski, "glColorMaski", "glColorMaskiARB");
// ClampColor
isClampColorSupported = OSG_GL3_FEATURES ||
isGLExtensionSupported(contextID,"GL_ARB_color_buffer_float") ||
strncmp((const char*)glGetString(GL_VERSION),"2.0",3)>=0;
setGLExtensionFuncPtr(glClampColor, "glClampColor", "glClampColorARB");
// PrimitiveRestartIndex
setGLExtensionFuncPtr(glPrimitiveRestartIndex, "glPrimitiveRestartIndex", "glPrimitiveRestartIndexNV");
// Point
isPointParametersSupported = OSG_GL3_FEATURES ||
strncmp((const char*)glGetString(GL_VERSION),"1.4",3)>=0 ||
isGLExtensionSupported(contextID,"GL_ARB_point_parameters") ||
isGLExtensionSupported(contextID,"GL_EXT_point_parameters") ||
isGLExtensionSupported(contextID,"GL_SGIS_point_parameters");
isPointSpriteSupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID, "GL_ARB_point_sprite") || isGLExtensionSupported(contextID, "GL_OES_point_sprite") || isGLExtensionSupported(contextID, "GL_NV_point_sprite");
isPointSpriteCoordOriginSupported = OSG_GL3_FEATURES || strncmp((const char*)glGetString(GL_VERSION),"2.0",3)>=0;
setGLExtensionFuncPtr(glPointParameteri, "glPointParameteri", "glPointParameteriARB");
if (!glPointParameteri) setGLExtensionFuncPtr(glPointParameteri, "glPointParameteriEXT", "glPointParameteriSGIS");
setGLExtensionFuncPtr(glPointParameterf, "glPointParameterf", "glPointParameterfARB");
if (!glPointParameterf) setGLExtensionFuncPtr(glPointParameterf, "glPointParameterfEXT", "glPointParameterfSGIS");
setGLExtensionFuncPtr(glPointParameterfv, "glPointParameterfv", "glPointParameterfvARB");
if (!glPointParameterfv) setGLExtensionFuncPtr(glPointParameterfv, "glPointParameterfvEXT", "glPointParameterfvSGIS");
// Multisample
isMultisampleSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_ARB_multisample");
isMultisampleFilterHintSupported = isGLExtensionSupported(contextID, "GL_NV_multisample_filter_hint");
setGLExtensionFuncPtr(glSampleCoverage, "glSampleCoverageARB");
// FrameBufferObject
setGLExtensionFuncPtr(glBindRenderbuffer, "glBindRenderbuffer", "glBindRenderbufferEXT", "glBindRenderbufferOES");
setGLExtensionFuncPtr(glDeleteRenderbuffers, "glDeleteRenderbuffers", "glDeleteRenderbuffersEXT", "glDeleteRenderbuffersOES");
setGLExtensionFuncPtr(glGenRenderbuffers, "glGenRenderbuffers", "glGenRenderbuffersEXT", "glGenRenderbuffersOES");
setGLExtensionFuncPtr(glRenderbufferStorage, "glRenderbufferStorage", "glRenderbufferStorageEXT", "glRenderbufferStorageOES");
setGLExtensionFuncPtr(glRenderbufferStorageMultisample, "glRenderbufferStorageMultisample", "glRenderbufferStorageMultisampleEXT", "glRenderbufferStorageMultisampleOES");
setGLExtensionFuncPtr(glRenderbufferStorageMultisampleCoverageNV, "glRenderbufferStorageMultisampleCoverageNV");
setGLExtensionFuncPtr(glBindFramebuffer, "glBindFramebuffer", "glBindFramebufferEXT", "glBindFramebufferOES");
setGLExtensionFuncPtr(glDeleteFramebuffers, "glDeleteFramebuffers", "glDeleteFramebuffersEXT", "glDeleteFramebuffersOES");
setGLExtensionFuncPtr(glGenFramebuffers, "glGenFramebuffers", "glGenFramebuffersEXT", "glGenFramebuffersOES");
setGLExtensionFuncPtr(glCheckFramebufferStatus, "glCheckFramebufferStatus", "glCheckFramebufferStatusEXT", "glCheckFramebufferStatusOES");
setGLExtensionFuncPtr(glFramebufferTexture1D, "glFramebufferTexture1D", "glFramebufferTexture1DEXT", "glFramebufferTexture1DOES");
setGLExtensionFuncPtr(glFramebufferTexture2D, "glFramebufferTexture2D", "glFramebufferTexture2DEXT", "glFramebufferTexture2DOES");
setGLExtensionFuncPtr(glFramebufferTexture3D, "glFramebufferTexture3D", "glFramebufferTexture3DEXT", "glFramebufferTexture3DOES");
setGLExtensionFuncPtr(glFramebufferTexture, "glFramebufferTexture", "glFramebufferTextureEXT", "glFramebufferTextureOES");
setGLExtensionFuncPtr(glFramebufferTextureLayer, "glFramebufferTextureLayer", "glFramebufferTextureLayerEXT", "glFramebufferTextureLayerOES");
setGLExtensionFuncPtr(glFramebufferTextureFace, "glFramebufferTextureFace", "glFramebufferTextureFaceEXT", "glFramebufferTextureFaceOES" );
setGLExtensionFuncPtr(glFramebufferRenderbuffer, "glFramebufferRenderbuffer", "glFramebufferRenderbufferEXT", "glFramebufferRenderbufferOES");
setGLExtensionFuncPtr(glGenerateMipmap, "glGenerateMipmap", "glGenerateMipmapEXT", "glGenerateMipmapOES");
setGLExtensionFuncPtr(glBlitFramebuffer, "glBlitFramebuffer", "glBlitFramebufferEXT", "glBlitFramebufferOES");
setGLExtensionFuncPtr(glGetRenderbufferParameteriv, "glGetRenderbufferParameteriv", "glGetRenderbufferParameterivEXT", "glGetRenderbufferParameterivOES");
isFrameBufferObjectSupported =
glBindRenderbuffer != 0 &&
glDeleteRenderbuffers != 0 &&
glGenRenderbuffers != 0 &&
glRenderbufferStorage != 0 &&
glBindFramebuffer != 0 &&
glDeleteFramebuffers != 0 &&
glGenFramebuffers != 0 &&
glCheckFramebufferStatus != 0 &&
glFramebufferTexture2D != 0 &&
glFramebufferRenderbuffer != 0 &&
glGenerateMipmap != 0 &&
glGetRenderbufferParameteriv != 0;
isPackedDepthStencilSupported = OSG_GL3_FEATURES ||
(isGLExtensionSupported(contextID, "GL_EXT_packed_depth_stencil")) ||
(isGLExtensionSupported(contextID, "GL_OES_packed_depth_stencil"));
// Sync
osg::setGLExtensionFuncPtr(glFenceSync, "glFenceSync");
osg::setGLExtensionFuncPtr(glIsSync, "glIsSync");
osg::setGLExtensionFuncPtr(glDeleteSync, "glDeleteSync");
osg::setGLExtensionFuncPtr(glClientWaitSync, "glClientWaitSync");
osg::setGLExtensionFuncPtr(glWaitSync, "glWaitSync");
osg::setGLExtensionFuncPtr(glGetSynciv, "glGetSynciv");
}
///////////////////////////////////////////////////////////////////////////
// C++-friendly convenience methods
GLuint GLExtensions::getCurrentProgram() const
{
if( glVersion >= 2.0f )
{
// GLSL as GL v2.0 core functionality
GLint result = 0;
glGetIntegerv( GL_CURRENT_PROGRAM, &result );
return static_cast<GLuint>(result);
}
else if (glGetHandleARB)
{
// fallback for GLSL as GL v1.5 ARB extension
#ifndef GL_PROGRAM_OBJECT_ARB
#define GL_PROGRAM_OBJECT_ARB 0x8B40
#endif
return glGetHandleARB( GL_PROGRAM_OBJECT_ARB );
}
else
{
OSG_WARN<<"Warning GLExtensions::getCurrentProgram not supported"<<std::endl;;
return 0;
}
}
bool GLExtensions::getProgramInfoLog( GLuint program, std::string& result ) const
{
GLsizei bufLen = 0; // length of buffer to allocate
GLsizei strLen = 0; // strlen GL actually wrote to buffer
glGetProgramiv( program, GL_INFO_LOG_LENGTH, &bufLen );
if( bufLen > 1 )
{
GLchar* infoLog = new GLchar[bufLen];
glGetProgramInfoLog( program, bufLen, &strLen, infoLog );
if( strLen > 0 ) result = reinterpret_cast<char*>(infoLog);
delete [] infoLog;
}
return (strLen > 0);
}
bool GLExtensions::getShaderInfoLog( GLuint shader, std::string& result ) const
{
GLsizei bufLen = 0; // length of buffer to allocate
GLsizei strLen = 0; // strlen GL actually wrote to buffer
glGetShaderiv( shader, GL_INFO_LOG_LENGTH, &bufLen );
if( bufLen > 1 )
{
GLchar* infoLog = new GLchar[bufLen];
glGetShaderInfoLog( shader, bufLen, &strLen, infoLog );
if( strLen > 0 ) result = reinterpret_cast<char*>(infoLog);
delete [] infoLog;
}
return (strLen > 0);
}
bool GLExtensions::getAttribLocation( const char* attribName, GLuint& location ) const
{
// is there an active GLSL program?
GLuint program = getCurrentProgram();
if( glIsProgram(program) == GL_FALSE ) return false;
// has that program been successfully linked?
GLint linked = GL_FALSE;
glGetProgramiv( program, GL_LINK_STATUS, &linked );
if( linked == GL_FALSE ) return false;
// is there such a named attribute?
GLint loc = glGetAttribLocation( program, reinterpret_cast<const GLchar*>(attribName) );
if( loc < 0 ) return false;
location = loc;
return true;
}
bool GLExtensions::getFragDataLocation( const char* fragDataName, GLuint& location ) const
{
// is there an active GLSL program?
GLuint program = getCurrentProgram();
if( glIsProgram(program) == GL_FALSE ) return false;
// has that program been successfully linked?
GLint linked = GL_FALSE;
glGetProgramiv( program, GL_LINK_STATUS, &linked );
if( linked == GL_FALSE ) return false;
// check if supported
if (glGetFragDataLocation == NULL) return false;
// is there such a named attribute?
GLint loc = glGetFragDataLocation( program, reinterpret_cast<const GLchar*>(fragDataName) );
if( loc < 0 ) return false;
location = loc;
return true;
}

View File

@@ -661,7 +661,7 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const
{
State& state = *renderInfo.getState();
unsigned int contextID = state.getContextID();
GL2Extensions* extensions = state.get<GL2Extensions>();
GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions) return;
typedef std::set<BufferObject*> BufferObjects;

View File

@@ -993,7 +993,7 @@ void SyncSwapBuffersCallback::swapBuffersImplementation(osg::GraphicsContext* gc
gc->swapBuffersImplementation();
//glFinish();
GL2Extensions* ext = gc->getState()->get<GL2Extensions>();
GLExtensions* ext = gc->getState()->get<GLExtensions>();
if (ext->glClientWaitSync)
{

View File

@@ -1053,7 +1053,7 @@ void Image::readImageFromCurrentTexture(unsigned int contextID, bool copyMipMaps
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
// OSG_NOTICE<<"Image::readImageFromCurrentTexture()"<<std::endl;
const osg::GL2Extensions* extensions = osg::GL2Extensions::Get(contextID,true);
const osg::GLExtensions* extensions = osg::GLExtensions::Get(contextID,true);
GLboolean binding1D = GL_FALSE, binding2D = GL_FALSE, binding3D = GL_FALSE, binding2DArray = GL_FALSE, bindingCubeMap = GL_FALSE;

View File

@@ -31,7 +31,7 @@ Multisample::~Multisample()
void Multisample::apply(State& state) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isMultisampleSupported)
{
OSG_WARN<<"Warning: Multisample::apply(..) failed, Multisample is not support by OpenGL driver."<<std::endl;

View File

@@ -100,7 +100,7 @@ struct RetrieveQueriesCallback : public osg::Camera::DrawCallback
typedef std::vector<osg::TestResult*> ResultsVector;
ResultsVector _results;
RetrieveQueriesCallback( osg::GL2Extensions* ext=NULL )
RetrieveQueriesCallback( osg::GLExtensions* ext=NULL )
: _extensionsFallback( ext )
{
}
@@ -118,24 +118,24 @@ struct RetrieveQueriesCallback : public osg::Camera::DrawCallback
double elapsedTime( 0. );
int count( 0 );
const osg::GL2Extensions* ext=0;
const osg::GLExtensions* ext=0;
if (camera.getGraphicsContext())
{
// The typical path, for osgViewer-based applications or any
// app that has set up a valid GraphicsCOntext for the Camera.
ext = camera.getGraphicsContext()->getState()->get<osg::GL2Extensions>();
ext = camera.getGraphicsContext()->getState()->get<osg::GLExtensions>();
}
else
{
// No valid GraphicsContext in the Camera. This might happen in
// SceneView-based apps. Rely on the creating code to have passed
// in a valid GL2Extensions pointer, and hope it's valid for any
// in a valid GLExtensions pointer, and hope it's valid for any
// context that might be current.
OSG_DEBUG << "osgOQ: RQCB: Using fallback path to obtain GL2Extensions pointer." << std::endl;
OSG_DEBUG << "osgOQ: RQCB: Using fallback path to obtain GLExtensions pointer." << std::endl;
ext = _extensionsFallback;
if (!ext)
{
OSG_FATAL << "osgOQ: RQCB: GL2Extensions pointer fallback is NULL." << std::endl;
OSG_FATAL << "osgOQ: RQCB: GLExtensions pointer fallback is NULL." << std::endl;
return;
}
}
@@ -204,7 +204,7 @@ struct RetrieveQueriesCallback : public osg::Camera::DrawCallback
_results.push_back( tr );
}
osg::GL2Extensions* _extensionsFallback;
osg::GLExtensions* _extensionsFallback;
};
@@ -279,7 +279,7 @@ void
QueryGeometry::drawImplementation( osg::RenderInfo& renderInfo ) const
{
unsigned int contextID = renderInfo.getState()->getContextID();
osg::GL2Extensions* ext = renderInfo.getState()->get<GL2Extensions>();
osg::GLExtensions* ext = renderInfo.getState()->get<GLExtensions>();
osg::Camera* cam = renderInfo.getCurrentCamera();
// Add callbacks if necessary.
@@ -412,7 +412,7 @@ QueryGeometry::flushDeletedQueryObjects( unsigned int contextID, double /*curren
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedQueryObjectCache);
const osg::GL2Extensions* extensions = osg::GL2Extensions::Get( contextID, true );
const osg::GLExtensions* extensions = osg::GLExtensions::Get( contextID, true );
QueryObjectList& qol = s_deletedQueryObjectCache[contextID];

View File

@@ -31,7 +31,7 @@ PatchParameter::~PatchParameter()
void PatchParameter::apply(State& state) const
{
GL2Extensions* extensions = state.get<GL2Extensions>();
GLExtensions* extensions = state.get<GLExtensions>();
if (extensions->areTessellationShadersSupported )
{

View File

@@ -84,7 +84,7 @@ void Point::apply(State& state) const
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
glPointSize(_size);
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isPointParametersSupported)
return;

View File

@@ -42,7 +42,7 @@ int PointSprite::compare(const StateAttribute& sa) const
bool PointSprite::checkValidityOfAssociatedModes(osg::State& state) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
bool modeValid = extensions->isPointSpriteSupported;
#if defined( OSG_GLES1_AVAILABLE ) //point sprites don't exist on es 2.0
@@ -56,7 +56,7 @@ bool PointSprite::checkValidityOfAssociatedModes(osg::State& state) const
void PointSprite::apply(osg::State& state) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
#if defined( OSG_GL3_AVAILABLE )
extensions->glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, _coordOriginMode);

View File

@@ -52,7 +52,7 @@ int PrimitiveRestartIndex::compare(const StateAttribute& sa) const
void PrimitiveRestartIndex::apply(State& state) const
{
// get "per-context" extensions
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (extensions->glPrimitiveRestartIndex)
{
extensions->glPrimitiveRestartIndex( _restartIndex );

View File

@@ -30,7 +30,7 @@
#include <osg/ref_ptr>
#include <osg/Program>
#include <osg/Shader>
#include <osg/GL2Extensions>
#include <osg/GLExtensions>
#include <OpenThreads/ScopedLock>
#include <OpenThreads/Mutex>
@@ -66,7 +66,7 @@ void Program::flushDeletedGlPrograms(unsigned int contextID,double /*currentTime
if (availableTime<=0.0) return;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedGlProgramCache);
const GL2Extensions* extensions = GL2Extensions::Get(contextID,true);
const GLExtensions* extensions = GLExtensions::Get(contextID,true);
if( ! extensions->isGlslSupported ) return;
const osg::Timer& timer = *osg::Timer::instance();
@@ -441,7 +441,7 @@ void Program::removeBindUniformBlock(const std::string& name)
void Program::apply( osg::State& state ) const
{
const unsigned int contextID = state.getContextID();
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if( ! extensions->isGlslSupported ) return;
if( isFixedFunction() )
@@ -534,7 +534,7 @@ Program::PerContextProgram::PerContextProgram(const Program* program, unsigned i
_program = program;
if (_glProgramHandle == 0)
{
_extensions = GL2Extensions::Get( _contextID, true );
_extensions = GLExtensions::Get( _contextID, true );
_glProgramHandle = _extensions->glCreateProgram();
_ownsProgramHandle = true;
}

View File

@@ -51,7 +51,7 @@ int SampleMaski::compare(const StateAttribute& sa) const
void SampleMaski::apply(State& state) const
{
// get "per-context" extensions
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if ( (extensions->isTextureMultisampleSupported) || (extensions->isOpenGL32upported) || (extensions->isSampleMaskiSupported) )
{

View File

@@ -177,7 +177,7 @@ void Shader::flushDeletedGlShaders(unsigned int contextID,double /*currentTime*/
// if no time available don't try to flush objects.
if (availableTime<=0.0) return;
const GL2Extensions* extensions = GL2Extensions::Get(contextID,true);
const GLExtensions* extensions = GLExtensions::Get(contextID,true);
if( ! extensions->isGlslSupported ) return;
const osg::Timer& timer = *osg::Timer::instance();
@@ -458,7 +458,7 @@ Shader::PerContextShader::PerContextShader(const Shader* shader, unsigned int co
_contextID( contextID )
{
_shader = shader;
_extensions = GL2Extensions::Get( _contextID, true );
_extensions = GLExtensions::Get( _contextID, true );
_glShaderHandle = _extensions->glCreateShader( shader->getType() );
requestCompile();
}

View File

@@ -131,9 +131,9 @@ State::State():
State::~State()
{
// delete the GL2Extensions object associated with this osg::State.
GL2Extensions::Set(_contextID, 0);
_gl2Extentsions = 0;
// delete the GLExtensions object associated with this osg::State.
GLExtensions::Set(_contextID, 0);
_glExtensions = 0;
//_texCoordArrayList.clear();
@@ -922,8 +922,8 @@ void State::initializeExtensionProcs()
{
if (_extensionProcsInitialized) return;
_gl2Extentsions = new GL2Extensions(_contextID);
GL2Extensions::Set(_contextID, _gl2Extentsions.get());
_glExtensions = new GLExtensions(_contextID);
GLExtensions::Set(_contextID, _glExtensions.get());
setGLExtensionFuncPtr(_glClientActiveTexture,"glClientActiveTexture","glClientActiveTextureARB");
setGLExtensionFuncPtr(_glActiveTexture, "glActiveTexture","glActiveTextureARB");
@@ -966,7 +966,7 @@ void State::initializeExtensionProcs()
_glMaxTextureCoords = 1;
}
if (_gl2Extentsions->isARBTimerQuerySupported)
if (_glExtensions->isARBTimerQuerySupported)
{
const GLubyte* renderer = glGetString(GL_RENDERER);
std::string rendererString = renderer ? (const char*)renderer : "";
@@ -981,7 +981,7 @@ void State::initializeExtensionProcs()
else
{
GLint bits = 0;
_gl2Extentsions->glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS_ARB, &bits);
_glExtensions->glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS_ARB, &bits);
setTimestampBits(bits);
}
}
@@ -1760,7 +1760,7 @@ void State::frameCompleted()
if (getTimestampBits())
{
GLint64 timestamp;
_gl2Extentsions->glGetInteger64v(GL_TIMESTAMP, &timestamp);
_glExtensions->glGetInteger64v(GL_TIMESTAMP, &timestamp);
setGpuTimestamp(osg::Timer::instance()->tick(), timestamp);
//OSG_NOTICE<<"State::frameCompleted() setting time stamp. timestamp="<<timestamp<<std::endl;
}

View File

@@ -37,7 +37,7 @@ Stencil::~Stencil()
{
}
static Stencil::Operation validateOperation(const GL2Extensions* extensions, Stencil::Operation op)
static Stencil::Operation validateOperation(const GLExtensions* extensions, Stencil::Operation op)
{
// only wrap requires validation
if (op != Stencil::INCR_WRAP && op != Stencil::DECR_WRAP)
@@ -52,7 +52,7 @@ static Stencil::Operation validateOperation(const GL2Extensions* extensions, Ste
void Stencil::apply(State& state) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
Operation sf = validateOperation(extensions, _sfail);
Operation zf = validateOperation(extensions, _zfail);
Operation zp = validateOperation(extensions, _zpass);

View File

@@ -88,7 +88,7 @@ void StencilTwoSided::apply(State& state) const
{
// get "per-context" extensions
const unsigned int contextID = state.getContextID();
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
// use OpenGL 2.0 functions if available
if (extensions->isOpenGL20Supported)

View File

@@ -1465,7 +1465,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
{
const unsigned int contextID = 0; // state.getContextID(); // set to 0 right now, assume same parameters for each graphics context...
const GL2Extensions* extensions = GL2Extensions::Get(contextID,true);
const GLExtensions* extensions = GLExtensions::Get(contextID,true);
switch(_internalFormatMode)
{
@@ -1873,7 +1873,7 @@ void Texture::applyTexParameters(GLenum target, State& state) const
// get the contextID (user defined ID of 0 upwards) for the
// current OpenGL context.
const unsigned int contextID = state.getContextID();
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
WrapMode ws = _wrap_s, wt = _wrap_t, wr = _wrap_r;
@@ -2016,7 +2016,7 @@ void Texture::applyTexParameters(GLenum target, State& state) const
void Texture::computeRequiredTextureDimensions(State& state, const osg::Image& image,GLsizei& inwidth, GLsizei& inheight,GLsizei& numMipmapLevels) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
int width,height;
@@ -2078,7 +2078,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
#endif
// get extensions object
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
// select the internalFormat required for the texture.
bool compressed_image = isCompressedInternalFormat((GLenum)image->getPixelFormat());
@@ -2485,7 +2485,7 @@ void Texture::applyTexImage2D_subload(State& state, GLenum target, const Image*
// get the contextID (user defined ID of 0 upwards) for the
// current OpenGL context.
const unsigned int contextID = state.getContextID();
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
// select the internalFormat required for the texture.
bool compressed_image = isCompressedInternalFormat((GLenum)image->getPixelFormat());
@@ -2671,7 +2671,7 @@ bool Texture::isHardwareMipmapGenerationEnabled(const State& state) const
{
if (_useHardwareMipMapGeneration)
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (extensions->isGenerateMipMapSupported)
{
return true;
@@ -2694,7 +2694,7 @@ Texture::GenerateMipmapMode Texture::mipmapBeforeTexImage(const State& state, bo
return GENERATE_MIPMAP;
#else
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
bool useGenerateMipMap = extensions->glGenerateMipmap!=0;
if (useGenerateMipMap)
@@ -2731,7 +2731,7 @@ void Texture::mipmapAfterTexImage(State& state, GenerateMipmapMode beforeResult)
TextureObject* textureObject = getTextureObject(contextID);
if (textureObject)
{
osg::GL2Extensions* ext = state.get<GL2Extensions>();
osg::GLExtensions* ext = state.get<GLExtensions>();
ext->glGenerateMipmap(textureObject->target());
}
break;
@@ -2764,7 +2764,7 @@ void Texture::generateMipmap(State& state) const
}
// get fbo extension which provides us with the glGenerateMipmapEXT function
osg::GL2Extensions* ext = state.get<GL2Extensions>();
osg::GLExtensions* ext = state.get<GLExtensions>();
// check if the function is supported
if (ext->glGenerateMipmap)

View File

@@ -278,7 +278,7 @@ void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsiz
return;
// get extension object
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
// compute the internal texture format, this set the _internalFormat to an appropriate value.
computeInternalFormat();

View File

@@ -225,7 +225,7 @@ void Texture2DArray::apply(State& state) const
ElapsedTime elapsedTime(&(tom->getApplyTime()));
tom->getNumberApplied()++;
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
// if not supported, then return
if (!extensions->isTexture2DArraySupported || !extensions->isTexture3DSupported)
@@ -367,7 +367,7 @@ void Texture2DArray::apply(State& state) const
}
}
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
// source images have no mipmamps but we could generate them...
if( _min_filter != LINEAR && _min_filter != NEAREST && !_images[0]->isMipmap() &&
_useHardwareMipMapGeneration && extensions->isGenerateMipMapSupported )
@@ -434,7 +434,7 @@ void Texture2DArray::applyTexImage2DArray_subload(State& state, Image* image, GL
// get the contextID (user defined ID of 0 upwards) for the
// current OpenGL context.
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
GLenum target = GL_TEXTURE_2D_ARRAY_EXT;
// compute the internal texture format, this set the _internalFormat to an appropriate value.
@@ -582,7 +582,7 @@ void Texture2DArray::applyTexImage2DArray_subload(State& state, Image* image, GL
void Texture2DArray::copyTexSubImage2DArray(State& state, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height )
{
const unsigned int contextID = state.getContextID();
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
// get the texture object for the current contextID.
TextureObject* textureObject = getTextureObject(contextID);
@@ -614,7 +614,7 @@ void Texture2DArray::allocateMipmap(State& state) const
if (textureObject && _textureWidth != 0 && _textureHeight != 0 && _textureDepth != 0)
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
int safeSourceFormat = _sourceFormat ? _sourceFormat : _internalFormat;

View File

@@ -86,7 +86,7 @@ void Texture2DMultisample::apply(State& state) const
{
// current OpenGL context.
const unsigned int contextID = state.getContextID();
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isTextureMultisampledSupported)
{
OSG_INFO<<"Texture2DMultisample not supoorted."<<std::endl;

View File

@@ -141,7 +141,7 @@ void Texture3D::setImage(Image* image)
void Texture3D::computeRequiredTextureDimensions(State& state, const osg::Image& image,GLsizei& inwidth, GLsizei& inheight,GLsizei& indepth, GLsizei& numMipmapLevels) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
int width,height,depth;
@@ -208,7 +208,7 @@ void Texture3D::apply(State& state) const
ElapsedTime elapsedTime(&(tom->getApplyTime()));
tom->getNumberApplied()++;
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isTexture3DSupported)
{
@@ -365,7 +365,7 @@ void Texture3D::applyTexImage3D(GLenum target, Image* image, State& state, GLsiz
// get the contextID (user defined ID of 0 upwards) for the
// current OpenGL context.
const unsigned int contextID = state.getContextID();
const GL2Extensions* extensions = GL2Extensions::Get(contextID,true);
const GLExtensions* extensions = GLExtensions::Get(contextID,true);
// compute the internal texture format, this set the _internalFormat to an appropriate value.
computeInternalFormat();
@@ -486,7 +486,7 @@ void Texture3D::applyTexImage3D(GLenum target, Image* image, State& state, GLsiz
void Texture3D::copyTexSubImage3D(State& state, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height )
{
const unsigned int contextID = state.getContextID();
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
// get the texture object for the current contextID.
TextureObject* textureObject = getTextureObject(contextID);
@@ -520,7 +520,7 @@ void Texture3D::allocateMipmap(State& state) const
if (textureObject && _textureWidth != 0 && _textureHeight != 0 && _textureDepth != 0)
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
// bind texture
textureObject->bind();

View File

@@ -122,7 +122,7 @@ void TextureBuffer::apply(State& state) const
if( getTextureParameterDirty(contextID) )
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (extensions->isBindImageTextureSupported() && _imageAttachment.access!=0)
{
extensions->glBindImageTexture(
@@ -142,7 +142,7 @@ void TextureBuffer::apply(State& state) const
textureBufferObject = new TextureBufferObject(contextID,_usageHint);
_textureBufferObjects[contextID] = textureBufferObject;
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (extensions->isBindImageTextureSupported() && _imageAttachment.access!=0)
{
extensions->glBindImageTexture(

View File

@@ -203,7 +203,7 @@ void TextureCubeMap::apply(State& state) const
ElapsedTime elapsedTime(&(tom->getApplyTime()));
tom->getNumberApplied()++;
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isCubeMapSupported)
return;
@@ -366,7 +366,7 @@ void TextureCubeMap::apply(State& state) const
void TextureCubeMap::copyTexSubImageCubeMap(State& state, int face, int xoffset, int yoffset, int x, int y, int width, int height )
{
const unsigned int contextID = state.getContextID();
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isCubeMapSupported)
return;

View File

@@ -157,7 +157,7 @@ void TextureRectangle::setImage(Image* image)
void TextureRectangle::apply(State& state) const
{
if (!state.get<GL2Extensions>()->isRectangleSupported)
if (!state.get<GLExtensions>()->isRectangleSupported)
{
OSG_WARN<<"Warning: TextureRectangle::apply(..) failed, texture rectangle is not support by your OpenGL drivers."<<std::endl;
return;
@@ -308,7 +308,7 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st
// get the contextID (user defined ID of 0 upwards) for the
// current OpenGL context.
const unsigned int contextID = state.getContextID();
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
// update the modified count to show that it is upto date.
getModifiedCount(contextID) = image->getModifiedCount();
@@ -390,7 +390,7 @@ void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State&
// get the contextID (user defined ID of 0 upwards) for the
// current OpenGL context.
const unsigned int contextID = state.getContextID();
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
// update the modified count to show that it is upto date.

View File

@@ -973,7 +973,7 @@ unsigned int Uniform::getNameID(const std::string& name)
typedef std::map<std::string, unsigned int> UniformNameIDMap;
static OpenThreads::Mutex s_mutex_uniformNameIDMap;
static UniformNameIDMap s_uniformNameIDMap;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_uniformNameIDMap);
UniformNameIDMap::iterator it = s_uniformNameIDMap.find(name);
if (it != s_uniformNameIDMap.end())
@@ -2456,7 +2456,7 @@ unsigned int Uniform::getNameID() const
///////////////////////////////////////////////////////////////////////////
void Uniform::apply(const GL2Extensions* ext, GLint location) const
void Uniform::apply(const GLExtensions* ext, GLint location) const
{
// OSG_NOTICE << "uniform at "<<location<<" "<<_name<< std::endl;

View File

@@ -11,7 +11,7 @@
* OpenSceneGraph Public License for more details.
*/
#include <osg/VertexAttribDivisor>
#include <osg/GL2Extensions>
#include <osg/GLExtensions>
#include <osg/State>
using namespace osg;
@@ -34,7 +34,7 @@ VertexAttribDivisor::~VertexAttribDivisor()
void VertexAttribDivisor::apply(State& state) const
{
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (extensions->glVertexAttribDivisor)
{
extensions->glVertexAttribDivisor( _index, _divisor );

View File

@@ -56,7 +56,7 @@ void VertexProgram::flushDeletedVertexProgramObjects(unsigned int contextID,doub
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexProgramObjectCache);
const GL2Extensions* extensions = GL2Extensions::Get(contextID,true);
const GLExtensions* extensions = GLExtensions::Get(contextID,true);
VertexProgramObjectList& vpol = s_deletedVertexProgramObjectCache[contextID];
@@ -127,7 +127,7 @@ void VertexProgram::apply(State& state) const
{
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
const GL2Extensions* extensions = state.get<GL2Extensions>();
const GLExtensions* extensions = state.get<GLExtensions>();
if (!extensions->isVertexProgramSupported)
return;

View File

@@ -114,7 +114,7 @@ namespace
{
if (!Technique::validate(state)) return false;
osg::GL2Extensions *ext = state.get<osg::GL2Extensions>();
osg::GLExtensions *ext = state.get<osg::GLExtensions>();
return ext ? ext->isCubeMapSupported : false;
}

View File

@@ -838,7 +838,7 @@ void PrecipitationEffect::PrecipitationDrawable::drawImplementation(osg::RenderI
if (!_geometry) return;
const osg::GL2Extensions* extensions = renderInfo.getState()->get<osg::GL2Extensions>();
const osg::GLExtensions* extensions = renderInfo.getState()->get<osg::GLExtensions>();
// save OpenGL matrices
glPushMatrix();

View File

@@ -147,7 +147,7 @@ void GlyphTexture::apply(osg::State& state) const
}
const osg::GL2Extensions* extensions = state.get<osg::GL2Extensions>();
const osg::GLExtensions* extensions = state.get<osg::GLExtensions>();
bool generateMipMapSupported = extensions->isGenerateMipMapSupported;
// get the texture object for the current contextID.

View File

@@ -46,7 +46,7 @@ void GLObjectsVisitor::apply(osg::Node& node)
if (programSetBefore && !programSetAfter)
{
osg::State* state = _renderInfo.getState();
osg::GL2Extensions* extensions = state->get<osg::GL2Extensions>();
osg::GLExtensions* extensions = state->get<osg::GLExtensions>();
extensions->glUseProgram(0);
state->setLastAppliedProgramObject(0);
_lastCompiledProgram = 0;
@@ -68,7 +68,7 @@ void GLObjectsVisitor::apply(osg::Geode& node)
if (!programSetBefore && programSetAfter)
{
osg::State* state = _renderInfo.getState();
osg::GL2Extensions* extensions = state->get<osg::GL2Extensions>();
osg::GLExtensions* extensions = state->get<osg::GLExtensions>();
extensions->glUseProgram(0);
state->setLastAppliedProgramObject(0);
_lastCompiledProgram = 0;
@@ -157,7 +157,7 @@ void GLObjectsVisitor::apply(osg::StateSet& stateset)
else if(_renderInfo.getState()->getLastAppliedProgramObject())
{
osg::State* state = _renderInfo.getState();
osg::GL2Extensions* extensions = state->get<osg::GL2Extensions>();
osg::GLExtensions* extensions = state->get<osg::GLExtensions>();
extensions->glUseProgram(0);
_renderInfo.getState()->setLastAppliedProgramObject(0);
}

View File

@@ -338,7 +338,7 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
if (renderTargetImplementation==osg::Camera::FRAME_BUFFER_OBJECT)
{
osg::GL2Extensions* ext = state.get<osg::GL2Extensions>();
osg::GLExtensions* ext = state.get<osg::GLExtensions>();
bool fbo_supported = ext->isFrameBufferObjectSupported;
if (fbo_supported)
@@ -903,7 +903,7 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
osg::State& state = *renderInfo.getState();
osg::GL2Extensions* ext = _fbo.valid() ? state.get<osg::GL2Extensions>() : 0;
osg::GLExtensions* ext = _fbo.valid() ? state.get<osg::GLExtensions>() : 0;
bool fbo_supported = ext && ext->isFrameBufferObjectSupported;
bool using_multiple_render_targets = fbo_supported && _fbo->hasMultipleRenderingTargets();

View File

@@ -132,7 +132,7 @@ void EXTQuerySupport::endQuery(osg::State* /*state*/)
void OpenGLQuerySupport::initialize(osg::State* state, osg::Timer_t /*startTick*/)
{
_extensions = state->get<osg::GL2Extensions>();
_extensions = state->get<osg::GLExtensions>();
}
void EXTQuerySupport::initialize(osg::State* state, osg::Timer_t startTick)
@@ -464,7 +464,7 @@ void Renderer::initialize(osg::State* state)
if (!_initialized)
{
_initialized = true;
osg::GL2Extensions* ext = state->get<osg::GL2Extensions>();
osg::GLExtensions* ext = state->get<osg::GLExtensions>();
if (ext->isARBTimerQuerySupported && state->getTimestampBits() > 0)
_querySupport = new ARBQuerySupport();
else if (ext->isTimerQuerySupported)

View File

@@ -72,8 +72,8 @@ class WindowCaptureCallback : public osg::Camera::DrawCallback
void read();
void readPixels();
void singlePBO(osg::GL2Extensions* ext);
void multiPBO(osg::GL2Extensions* ext);
void singlePBO(osg::GLExtensions* ext);
void multiPBO(osg::GLExtensions* ext);
typedef std::vector< osg::ref_ptr<osg::Image> > ImageBuffer;
typedef std::vector< GLuint > PBOBuffer;
@@ -218,7 +218,7 @@ void WindowCaptureCallback::ContextData::updateTimings(osg::Timer_t tick_start,
void WindowCaptureCallback::ContextData::read()
{
osg::GL2Extensions* ext = osg::GL2Extensions::Get(_gc->getState()->getContextID(),true);
osg::GLExtensions* ext = osg::GLExtensions::Get(_gc->getState()->getContextID(),true);
if (ext->isPBOSupported && !_pboBuffer.empty())
{
@@ -275,7 +275,7 @@ void WindowCaptureCallback::ContextData::readPixels()
_currentPboIndex = nextPboIndex;
}
void WindowCaptureCallback::ContextData::singlePBO(osg::GL2Extensions* ext)
void WindowCaptureCallback::ContextData::singlePBO(osg::GLExtensions* ext)
{
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
@@ -350,7 +350,7 @@ void WindowCaptureCallback::ContextData::singlePBO(osg::GL2Extensions* ext)
_currentImageIndex = nextImageIndex;
}
void WindowCaptureCallback::ContextData::multiPBO(osg::GL2Extensions* ext)
void WindowCaptureCallback::ContextData::multiPBO(osg::GLExtensions* ext)
{
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
unsigned int nextPboIndex = (_currentPboIndex+1)%_pboBuffer.size();

View File

@@ -1102,7 +1102,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
if ((*citr)->getGraphicsContext())
{
const osg::State* state = (*citr)->getGraphicsContext()->getState();
const osg::GL2Extensions* extensions = state->get<osg::GL2Extensions>();
const osg::GLExtensions* extensions = state->get<osg::GLExtensions>();
if (extensions &&
(((extensions->isARBTimerQuerySupported && state->getTimestampBits() > 0)) || extensions->isTimerQuerySupported))
{