OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ShaderAttribute.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_SHADERATTRIBUTE
15 #define OSG_SHADERATTRIBUTE 1
16 
17 #include <osg/StateAttribute>
18 #include <osg/Shader>
19 #include <osg/Uniform>
20 
21 namespace osg {
22 
24 {
25  public :
26 
28 
31 
32  virtual osg::Object* cloneType() const;
33  virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new ShaderAttribute(*this,copyop); }
34  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ShaderAttribute *>(obj)!=NULL; }
35  virtual const char* libraryName() const { return "osg"; }
36  virtual const char* className() const { return "ShaderAttribute"; }
37 
39  virtual int compare(const StateAttribute& sa) const;
40 
41 
42  void setType(Type type);
43  virtual Type getType() const { return _type; }
44 
45  unsigned int addShader(Shader* shader) { return _shaderComponent->addShader(shader); }
46  void removeShader(unsigned int i) { _shaderComponent->removeShader(i); }
47  unsigned int getNumShaders() const { return _shaderComponent->getNumShaders(); }
48  Shader* getShader(unsigned int i) { return _shaderComponent->getShader(i); }
49  const Shader* getShader(unsigned int i) const { return _shaderComponent->getShader(i); }
50 
51  unsigned int addUniform(Uniform* uniform);
52  void removeUniform(unsigned int i);
53  unsigned int getNumUniforms() const { return _uniforms.size(); }
54  Uniform* getUniform(unsigned int i) { return _uniforms[i].get(); }
55  const Uniform* getUniform(unsigned int i) const { return _uniforms[i].get(); }
56 
57  virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const;
58 
59  virtual void apply(State& state) const;
60 
61  virtual void compileGLObjects(State& state) const;
62 
63  virtual void resizeGLObjectBuffers(unsigned int maxSize);
64 
65  virtual void releaseGLObjects(State* state=0) const;
66 
67  protected :
68 
69  virtual ~ShaderAttribute();
70 
71  typedef std::vector< osg::ref_ptr<osg::Uniform> > Uniforms;
72 
74  Uniforms _uniforms;
75 };
76 
77 }
78 
79 #endif
#define OSG_EXPORT
Definition: Export.h:43
const Uniform * getUniform(unsigned int i) const
#define NULL
Definition: Export.h:59
virtual const char * libraryName() const
virtual const char * className() const
Shader * getShader(unsigned int i)
std::vector< osg::ref_ptr< osg::Uniform > > Uniforms
virtual bool isSameKindAs(const osg::Object *obj) const
virtual osg::Object * clone(const osg::CopyOp &copyop) const
Uniform * getUniform(unsigned int i)
unsigned int getNumShaders() const
T * cloneType(const T *t)
Definition: Object.h:284
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: GLU.h:71
bool get(float &f) const
unsigned int getNumUniforms() const
unsigned int addShader(Shader *shader)
Definition: AlphaFunc.h:19
const Shader * getShader(unsigned int i) const
void removeShader(unsigned int i)
virtual Type getType() const