Added debug State::print(std::ostream&) method and extra debug messages in ShaderComposer and ShaderAttribute.
Added better shader composition testing in the osgshadercomposition example.
This commit is contained in:
@@ -29,7 +29,11 @@ class OSG_EXPORT ShaderAttribute : public StateAttribute
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
|
||||
ShaderAttribute(const ShaderAttribute& sa,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osg, ShaderAttribute);
|
||||
virtual osg::Object* cloneType() const;
|
||||
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new ShaderAttribute(*this,copyop); }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ShaderAttribute *>(obj)!=NULL; }
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
virtual const char* className() const { return "ShaderAttribute"; }
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
|
||||
virtual int compare(const StateAttribute& sa) const;
|
||||
|
||||
@@ -1352,6 +1352,8 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
bool checkGLErrors(StateAttribute::GLMode mode) const;
|
||||
bool checkGLErrors(const StateAttribute* attribute) const;
|
||||
|
||||
/** print out the internal details of osg::State - useful for debugging.*/
|
||||
void print(std::ostream& fout) const;
|
||||
|
||||
/** Initialize extension used by osg:::State.*/
|
||||
void initializeExtensionProcs();
|
||||
@@ -1424,6 +1426,8 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
global_default_value = false;
|
||||
}
|
||||
|
||||
void print(std::ostream& fout) const;
|
||||
|
||||
bool valid;
|
||||
bool changed;
|
||||
bool last_applied_value;
|
||||
@@ -1442,6 +1446,8 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
}
|
||||
|
||||
void print(std::ostream& fout) const;
|
||||
|
||||
/** apply an attribute if required, passing in attribute and appropriate attribute stack */
|
||||
bool changed;
|
||||
const StateAttribute* last_applied_attribute;
|
||||
@@ -1458,6 +1464,8 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
|
||||
UniformStack() {}
|
||||
|
||||
void print(std::ostream& fout) const;
|
||||
|
||||
UniformVec uniformVec;
|
||||
};
|
||||
|
||||
@@ -1546,6 +1554,13 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
as.last_applied_attribute = attribute;
|
||||
attribute->apply(*this);
|
||||
|
||||
const ShaderComponent* sc = attribute->getShaderComponent();
|
||||
if (as.last_applied_shadercomponent != sc)
|
||||
{
|
||||
as.last_applied_shadercomponent = sc;
|
||||
_shaderCompositionDirty = true;
|
||||
}
|
||||
|
||||
if (_checkGLErrors==ONCE_PER_ATTRIBUTE) checkGLErrors(attribute);
|
||||
|
||||
return true;
|
||||
@@ -1566,6 +1581,13 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
if (as.global_default_attribute.valid())
|
||||
{
|
||||
as.global_default_attribute->apply(*this);
|
||||
const ShaderComponent* sc = as.global_default_attribute->getShaderComponent();
|
||||
if (as.last_applied_shadercomponent != sc)
|
||||
{
|
||||
as.last_applied_shadercomponent = sc;
|
||||
_shaderCompositionDirty = true;
|
||||
}
|
||||
|
||||
if (_checkGLErrors==ONCE_PER_ATTRIBUTE) checkGLErrors(as.global_default_attribute.get());
|
||||
}
|
||||
return true;
|
||||
@@ -1584,6 +1606,12 @@ class OSG_EXPORT State : public Referenced, public Observer
|
||||
if (as.global_default_attribute.valid())
|
||||
{
|
||||
as.global_default_attribute->apply(*this);
|
||||
const ShaderComponent* sc = as.global_default_attribute->getShaderComponent();
|
||||
if (as.last_applied_shadercomponent != sc)
|
||||
{
|
||||
as.last_applied_shadercomponent = sc;
|
||||
_shaderCompositionDirty = true;
|
||||
}
|
||||
if (_checkGLErrors==ONCE_PER_ATTRIBUTE) checkGLErrors(as.global_default_attribute.get());
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user