25 #include <osg/GLExtensions>
27 #include <osg/buffered_value>
53 void allocate(
unsigned int size);
56 void assign(
unsigned int size,
const unsigned char* data);
59 unsigned int getSize()
const {
return static_cast<unsigned int>(_data.size()); }
62 unsigned char*
getData() {
return _data.empty() ? 0 : &(_data.front()); }
65 const unsigned char*
getData()
const {
return _data.empty() ? 0 : &(_data.front()); }
69 static ShaderBinary* readShaderBinaryFile(
const std::string& fileName);
73 typedef std::vector<unsigned char>
Data;
103 Shader(Type
type,
const std::string& source );
111 int compare(
const Shader& rhs)
const;
114 bool setType(Type t);
120 const char* getTypename()
const;
124 inline void setFileName(
const std::string& fileName) { _shaderFileName = fileName; }
127 inline const std::string&
getFileName()
const {
return _shaderFileName; }
131 void setShaderSource(
const std::string& sourceText);
171 bool loadShaderSourceFromFile(
const std::string& fileName );
183 void addCodeInjection(
float position,
const std::string& code) { _codeInjectionMap.insert(CodeInjectionMap::value_type(position, code)); }
194 virtual void resizeGLObjectBuffers(
unsigned int maxSize);
199 void releaseGLObjects(
osg::State* state=0)
const;
212 static void deleteGlShader(
unsigned int contextID, GLuint shader);
216 static void flushDeletedGlShaders(
unsigned int contextID,
double currentTime,
double& availableTime);
221 static void discardDeletedGlShaders(
unsigned int contextID);
223 static Shader::Type getTypeId(
const std::string& tname );
237 void requestCompile();
241 bool getInfoLog( std::string& infoLog )
const;
244 void attachShader(GLuint program)
const;
247 void detachShader(GLuint program)
const;
292 void requestCompile();
305 void _computeShaderDefines();
306 void _parseShaderDefines(
const std::string& str, ShaderDefines& defines);
342 void removeShader(
unsigned int i);
347 unsigned int getNumShaders()
const {
return static_cast<unsigned int>(_shaders.size()); }
349 virtual void compileGLObjects(
State& state)
const;
350 virtual void resizeGLObjectBuffers(
unsigned int maxSize);
351 virtual void releaseGLObjects(
State* state=0)
const;
355 typedef std::vector< osg::ref_ptr<osg::Shader> >
Shaders;
void setShaderBinary(ShaderBinary *shaderBinary)
const std::string & getFileName() const
std::vector< osg::ref_ptr< osg::Shader > > Shaders
void setShaderDefinesMode(ShaderDefinesMode sdm)
ShaderDefines _shaderDefines
CodeInjectionMap & getCodeInjectionMap()
#define GL_FRAGMENT_SHADER
void setShaderRequirements(const ShaderDefines &shaderDefs)
const ShaderBinary * getShaderBinary() const
void setDefineString(const std::string &defStr)
#define GL_COMPUTE_SHADER
ShaderDefines & getShaderDefines()
const CodeInjectionMap & getCodeInjectionMap() const
ShaderDefines _shaderRequirements
std::vector< osg::ref_ptr< PerContextShader > > PerContextShaders
const unsigned char * getData() const
const ShaderDefines & getShaderDefines() const
std::set< std::string > ShaderDefines
osg::ref_ptr< ShaderBinary > _shaderBinary
std::vector< unsigned char > Data
unsigned int getNumShaders() const
osg::buffered_value< osg::ref_ptr< ShaderObjects > > _pcsList
bool needsCompile() const
unsigned int getSize() const
std::set< osg::Program * > ProgramSet
#define META_Object(library, name)
OSGDB_EXPORT osg::Shader * readShaderFile(const std::string &filename, const Options *options)
const std::string & getDefineString() const
ShaderDefines & getShaderRequirements()
void setShaderDefines(const ShaderDefines &shaderDefs)
std::string _shaderFileName
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
CodeInjectionMap _codeInjectionMap
const std::string & getShaderSource() const
osg::Shader * getShader(unsigned int i)
osg::ref_ptr< osg::GLExtensions > _extensions
const osg::Shader * getShader(unsigned int i) const
#define GL_TESS_CONTROL_SHADER
const unsigned int _contextID
ShaderDefinesMode _shaderDefinesMode
unsigned char * getData()
ShaderBinary * getShaderBinary()
void addCodeInjection(float position, const std::string &code)
std::string _shaderSource
const ShaderDefines & getShaderRequirements() const
#define GL_TESS_EVALUATION_SHADER
ShaderDefinesMode getShaderDefinesMode() const
std::multimap< float, std::string > CodeInjectionMap
void setFileName(const std::string &fileName)
PerContextShaders _perContextShaders
#define GL_GEOMETRY_SHADER