Added support for new #pragam(atic) shader composition to new displacement mapping technique
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14683 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -135,6 +135,21 @@ public:
|
||||
assignedToAll();
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='l')
|
||||
{
|
||||
toggleDefine("GL_LIGHTING");
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='t')
|
||||
{
|
||||
toggleDefine("GL_TEXTURE_2D");
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='d')
|
||||
{
|
||||
toggleDefine("COMPUTE_DIAGONALS");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -143,6 +158,22 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void toggleDefine(const std::string& defineName)
|
||||
{
|
||||
osg::StateSet::DefineList& defineList = _terrain->getOrCreateStateSet()->getDefineList();
|
||||
osg::StateSet::DefineList::iterator itr = defineList.find(defineName);
|
||||
if (itr==defineList.end())
|
||||
{
|
||||
defineList[defineName].second = (osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::StateSet::DefinePair& dp = itr->second;
|
||||
if ( (dp.second & osg::StateAttribute::ON)==0) dp.second = (osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
|
||||
else dp.second = (osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
~TerrainHandler() {}
|
||||
@@ -351,6 +382,10 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
//terrain->getOrCreateStateSet()->setDefine("NUM_LIGHTS", "20.0");
|
||||
//terrain->getOrCreateStateSet()->setDefine("GL_LIGHTING"); // , osg::StateAttribute::OFF|osg::StateAttribute::OVERRIDE);
|
||||
//terrain->getOrCreateStateSet()->setDefine("COMPUTE_DIAGONALS"); // , osg::StateAttribute::OFF|osg::StateAttribute::OVERRIDE);
|
||||
|
||||
// run the viewers main loop
|
||||
return viewer.run();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user