Added osg:State:have_applied_mode(mode) and have_applied_attribute(type) to make it
easier to specify which modes and attributes have been modified without the user requiring to know to what value, or to have an equivilant attribute to pass to the have_applied_attribute method. The original have_applied(mode) and have_applied(attribute) methods have been renamed have_applied_mode(), have_applied_attribute() as this was required to prevent the mode and type values colliding during compile (it was causing a compile error when the method names were the same.)
This commit is contained in:
parent
b53b3038eb
commit
a364875afb
@ -75,10 +75,23 @@ class SG_EXPORT State : public Referenced
|
||||
void apply();
|
||||
|
||||
/** mode has been set externally, update state to reflect this setting.*/
|
||||
void have_applied(const StateAttribute::GLMode mode,const StateAttribute::GLModeValue value);
|
||||
void have_applied_mode(const StateAttribute::GLMode mode,const StateAttribute::GLModeValue value);
|
||||
|
||||
/** mode has been set externally, therefore dirty the associated mode in osg::State
|
||||
* so it is applied on next call to osg::State::apply(..)*/
|
||||
void have_applied_mode(const StateAttribute::GLMode mode);
|
||||
|
||||
/** attribute has been applied externally, update state to reflect this setting.*/
|
||||
void have_applied(const StateAttribute* attribute);
|
||||
void have_applied_attribute(const StateAttribute* attribute);
|
||||
|
||||
/** attribute has been applied externally,
|
||||
* and therefore this attribute type has been dirtied
|
||||
* and will need to be re-appplied on next osg::State.apply(..).
|
||||
* note, if you have an osg::StateAttribute which you have applied externally
|
||||
* then use the have_applied(attribute) method as this will the osg::State to
|
||||
* track the current state more accuratly and enable lazy state updating such
|
||||
* that only changed state will be applied.*/
|
||||
void have_applied_attribute(const StateAttribute::Type type);
|
||||
|
||||
|
||||
/** Set the current OpenGL context uniqueID.
|
||||
|
@ -512,7 +512,7 @@ void State::apply()
|
||||
}
|
||||
|
||||
/** mode has been set externally, update state to reflect this setting.*/
|
||||
void State::have_applied(const StateAttribute::GLMode mode,const StateAttribute::GLModeValue value)
|
||||
void State::have_applied_mode(const StateAttribute::GLMode mode,const StateAttribute::GLModeValue value)
|
||||
{
|
||||
ModeStack& ms = _modeMap[mode];
|
||||
|
||||
@ -522,8 +522,21 @@ void State::have_applied(const StateAttribute::GLMode mode,const StateAttribute:
|
||||
ms.changed = true;
|
||||
}
|
||||
|
||||
/** mode has been set externally, update state to reflect this setting.*/
|
||||
void State::have_applied_mode(const StateAttribute::GLMode mode)
|
||||
{
|
||||
ModeStack& ms = _modeMap[mode];
|
||||
|
||||
// don't know what last applied value is can't apply it.
|
||||
// assume that it has changed by toggle the value of last_applied_value.
|
||||
ms.last_applied_value = !ms.last_applied_value;
|
||||
|
||||
// will need to disable this mode on next apply so set it to changed.
|
||||
ms.changed = true;
|
||||
}
|
||||
|
||||
/** attribute has been applied externally, update state to reflect this setting.*/
|
||||
void State::have_applied(const StateAttribute* attribute)
|
||||
void State::have_applied_attribute(const StateAttribute* attribute)
|
||||
{
|
||||
if (attribute)
|
||||
{
|
||||
@ -536,3 +549,17 @@ void State::have_applied(const StateAttribute* attribute)
|
||||
}
|
||||
}
|
||||
|
||||
void State::have_applied_attribute(const StateAttribute::Type type)
|
||||
{
|
||||
|
||||
AttributeMap::iterator itr = _attributeMap.find(type);
|
||||
if (itr!=_attributeMap.end())
|
||||
{
|
||||
AttributeStack& as = itr->second;
|
||||
|
||||
as.last_applied_attribute = 0L;
|
||||
|
||||
// will need to update this attribute on next apply so set it to changed.
|
||||
as.changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ void Texture::copyTexImage2D(State& state, int x, int y, int width, int height )
|
||||
// cout<<"copyTexImage2D x="<<x<<" y="<<y<<" w="<<width<<" h="<<height<< std::endl;
|
||||
|
||||
// inform state that this texture is the current one bound.
|
||||
state.have_applied(this);
|
||||
state.have_applied_attribute(this);
|
||||
}
|
||||
|
||||
void Texture::copyTexSubImage2D(State& state, int xoffset, int yoffset, int x, int y, int width, int height )
|
||||
@ -586,7 +586,7 @@ void Texture::copyTexSubImage2D(State& state, int xoffset, int yoffset, int x, i
|
||||
glBindTexture( _target, handle );
|
||||
|
||||
// inform state that this texture is the current one bound.
|
||||
state.have_applied(this);
|
||||
state.have_applied_attribute(this);
|
||||
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user