From Mike Weiblen, changes to internal help class in prep for array uniform support.
Small tweaks for build under Linux from Robert Osfield.
This commit is contained in:
parent
7f101c37ad
commit
e7a4ad287b
@ -1,4 +1,4 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
* Copyright (C) 2003-2005 3Dlabs Inc. Ltd.
|
||||
* Copyright (C) 2004-2005 Nathan Cournia
|
||||
*
|
||||
@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
/* file: include/osg/Program
|
||||
* author: Mike Weiblen 2005-07-01
|
||||
* author: Mike Weiblen 2006-03-25
|
||||
*/
|
||||
|
||||
#ifndef OSG_PROGRAM
|
||||
@ -109,9 +109,16 @@ class OSG_EXPORT Program : public osg::StateAttribute
|
||||
* in the OpenGL context related to contextID.*/
|
||||
static void flushDeletedGlPrograms(unsigned int contextID,double currentTime, double& availableTime);
|
||||
|
||||
typedef std::map< std::string, std::pair<GLint,GLenum> > NameInfoMap;
|
||||
const NameInfoMap& getActiveUniforms(unsigned int contextID) const;
|
||||
const NameInfoMap& getActiveAttribs(unsigned int contextID) const;
|
||||
struct ActiveVarInfo {
|
||||
ActiveVarInfo() : _location(-1), _type(Uniform::UNDEFINED), _size(-1) {}
|
||||
ActiveVarInfo( GLint loc, GLenum type, GLint size ) : _location(loc), _type(type), _size(size) {}
|
||||
GLint _location;
|
||||
GLenum _type;
|
||||
GLint _size;
|
||||
};
|
||||
typedef std::map< std::string, ActiveVarInfo > ActiveVarInfoMap;
|
||||
const ActiveVarInfoMap& getActiveUniforms(unsigned int contextID) const;
|
||||
const ActiveVarInfoMap& getActiveAttribs(unsigned int contextID) const;
|
||||
|
||||
public:
|
||||
|
||||
@ -175,11 +182,11 @@ class OSG_EXPORT Program : public osg::StateAttribute
|
||||
}
|
||||
}
|
||||
|
||||
const NameInfoMap& getActiveUniforms() const {return _uniformInfoMap;}
|
||||
const NameInfoMap& getActiveAttribs() const {return _attribInfoMap;}
|
||||
const ActiveVarInfoMap& getActiveUniforms() const {return _uniformInfoMap;}
|
||||
const ActiveVarInfoMap& getActiveAttribs() const {return _attribInfoMap;}
|
||||
|
||||
inline GLint getUniformLocation( const std::string& name ) const { NameInfoMap::const_iterator itr = _uniformInfoMap.find(name); return (itr!=_uniformInfoMap.end()) ? itr->second.first : -1; }
|
||||
inline GLint getAttribLocation( const std::string& name ) const { NameInfoMap::const_iterator itr = _attribInfoMap.find(name); return (itr!=_attribInfoMap.end()) ? itr->second.first : -1; }
|
||||
inline GLint getUniformLocation( const std::string& name ) const { ActiveVarInfoMap::const_iterator itr = _uniformInfoMap.find(name); return (itr!=_uniformInfoMap.end()) ? itr->second._location : -1; }
|
||||
inline GLint getAttribLocation( const std::string& name ) const { ActiveVarInfoMap::const_iterator itr = _attribInfoMap.find(name); return (itr!=_attribInfoMap.end()) ? itr->second._location : -1; }
|
||||
|
||||
protected: /*methods*/
|
||||
~PerContextProgram();
|
||||
@ -197,8 +204,8 @@ class OSG_EXPORT Program : public osg::StateAttribute
|
||||
bool _isLinked;
|
||||
const unsigned int _contextID;
|
||||
|
||||
NameInfoMap _uniformInfoMap;
|
||||
NameInfoMap _attribInfoMap;
|
||||
ActiveVarInfoMap _uniformInfoMap;
|
||||
ActiveVarInfoMap _attribInfoMap;
|
||||
|
||||
typedef std::pair<const osg::Uniform*, unsigned int> UniformModifiedCountPair;
|
||||
typedef std::vector<UniformModifiedCountPair> LastAppliedUniformList;
|
||||
|
@ -164,7 +164,7 @@ class OSG_EXPORT Uniform : public Object
|
||||
SAMPLER_CUBE = GL_SAMPLER_CUBE,
|
||||
SAMPLER_1D_SHADOW = GL_SAMPLER_1D_SHADOW,
|
||||
SAMPLER_2D_SHADOW = GL_SAMPLER_2D_SHADOW,
|
||||
UNDEFINED = -1
|
||||
UNDEFINED = 0x0
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 Robert Osfield
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
* Copyright (C) 2003-2005 3Dlabs Inc. Ltd.
|
||||
* Copyright (C) 2004-2005 Nathan Cournia
|
||||
*
|
||||
@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
/* file: src/osg/Program.cpp
|
||||
* author: Mike Weiblen 2005-07-01
|
||||
* author: Mike Weiblen 2006-03-25
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
@ -2131,12 +2131,12 @@ bool Program::getGlProgramInfoLog(unsigned int contextID, std::string& log) cons
|
||||
return getPCP( contextID )->getInfoLog( log );
|
||||
}
|
||||
|
||||
const Program::NameInfoMap& Program::getActiveUniforms(unsigned int contextID) const
|
||||
const Program::ActiveVarInfoMap& Program::getActiveUniforms(unsigned int contextID) const
|
||||
{
|
||||
return getPCP( contextID )->getActiveUniforms();
|
||||
}
|
||||
|
||||
const Program::NameInfoMap& Program::getActiveAttribs(unsigned int contextID) const
|
||||
const Program::ActiveVarInfoMap& Program::getActiveAttribs(unsigned int contextID) const
|
||||
{
|
||||
return getPCP( contextID )->getActiveAttribs();
|
||||
}
|
||||
@ -2240,11 +2240,12 @@ void Program::PerContextProgram::linkProgram()
|
||||
|
||||
if( loc != -1 )
|
||||
{
|
||||
_uniformInfoMap[name] = std::pair<GLint,GLenum>(loc,type);
|
||||
_uniformInfoMap[name] = ActiveVarInfo(loc,type,size);
|
||||
|
||||
osg::notify(osg::INFO)
|
||||
<< "\tUniform \"" << name << "\""
|
||||
<< " loc="<< loc
|
||||
<< " size="<< size
|
||||
<< " type=" << Uniform::getTypename((Uniform::Type)type)
|
||||
<< std::endl;
|
||||
}
|
||||
@ -2271,11 +2272,12 @@ void Program::PerContextProgram::linkProgram()
|
||||
|
||||
if( loc != -1 )
|
||||
{
|
||||
_attribInfoMap[name] = std::pair<GLint,GLenum>(loc,type);
|
||||
_attribInfoMap[name] = ActiveVarInfo(loc,type,size);
|
||||
|
||||
osg::notify(osg::INFO)
|
||||
<< "\tAttrib \"" << name << "\""
|
||||
<< " loc=" << loc
|
||||
<< " size=" << size
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user