Added support for OpenGL mode black listing to provide better support
for extension checking and invalidation of OpenGL modes associated with extensions.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <osg/PointSprite>
|
||||
#include <osg/State>
|
||||
#include <osg/buffered_value>
|
||||
#include <osg/Notify>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
@@ -30,6 +31,16 @@ int PointSprite::compare(const StateAttribute& sa) const
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
|
||||
bool PointSprite::checkValididityOfAssociatedModes(osg::State& state) const
|
||||
{
|
||||
|
||||
bool modeValid = isPointSpriteSupported(state.getContextID());
|
||||
state.setModeValidity(GL_POINT_SPRITE_ARB, modeValid);
|
||||
|
||||
return modeValid;
|
||||
}
|
||||
|
||||
void PointSprite::apply(osg::State& state) const
|
||||
{
|
||||
if(!isPointSpriteSupported(state.getContextID())) return;
|
||||
|
||||
@@ -53,7 +53,7 @@ State::~State()
|
||||
void State::reset()
|
||||
{
|
||||
|
||||
/*
|
||||
#if 1
|
||||
for(ModeMap::iterator mitr=_modeMap.begin();
|
||||
mitr!=_modeMap.end();
|
||||
++mitr)
|
||||
@@ -63,9 +63,10 @@ void State::reset()
|
||||
ms.last_applied_value = !ms.global_default_value;
|
||||
ms.changed = true;
|
||||
}
|
||||
*/
|
||||
|
||||
#else
|
||||
_modeMap.clear();
|
||||
#endif
|
||||
|
||||
_modeMap[GL_DEPTH_TEST].global_default_value = true;
|
||||
_modeMap[GL_DEPTH_TEST].changed = true;
|
||||
|
||||
|
||||
@@ -1131,6 +1131,32 @@ const StateSet::RefAttributePair* StateSet::getTextureAttributePair(unsigned int
|
||||
return getAttributePair(_textureAttributeList[unit],type,0);
|
||||
}
|
||||
|
||||
bool StateSet::checkValididityOfAssociatedModes(osg::State& state) const
|
||||
{
|
||||
|
||||
|
||||
bool modesValid = true;
|
||||
for(AttributeList::const_iterator itr = _attributeList.begin();
|
||||
itr!=_attributeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (!itr->second.first->checkValididityOfAssociatedModes(state)) modesValid = false;
|
||||
}
|
||||
|
||||
for(TextureAttributeList::const_iterator taitr=_textureAttributeList.begin();
|
||||
taitr!=_textureAttributeList.end();
|
||||
++taitr)
|
||||
{
|
||||
for(AttributeList::const_iterator itr = taitr->begin();
|
||||
itr!=taitr->end();
|
||||
++itr)
|
||||
{
|
||||
if (!itr->second.first->checkValididityOfAssociatedModes(state)) modesValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
return modesValid;
|
||||
}
|
||||
|
||||
void StateSet::compileGLObjects(State& state) const
|
||||
{
|
||||
|
||||
@@ -60,6 +60,10 @@ void GLObjectsVisitor::apply(osg::Geode& node)
|
||||
|
||||
void GLObjectsVisitor::apply(osg::Drawable& drawable)
|
||||
{
|
||||
if (_drawablesAppliedSet.count(&drawable)!=0) return;
|
||||
|
||||
_drawablesAppliedSet.insert(&drawable);
|
||||
|
||||
if (_mode&SWITCH_OFF_DISPLAY_LISTS)
|
||||
{
|
||||
drawable.setUseDisplayList(false);
|
||||
@@ -93,12 +97,22 @@ void GLObjectsVisitor::apply(osg::Drawable& drawable)
|
||||
|
||||
void GLObjectsVisitor::apply(osg::StateSet& stateset)
|
||||
{
|
||||
if (_mode&COMPILE_STATE_ATTRIBUTES && _state.valid())
|
||||
if (_stateSetAppliedSet.count(&stateset)!=0) return;
|
||||
|
||||
_stateSetAppliedSet.insert(&stateset);
|
||||
|
||||
if (_mode & COMPILE_STATE_ATTRIBUTES && _state.valid())
|
||||
{
|
||||
stateset.compileGLObjects(*_state);
|
||||
}
|
||||
if (_mode&RELEASE_STATE_ATTRIBUTES)
|
||||
|
||||
if (_mode & RELEASE_STATE_ATTRIBUTES)
|
||||
{
|
||||
stateset.releaseGLObjects(_state.get());
|
||||
}
|
||||
|
||||
if (_mode & CHECK_BLACK_LISTED_MODES)
|
||||
{
|
||||
stateset.checkValididityOfAssociatedModes(*_state.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,9 @@ void SceneView::setDefaults(unsigned int options)
|
||||
|
||||
if (options & COMPILE_GLOBJECTS_AT_INIT)
|
||||
{
|
||||
GLObjectsVisitor::Mode dlvMode = GLObjectsVisitor::COMPILE_DISPLAY_LISTS|GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES;
|
||||
GLObjectsVisitor::Mode dlvMode = GLObjectsVisitor::COMPILE_DISPLAY_LISTS |
|
||||
GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES |
|
||||
GLObjectsVisitor::CHECK_BLACK_LISTED_MODES;
|
||||
|
||||
#ifdef __sgi
|
||||
dlvMode = GLObjectsVisitor::COMPILE_STATE_ATTRIBUTES;
|
||||
|
||||
Reference in New Issue
Block a user