Cleaned up API of BindAttributeLocation, added deletion of shader objects.
This commit is contained in:
@@ -340,8 +340,13 @@ class OSG_EXPORT Program : public osg::StateAttribute
|
||||
bool removeShader( Shader* shader );
|
||||
|
||||
/** Add an attribute location binding. */
|
||||
void bindAttribLocation( GLuint index, const char* name );
|
||||
void addBindAttribLocation( const std::string& name, GLuint index );
|
||||
|
||||
/** Add an attribute location binding. */
|
||||
void removeBindAttribLocation( const std::string& name );
|
||||
|
||||
typedef std::map<std::string,GLuint> AttribBindingList;
|
||||
|
||||
const AttribBindingList& getAttribBindingList() const { return _attribBindingList; }
|
||||
|
||||
/** Return true if this Program represents "fixed-functionality" rendering */
|
||||
|
||||
@@ -2034,12 +2034,18 @@ bool Program::removeShader( Shader* shader )
|
||||
}
|
||||
|
||||
|
||||
void Program::bindAttribLocation( GLuint index, const char* name )
|
||||
void Program::addBindAttribLocation( const std::string& name, GLuint index )
|
||||
{
|
||||
_attribBindingList[name] = index;
|
||||
dirtyProgram();
|
||||
}
|
||||
|
||||
void Program::removeBindAttribLocation( const std::string& name )
|
||||
{
|
||||
_attribBindingList.erase(name);
|
||||
dirtyProgram();
|
||||
}
|
||||
|
||||
|
||||
void Program::apply( osg::State& state ) const
|
||||
{
|
||||
|
||||
@@ -37,11 +37,21 @@ bool Program_readLocalData(Object& obj, Input& fr)
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
while(fr[0].matchWord("AttribBindingLocation"))
|
||||
while(fr.matchSequence("AttribBindingLocation %i %w"))
|
||||
{
|
||||
int index;
|
||||
fr[1].getInt(index);
|
||||
program.bindAttribLocation(index,fr[2].getStr());
|
||||
unsigned int index;
|
||||
fr[1].getUInt(index);
|
||||
program.addBindAttribLocation(fr[2].getStr(), index);
|
||||
fr += 3;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
|
||||
while(fr.matchSequence("AttribBindingLocation %w %i"))
|
||||
{
|
||||
unsigned int index;
|
||||
fr[2].getUInt(index);
|
||||
program.addBindAttribLocation(fr[1].getStr(), index);
|
||||
fr += 3;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
@@ -76,7 +86,7 @@ bool Program_writeLocalData(const Object& obj,Output& fw)
|
||||
Program::AttribBindingList::const_iterator i;
|
||||
for(i=abl.begin(); i!=abl.end(); i++)
|
||||
{
|
||||
fw.indent() << "AttribBindingLocation " << (*i).second << " " << (*i).first << std::endl;
|
||||
fw.indent() << "AttribBindingLocation " << (*i).first << " " << (*i).second << std::endl;
|
||||
}
|
||||
|
||||
fw.indent() << "num_shaders " << program.getNumShaders() << std::endl;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <osg/ColorMatrix>
|
||||
#include <osg/LightModel>
|
||||
#include <osg/CollectOccludersVisitor>
|
||||
#include <osg/Shader>
|
||||
|
||||
#include <osg/GLU>
|
||||
|
||||
@@ -658,6 +659,7 @@ void SceneView::flushAllDeletedGLObjects()
|
||||
osg::VertexProgram::flushDeletedVertexProgramObjects(_state->getContextID(),currentTime,availableTime);
|
||||
osg::FragmentProgram::flushDeletedFragmentProgramObjects(_state->getContextID(),currentTime,availableTime);
|
||||
osg::Program::flushDeletedGlPrograms(_state->getContextID(),currentTime,availableTime);
|
||||
osg::Shader::flushDeletedGlShaders(_state->getContextID(),currentTime,availableTime);
|
||||
}
|
||||
|
||||
void SceneView::flushDeletedGLObjects(double& availableTime)
|
||||
@@ -671,6 +673,7 @@ void SceneView::flushDeletedGLObjects(double& availableTime)
|
||||
osg::VertexProgram::flushDeletedVertexProgramObjects(_state->getContextID(),currentTime,availableTime);
|
||||
osg::FragmentProgram::flushDeletedFragmentProgramObjects(_state->getContextID(),currentTime,availableTime);
|
||||
osg::Program::flushDeletedGlPrograms(_state->getContextID(),currentTime,availableTime);
|
||||
osg::Shader::flushDeletedGlShaders(_state->getContextID(),currentTime,availableTime);
|
||||
}
|
||||
|
||||
void SceneView::draw()
|
||||
|
||||
Reference in New Issue
Block a user