Introduced OSG_GL*_FEATURES macros defined in include/GL that are set to 0 or 1 according to what the assocoated version of GL is compiled against.
Removed EXT postfix of FrameBufferObject functions, and added support for checking non EXT versions frame buffer object GL functions. Introduced usage of OSG_GL*_FEATURES to avoid some #if #else #endif code blocks. Using a submissions from Paul Martz as a guide added perliminary GL3 support to a range of OSG classes
This commit is contained in:
@@ -38,76 +38,62 @@ FBOExtensions* FBOExtensions::instance(unsigned contextID, bool createIfNotInita
|
||||
/**************************************************************************
|
||||
* FBOExtensions
|
||||
**************************************************************************/
|
||||
#define LOAD_FBO_EXT(name) setGLExtensionFuncPtr(name, (#name))
|
||||
#define LOAD_FBO_EXT(name) setGLExtensionFuncPtr(name, (#name), ( std::string(#name)+std::string("EXT") ).c_str() )
|
||||
|
||||
FBOExtensions::FBOExtensions(unsigned int contextID)
|
||||
: glBindRenderbufferEXT(0),
|
||||
glGenRenderbuffersEXT(0),
|
||||
glDeleteRenderbuffersEXT(0),
|
||||
glRenderbufferStorageEXT(0),
|
||||
glRenderbufferStorageMultisampleEXT(0),
|
||||
: glBindRenderbuffer(0),
|
||||
glGenRenderbuffers(0),
|
||||
glDeleteRenderbuffers(0),
|
||||
glRenderbufferStorage(0),
|
||||
glRenderbufferStorageMultisample(0),
|
||||
glRenderbufferStorageMultisampleCoverageNV(0),
|
||||
glBindFramebufferEXT(0),
|
||||
glDeleteFramebuffersEXT(0),
|
||||
glGenFramebuffersEXT(0),
|
||||
glCheckFramebufferStatusEXT(0),
|
||||
glFramebufferTexture1DEXT(0),
|
||||
glFramebufferTexture2DEXT(0),
|
||||
glFramebufferTexture3DEXT(0),
|
||||
glFramebufferTextureLayerEXT(0),
|
||||
glFramebufferRenderbufferEXT(0),
|
||||
glGenerateMipmapEXT(0),
|
||||
glBlitFramebufferEXT(0),
|
||||
glBindFramebuffer(0),
|
||||
glDeleteFramebuffers(0),
|
||||
glGenFramebuffers(0),
|
||||
glCheckFramebufferStatus(0),
|
||||
glFramebufferTexture1D(0),
|
||||
glFramebufferTexture2D(0),
|
||||
glFramebufferTexture3D(0),
|
||||
glFramebufferTextureLayer(0),
|
||||
glFramebufferRenderbuffer(0),
|
||||
glGenerateMipmap(0),
|
||||
glBlitFramebuffer(0),
|
||||
_supported(false),
|
||||
_packed_depth_stencil_supported(false)
|
||||
{
|
||||
if (!isGLExtensionSupported(contextID, "GL_EXT_framebuffer_object"))
|
||||
return;
|
||||
|
||||
LOAD_FBO_EXT(glBindRenderbufferEXT);
|
||||
LOAD_FBO_EXT(glGenRenderbuffersEXT);
|
||||
LOAD_FBO_EXT(glDeleteRenderbuffersEXT);
|
||||
LOAD_FBO_EXT(glRenderbufferStorageEXT);
|
||||
LOAD_FBO_EXT(glBindFramebufferEXT);
|
||||
LOAD_FBO_EXT(glDeleteFramebuffersEXT);
|
||||
LOAD_FBO_EXT(glGenFramebuffersEXT);
|
||||
LOAD_FBO_EXT(glCheckFramebufferStatusEXT);
|
||||
LOAD_FBO_EXT(glFramebufferTexture1DEXT);
|
||||
LOAD_FBO_EXT(glFramebufferTexture2DEXT);
|
||||
LOAD_FBO_EXT(glFramebufferTexture3DEXT);
|
||||
LOAD_FBO_EXT(glFramebufferTextureLayerEXT);
|
||||
LOAD_FBO_EXT(glFramebufferRenderbufferEXT);
|
||||
LOAD_FBO_EXT(glGenerateMipmapEXT);
|
||||
LOAD_FBO_EXT(glBindRenderbuffer);
|
||||
LOAD_FBO_EXT(glGenRenderbuffers);
|
||||
LOAD_FBO_EXT(glDeleteRenderbuffers);
|
||||
LOAD_FBO_EXT(glRenderbufferStorage);
|
||||
LOAD_FBO_EXT(glBindFramebuffer);
|
||||
LOAD_FBO_EXT(glDeleteFramebuffers);
|
||||
LOAD_FBO_EXT(glGenFramebuffers);
|
||||
LOAD_FBO_EXT(glCheckFramebufferStatus);
|
||||
LOAD_FBO_EXT(glFramebufferTexture1D);
|
||||
LOAD_FBO_EXT(glFramebufferTexture2D);
|
||||
LOAD_FBO_EXT(glFramebufferTexture3D);
|
||||
LOAD_FBO_EXT(glFramebufferTextureLayer);
|
||||
LOAD_FBO_EXT(glFramebufferRenderbuffer);
|
||||
LOAD_FBO_EXT(glGenerateMipmap);
|
||||
|
||||
_supported =
|
||||
glBindRenderbufferEXT != 0 &&
|
||||
glDeleteRenderbuffersEXT != 0 &&
|
||||
glGenRenderbuffersEXT != 0 &&
|
||||
glRenderbufferStorageEXT != 0 &&
|
||||
glBindFramebufferEXT != 0 &&
|
||||
glDeleteFramebuffersEXT != 0 &&
|
||||
glGenFramebuffersEXT != 0 &&
|
||||
glCheckFramebufferStatusEXT != 0 &&
|
||||
glFramebufferTexture1DEXT != 0 &&
|
||||
glFramebufferTexture2DEXT != 0 &&
|
||||
glFramebufferTexture3DEXT != 0 &&
|
||||
glFramebufferRenderbufferEXT != 0 &&
|
||||
glGenerateMipmapEXT != 0;
|
||||
glBindRenderbuffer != 0 &&
|
||||
glDeleteRenderbuffers != 0 &&
|
||||
glGenRenderbuffers != 0 &&
|
||||
glRenderbufferStorage != 0 &&
|
||||
glBindFramebuffer != 0 &&
|
||||
glDeleteFramebuffers != 0 &&
|
||||
glGenFramebuffers != 0 &&
|
||||
glCheckFramebufferStatus != 0 &&
|
||||
glFramebufferTexture1D != 0 &&
|
||||
glFramebufferTexture2D != 0 &&
|
||||
glFramebufferTexture3D != 0 &&
|
||||
glFramebufferRenderbuffer != 0 &&
|
||||
glGenerateMipmap != 0;
|
||||
|
||||
if (isGLExtensionSupported(contextID, "GL_EXT_framebuffer_blit"))
|
||||
{
|
||||
LOAD_FBO_EXT(glBlitFramebufferEXT);
|
||||
|
||||
if (isGLExtensionSupported(contextID, "GL_EXT_framebuffer_multisample"))
|
||||
{
|
||||
LOAD_FBO_EXT(glRenderbufferStorageMultisampleEXT);
|
||||
}
|
||||
|
||||
if (isGLExtensionSupported(contextID, "GL_NV_framebuffer_multisample_coverage"))
|
||||
{
|
||||
LOAD_FBO_EXT(glRenderbufferStorageMultisampleCoverageNV);
|
||||
}
|
||||
}
|
||||
LOAD_FBO_EXT(glBlitFramebuffer);
|
||||
LOAD_FBO_EXT(glRenderbufferStorageMultisample);
|
||||
LOAD_FBO_EXT(glRenderbufferStorageMultisampleCoverageNV);
|
||||
|
||||
if (isGLExtensionSupported(contextID, "GL_EXT_packed_depth_stencil"))
|
||||
{
|
||||
@@ -161,7 +147,7 @@ void RenderBuffer::flushDeletedRenderBuffers(unsigned int contextID,double /*cur
|
||||
titr!=pList.end() && elapsedTime<availableTime;
|
||||
)
|
||||
{
|
||||
extensions->glDeleteRenderbuffersEXT(1, &(*titr) );
|
||||
extensions->glDeleteRenderbuffers(1, &(*titr) );
|
||||
titr = pList.erase( titr );
|
||||
elapsedTime = timer.delta_s(start_tick,timer.tick());
|
||||
}
|
||||
@@ -238,7 +224,7 @@ GLuint RenderBuffer::getObjectID(unsigned int contextID, const FBOExtensions *ex
|
||||
|
||||
if (objectID == 0)
|
||||
{
|
||||
ext->glGenRenderbuffersEXT(1, &objectID);
|
||||
ext->glGenRenderbuffers(1, &objectID);
|
||||
if (objectID == 0)
|
||||
return 0;
|
||||
dirty = 1;
|
||||
@@ -247,7 +233,7 @@ GLuint RenderBuffer::getObjectID(unsigned int contextID, const FBOExtensions *ex
|
||||
if (dirty)
|
||||
{
|
||||
// bind and configure
|
||||
ext->glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, objectID);
|
||||
ext->glBindRenderbuffer(GL_RENDERBUFFER_EXT, objectID);
|
||||
|
||||
// framebuffer_multisample_coverage specification requires that coverage
|
||||
// samples must be >= color samples.
|
||||
@@ -270,12 +256,12 @@ GLuint RenderBuffer::getObjectID(unsigned int contextID, const FBOExtensions *ex
|
||||
{
|
||||
int samples = minimum(_samples, getMaxSamples(contextID, ext));
|
||||
|
||||
ext->glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT,
|
||||
ext->glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT,
|
||||
samples, _internalFormat, _width, _height);
|
||||
}
|
||||
else
|
||||
{
|
||||
ext->glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, _internalFormat, _width, _height);
|
||||
ext->glRenderbufferStorage(GL_RENDERBUFFER_EXT, _internalFormat, _width, _height);
|
||||
}
|
||||
dirty = 0;
|
||||
}
|
||||
@@ -512,7 +498,7 @@ void FrameBufferAttachment::createRequiredTexturesAndApplyGenerateMipMap(State &
|
||||
{
|
||||
state.setActiveTextureUnit(0);
|
||||
state.applyTextureAttribute(0, _ximpl->textureTarget.get());
|
||||
ext->glGenerateMipmapEXT(_ximpl->textureTarget->getTextureTarget());
|
||||
ext->glGenerateMipmap(_ximpl->textureTarget->getTextureTarget());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -540,25 +526,25 @@ void FrameBufferAttachment::attach(State &state, GLenum target, GLenum attachmen
|
||||
{
|
||||
default:
|
||||
case Pimpl::RENDERBUFFER:
|
||||
ext->glFramebufferRenderbufferEXT(target, attachment_point, GL_RENDERBUFFER_EXT, _ximpl->renderbufferTarget->getObjectID(contextID, ext));
|
||||
ext->glFramebufferRenderbuffer(target, attachment_point, GL_RENDERBUFFER_EXT, _ximpl->renderbufferTarget->getObjectID(contextID, ext));
|
||||
break;
|
||||
case Pimpl::TEXTURE1D:
|
||||
ext->glFramebufferTexture1DEXT(target, attachment_point, GL_TEXTURE_1D, tobj->id(), _ximpl->level);
|
||||
ext->glFramebufferTexture1D(target, attachment_point, GL_TEXTURE_1D, tobj->id(), _ximpl->level);
|
||||
break;
|
||||
case Pimpl::TEXTURE2D:
|
||||
ext->glFramebufferTexture2DEXT(target, attachment_point, GL_TEXTURE_2D, tobj->id(), _ximpl->level);
|
||||
ext->glFramebufferTexture2D(target, attachment_point, GL_TEXTURE_2D, tobj->id(), _ximpl->level);
|
||||
break;
|
||||
case Pimpl::TEXTURE3D:
|
||||
ext->glFramebufferTexture3DEXT(target, attachment_point, GL_TEXTURE_3D, tobj->id(), _ximpl->level, _ximpl->zoffset);
|
||||
ext->glFramebufferTexture3D(target, attachment_point, GL_TEXTURE_3D, tobj->id(), _ximpl->level, _ximpl->zoffset);
|
||||
break;
|
||||
case Pimpl::TEXTURE2DARRAY:
|
||||
ext->glFramebufferTextureLayerEXT(target, attachment_point, tobj->id(), _ximpl->level, _ximpl->zoffset);
|
||||
ext->glFramebufferTextureLayer(target, attachment_point, tobj->id(), _ximpl->level, _ximpl->zoffset);
|
||||
break;
|
||||
case Pimpl::TEXTURERECT:
|
||||
ext->glFramebufferTexture2DEXT(target, attachment_point, GL_TEXTURE_RECTANGLE, tobj->id(), 0);
|
||||
ext->glFramebufferTexture2D(target, attachment_point, GL_TEXTURE_RECTANGLE, tobj->id(), 0);
|
||||
break;
|
||||
case Pimpl::TEXTURECUBE:
|
||||
ext->glFramebufferTexture2DEXT(target, attachment_point, GL_TEXTURE_CUBE_MAP_POSITIVE_X + _ximpl->cubeMapFace, tobj->id(), _ximpl->level);
|
||||
ext->glFramebufferTexture2D(target, attachment_point, GL_TEXTURE_CUBE_MAP_POSITIVE_X + _ximpl->cubeMapFace, tobj->id(), _ximpl->level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -666,7 +652,7 @@ void FrameBufferObject::flushDeletedFrameBufferObjects(unsigned int contextID,do
|
||||
titr!=pList.end() && elapsedTime<availableTime;
|
||||
)
|
||||
{
|
||||
extensions->glDeleteFramebuffersEXT(1, &(*titr) );
|
||||
extensions->glDeleteFramebuffers(1, &(*titr) );
|
||||
titr = pList.erase( titr );
|
||||
elapsedTime = timer.delta_s(start_tick,timer.tick());
|
||||
}
|
||||
@@ -761,7 +747,7 @@ void FrameBufferObject::apply(State &state, BindTarget target) const
|
||||
|
||||
if (_attachments.empty())
|
||||
{
|
||||
ext->glBindFramebufferEXT(target, 0);
|
||||
ext->glBindFramebuffer(target, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -770,7 +756,7 @@ void FrameBufferObject::apply(State &state, BindTarget target) const
|
||||
GLuint &fboID = _fboID[contextID];
|
||||
if (fboID == 0)
|
||||
{
|
||||
ext->glGenFramebuffersEXT(1, &fboID);
|
||||
ext->glGenFramebuffers(1, &fboID);
|
||||
if (fboID == 0)
|
||||
{
|
||||
notify(WARN) << "Warning: FrameBufferObject: could not create the FBO" << std::endl;
|
||||
@@ -800,7 +786,7 @@ void FrameBufferObject::apply(State &state, BindTarget target) const
|
||||
}
|
||||
|
||||
|
||||
ext->glBindFramebufferEXT(target, fboID);
|
||||
ext->glBindFramebuffer(target, fboID);
|
||||
|
||||
// enable drawing buffers to render the result to fbo
|
||||
if (_drawBuffers.size() > 0)
|
||||
|
||||
@@ -329,21 +329,14 @@ void GL2Extensions::setupGL2Extensions(unsigned int contextID)
|
||||
_glVersion = asciiToFloat( version );
|
||||
_glslLanguageVersion = 0.0f;
|
||||
|
||||
_isShaderObjectsSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_shader_objects");
|
||||
_isVertexShaderSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_vertex_shader");
|
||||
_isFragmentShaderSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_fragment_shader");
|
||||
_isLanguage100Supported = osg::isGLExtensionSupported(contextID,"GL_ARB_shading_language_100");
|
||||
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");
|
||||
|
||||
|
||||
#if defined(OSG_GLES2_AVAILABLE)
|
||||
_glVersion = 2.0;
|
||||
_isShaderObjectsSupported = true;
|
||||
_isVertexShaderSupported = true;
|
||||
_isFragmentShaderSupported = true;
|
||||
_isLanguage100Supported = true;
|
||||
#endif
|
||||
|
||||
if( isGlslSupported() )
|
||||
{
|
||||
|
||||
@@ -318,6 +318,8 @@ std::string& osg::getGLExtensionDisableString()
|
||||
|
||||
void* osg::getGLExtensionFuncPtr(const char *funcName)
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"osg::getGLExtensionFuncPtr("<<funcName<<")"<<std::endl;
|
||||
|
||||
#if defined(WIN32)
|
||||
|
||||
return convertPointerType<void*, PROC>(wglGetProcAddress(funcName));
|
||||
|
||||
@@ -51,7 +51,10 @@ bool PointSprite::checkValidityOfAssociatedModes(osg::State& state) const
|
||||
|
||||
void PointSprite::apply(osg::State& state) const
|
||||
{
|
||||
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
|
||||
#if defined( OSG_GL3_AVAILABLE )
|
||||
const Point::Extensions* extensions = Point::getExtensions(state.getContextID(),true);
|
||||
extensions->glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN,_coordOriginMode);
|
||||
#elif defined( OSG_GL_FIXED_FUNCTION_AVAILABLE )
|
||||
if(!isPointSpriteSupported(state.getContextID())) return;
|
||||
|
||||
glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, 1);
|
||||
@@ -83,7 +86,7 @@ bool PointSprite::isPointSpriteSupported(unsigned int contextID)
|
||||
if (!s_extensions[contextID].initialized)
|
||||
{
|
||||
s_extensions[contextID].initialized = true;
|
||||
s_extensions[contextID].supported = isGLExtensionSupported(contextID, "GL_ARB_point_sprite") || isGLExtensionSupported(contextID, "GL_NV_point_sprite");
|
||||
s_extensions[contextID].supported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID, "GL_ARB_point_sprite") || isGLExtensionSupported(contextID, "GL_NV_point_sprite");
|
||||
}
|
||||
|
||||
return s_extensions[contextID].supported;
|
||||
|
||||
@@ -1074,7 +1074,7 @@ bool State::computeFogCoordSupported() const
|
||||
bool State::computeVertexBufferObjectSupported() const
|
||||
{
|
||||
_isVertexBufferObjectSupportResolved = true;
|
||||
_isVertexBufferObjectSupported = osg::isGLExtensionSupported(_contextID,"GL_ARB_vertex_buffer_object");
|
||||
_isVertexBufferObjectSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(_contextID,"GL_ARB_vertex_buffer_object");
|
||||
return _isVertexBufferObjectSupported;
|
||||
}
|
||||
|
||||
|
||||
@@ -2199,7 +2199,7 @@ bool Texture::isHardwareMipmapGenerationEnabled(const State& state) const
|
||||
|
||||
const FBOExtensions* fbo_ext = FBOExtensions::instance(contextID,true);
|
||||
|
||||
if (fbo_ext->glGenerateMipmapEXT)
|
||||
if (fbo_ext->glGenerateMipmap)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -2212,6 +2212,9 @@ Texture::GenerateMipmapMode Texture::mipmapBeforeTexImage(const State& state, bo
|
||||
{
|
||||
if (hardwareMipmapOn)
|
||||
{
|
||||
#if defined( OSG_GLES2_AVAILABLE ) || defined( OSG_GL3_AVAILABLE )
|
||||
return GENERATE_MIPMAP;
|
||||
#else
|
||||
int width = getTextureWidth();
|
||||
int height = getTextureHeight();
|
||||
|
||||
@@ -2223,7 +2226,7 @@ Texture::GenerateMipmapMode Texture::mipmapBeforeTexImage(const State& state, bo
|
||||
if (_internalFormatType != SIGNED_INTEGER &&
|
||||
_internalFormatType != UNSIGNED_INTEGER)
|
||||
{
|
||||
if (FBOExtensions::instance(state.getContextID(), true)->glGenerateMipmapEXT)
|
||||
if (FBOExtensions::instance(state.getContextID(), true)->glGenerateMipmap)
|
||||
{
|
||||
return GENERATE_MIPMAP;
|
||||
}
|
||||
@@ -2232,6 +2235,7 @@ Texture::GenerateMipmapMode Texture::mipmapBeforeTexImage(const State& state, bo
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
|
||||
return GENERATE_MIPMAP_TEX_PARAMETER;
|
||||
#endif
|
||||
}
|
||||
return GENERATE_MIPMAP_NONE;
|
||||
}
|
||||
@@ -2240,22 +2244,22 @@ void Texture::mipmapAfterTexImage(State& state, GenerateMipmapMode beforeResult)
|
||||
{
|
||||
switch (beforeResult)
|
||||
{
|
||||
case GENERATE_MIPMAP:
|
||||
case GENERATE_MIPMAP:
|
||||
{
|
||||
unsigned int contextID = state.getContextID();
|
||||
TextureObject* textureObject = getTextureObject(contextID);
|
||||
if (textureObject)
|
||||
{
|
||||
osg::FBOExtensions* fbo_ext = osg::FBOExtensions::instance(contextID, true);
|
||||
fbo_ext->glGenerateMipmapEXT(textureObject->target());
|
||||
fbo_ext->glGenerateMipmap(textureObject->target());
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GENERATE_MIPMAP_TEX_PARAMETER:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
|
||||
break;
|
||||
case GENERATE_MIPMAP_NONE:
|
||||
break;
|
||||
case GENERATE_MIPMAP_TEX_PARAMETER:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
|
||||
break;
|
||||
case GENERATE_MIPMAP_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2282,10 +2286,10 @@ void Texture::generateMipmap(State& state) const
|
||||
osg::FBOExtensions* fbo_ext = osg::FBOExtensions::instance(state.getContextID(), true);
|
||||
|
||||
// check if the function is supported
|
||||
if (fbo_ext->glGenerateMipmapEXT)
|
||||
if (fbo_ext->glGenerateMipmap)
|
||||
{
|
||||
textureObject->bind();
|
||||
fbo_ext->glGenerateMipmapEXT(textureObject->target());
|
||||
fbo_ext->glGenerateMipmap(textureObject->target());
|
||||
|
||||
// inform state that this texture is the current one bound.
|
||||
state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this);
|
||||
|
||||
@@ -484,7 +484,8 @@ void TextureCubeMap::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||
|
||||
void TextureCubeMap::Extensions::setupGLExtensions(unsigned int contextID)
|
||||
{
|
||||
_isCubeMapSupported = isGLExtensionSupported(contextID,"GL_ARB_texture_cube_map") ||
|
||||
_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;;
|
||||
}
|
||||
|
||||
@@ -147,9 +147,11 @@ void TextureRectangle::setImage(Image* image)
|
||||
|
||||
void TextureRectangle::apply(State& state) const
|
||||
{
|
||||
static bool s_rectangleSupported = isGLExtensionSupported(state.getContextID(),"GL_ARB_texture_rectangle")
|
||||
|| isGLExtensionSupported(state.getContextID(),"GL_EXT_texture_rectangle")
|
||||
|| isGLExtensionSupported(state.getContextID(),"GL_NV_texture_rectangle");
|
||||
static bool s_rectangleSupported =
|
||||
OSG_GL3_FEATURES ||
|
||||
isGLExtensionSupported(state.getContextID(),"GL_ARB_texture_rectangle") ||
|
||||
isGLExtensionSupported(state.getContextID(),"GL_EXT_texture_rectangle") ||
|
||||
isGLExtensionSupported(state.getContextID(),"GL_NV_texture_rectangle");
|
||||
|
||||
if (!s_rectangleSupported)
|
||||
{
|
||||
|
||||
@@ -461,7 +461,7 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
|
||||
fbo->apply(state);
|
||||
|
||||
// If no color attachment make sure to set glDrawBuffer/glReadBuffer to none
|
||||
// otherwise glCheckFramebufferStatusEXT will fail
|
||||
// otherwise glCheckFramebufferStatus will fail
|
||||
// It has to be done after call to glBindFramebuffer (fbo->apply)
|
||||
// and before call to glCheckFramebufferStatus
|
||||
if ( !colorAttached )
|
||||
@@ -474,14 +474,14 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
|
||||
#endif
|
||||
}
|
||||
|
||||
GLenum status = fbo_ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
GLenum status = fbo_ext->glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
|
||||
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"RenderStage::runCameraSetUp(), FBO setup failed, FBO status= 0x"<<std::hex<<status<<std::dec<<std::endl;
|
||||
|
||||
fbo_supported = false;
|
||||
fbo_ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
fbo_ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
fbo = 0;
|
||||
|
||||
// clean up.
|
||||
@@ -503,7 +503,7 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
|
||||
{
|
||||
fbo_multisample->apply(state);
|
||||
|
||||
GLenum status = fbo_ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
GLenum status = fbo_ext->glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
|
||||
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
{
|
||||
@@ -890,7 +890,7 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
|
||||
{
|
||||
if ( fbo_ext )
|
||||
{
|
||||
GLenum fbstatus = fbo_ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
GLenum fbstatus = fbo_ext->glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
|
||||
if ( fbstatus != GL_FRAMEBUFFER_COMPLETE_EXT )
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"RenderStage::drawInner(,) FBO status = 0x"<<std::hex<<fbstatus<<std::dec<<std::endl;
|
||||
@@ -902,7 +902,7 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
|
||||
const FrameBufferObject* read_fbo = fbo_supported ? _fbo.get() : 0;
|
||||
bool apply_read_fbo = false;
|
||||
|
||||
if (fbo_supported && _resolveFbo.valid() && fbo_ext->glBlitFramebufferEXT)
|
||||
if (fbo_supported && _resolveFbo.valid() && fbo_ext->glBlitFramebuffer)
|
||||
{
|
||||
GLbitfield blitMask = 0;
|
||||
|
||||
@@ -935,7 +935,7 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
|
||||
// Note that (with nvidia 175.16 windows drivers at least) if the read
|
||||
// framebuffer is multisampled then the dimension arguments are ignored
|
||||
// and the whole framebuffer is always copied.
|
||||
fbo_ext->glBlitFramebufferEXT(
|
||||
fbo_ext->glBlitFramebuffer(
|
||||
0, 0, static_cast<GLint>(_viewport->width()), static_cast<GLint>(_viewport->height()),
|
||||
0, 0, static_cast<GLint>(_viewport->width()), static_cast<GLint>(_viewport->height()),
|
||||
blitMask, GL_NEAREST);
|
||||
@@ -1003,7 +1003,7 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
|
||||
if (getDisableFboAfterRender())
|
||||
{
|
||||
// switch off the frame buffer object
|
||||
fbo_ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
fbo_ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
}
|
||||
|
||||
doCopyTexture = true;
|
||||
@@ -1021,7 +1021,7 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
|
||||
{
|
||||
state.setActiveTextureUnit(0);
|
||||
state.applyTextureAttribute(0, itr->second._texture.get());
|
||||
fbo_ext->glGenerateMipmapEXT(itr->second._texture->getTextureTarget());
|
||||
fbo_ext->glGenerateMipmap(itr->second._texture->getTextureTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user