Added GL2Extensions::isDrawBuffersSupported() and usage of this in FrameBufferObject.cpp to prevent crash under GLES2 when users attempt to use MRT when it's not supported
This commit is contained in:
@@ -530,6 +530,8 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
|
|||||||
void setShaderAtomicCounterSupported(bool flag) { _isShaderAtomicCountersSupported = flag; }
|
void setShaderAtomicCounterSupported(bool flag) { _isShaderAtomicCountersSupported = flag; }
|
||||||
bool isShaderAtomicCounterSupported() const {return _isShaderAtomicCountersSupported; }
|
bool isShaderAtomicCounterSupported() const {return _isShaderAtomicCountersSupported; }
|
||||||
|
|
||||||
|
bool isDrawBuffersSupported() const { return _glDrawBuffers!=0; }
|
||||||
|
|
||||||
/** Function to call to get the extension of a specified context.
|
/** Function to call to get the extension of a specified context.
|
||||||
* If the Exentsion object for that context has not yet been created then
|
* If the Exentsion object for that context has not yet been created then
|
||||||
* and the 'createIfNotInitalized' flag been set to false then returns NULL.
|
* and the 'createIfNotInitalized' flag been set to false then returns NULL.
|
||||||
|
|||||||
@@ -916,10 +916,14 @@ void FrameBufferObject::apply(State &state, BindTarget target) const
|
|||||||
if (_drawBuffers.size() > 0)
|
if (_drawBuffers.size() > 0)
|
||||||
{
|
{
|
||||||
GL2Extensions *gl2e = GL2Extensions::Get(state.getContextID(), true );
|
GL2Extensions *gl2e = GL2Extensions::Get(state.getContextID(), true );
|
||||||
if (gl2e)
|
if (gl2e && gl2e->isDrawBuffersSupported())
|
||||||
{
|
{
|
||||||
gl2e->glDrawBuffers(_drawBuffers.size(), &(_drawBuffers[0]));
|
gl2e->glDrawBuffers(_drawBuffers.size(), &(_drawBuffers[0]));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OSG_WARN <<"Warning: FrameBufferObject: could not set draw buffers, glDrawBuffers is not supported!" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dirtyAttachmentList)
|
if (dirtyAttachmentList)
|
||||||
@@ -939,7 +943,7 @@ void FrameBufferObject::apply(State &state, BindTarget target) const
|
|||||||
{
|
{
|
||||||
OSG_WARN <<
|
OSG_WARN <<
|
||||||
"Warning: FrameBufferObject: could not attach PACKED_DEPTH_STENCIL_BUFFER, "
|
"Warning: FrameBufferObject: could not attach PACKED_DEPTH_STENCIL_BUFFER, "
|
||||||
"EXT_packed_depth_stencil is not supported !" << std::endl;
|
"EXT_packed_depth_stencil is not supported!" << std::endl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user