ShaderAttribute
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_SHADERATTRIBUTE
#define OSG_SHADERATTRIBUTE 1
#include <osg/StateAttribute>
#include <osg/Shader>
#include <osg/Uniform>
namespace osg {
class OSG_EXPORT ShaderAttribute : public StateAttribute
{
public :
ShaderAttribute();
ShaderAttribute(const ShaderAttribute& sa,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
virtual osg::Object* cloneType() const;
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new ShaderAttribute(*this,copyop); }
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ShaderAttribute *>(obj)!=NULL; }
virtual const char* libraryName() const { return "osg"; }
virtual const char* className() const { return "ShaderAttribute"; }
virtual int compare(const StateAttribute& sa) const;
void setType(Type type);
virtual Type getType() const { return _type; }
unsigned int addShader(Shader* shader) { return _shaderComponent->addShader(shader); }
void removeShader(unsigned int i) { _shaderComponent->removeShader(i); }
unsigned int getNumShaders() const { return _shaderComponent->getNumShaders(); }
Shader* getShader(unsigned int i) { return _shaderComponent->getShader(i); }
const Shader* getShader(unsigned int i) const { return _shaderComponent->getShader(i); }
unsigned int addUniform(Uniform* uniform);
void removeUniform(unsigned int i);
unsigned int getNumUniforms() const { return _uniforms.size(); }
Uniform* getUniform(unsigned int i) { return _uniforms[i].get(); }
const Uniform* getUniform(unsigned int i) const { return _uniforms[i].get(); }
virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const;
virtual void apply(State& state) const;
virtual void compileGLObjects(State& state) const;
virtual void resizeGLObjectBuffers(unsigned int maxSize);
virtual void releaseGLObjects(State* state=0) const;
protected :
virtual ~ShaderAttribute();
typedef std::vector< osg::ref_ptr<osg::Uniform> > Uniforms;
Type _type;
Uniforms _uniforms;
};
}
#endif
Shader
StateAttribute
Uniform
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Object
Definition Object:61
osg::ShaderAttribute::getModeUsage
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
osg::ShaderAttribute::Uniforms
std::vector< osg::ref_ptr< osg::Uniform > > Uniforms
Definition ShaderAttribute:71
osg::ShaderAttribute::isSameKindAs
virtual bool isSameKindAs(const osg::Object *obj) const
Definition ShaderAttribute:34
osg::ShaderAttribute::compileGLObjects
virtual void compileGLObjects(State &state) const
osg::ShaderAttribute::apply
virtual void apply(State &state) const
osg::ShaderAttribute::getUniform
const Uniform * getUniform(unsigned int i) const
Definition ShaderAttribute:55
osg::ShaderAttribute::removeShader
void removeShader(unsigned int i)
Definition ShaderAttribute:46
osg::ShaderAttribute::clone
virtual osg::Object * clone(const osg::CopyOp &copyop) const
Definition ShaderAttribute:33
osg::ShaderAttribute::getUniform
Uniform * getUniform(unsigned int i)
Definition ShaderAttribute:54
osg::ShaderAttribute::getNumUniforms
unsigned int getNumUniforms() const
Definition ShaderAttribute:53
osg::ShaderAttribute::className
virtual const char * className() const
Definition ShaderAttribute:36
osg::ShaderAttribute::getNumShaders
unsigned int getNumShaders() const
Definition ShaderAttribute:47
osg::ShaderAttribute::removeUniform
void removeUniform(unsigned int i)
osg::ShaderAttribute::getType
virtual Type getType() const
Definition ShaderAttribute:43
osg::ShaderAttribute::ShaderAttribute
ShaderAttribute()
osg::ShaderAttribute::_type
Type _type
Definition ShaderAttribute:73
osg::ShaderAttribute::ShaderAttribute
ShaderAttribute(const ShaderAttribute &sa, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
osg::ShaderAttribute::addShader
unsigned int addShader(Shader *shader)
Definition ShaderAttribute:45
osg::ShaderAttribute::addUniform
unsigned int addUniform(Uniform *uniform)
osg::ShaderAttribute::getShader
const Shader * getShader(unsigned int i) const
Definition ShaderAttribute:49
osg::ShaderAttribute::_uniforms
Uniforms _uniforms
Definition ShaderAttribute:74
osg::ShaderAttribute::resizeGLObjectBuffers
virtual void resizeGLObjectBuffers(unsigned int maxSize)
osg::ShaderAttribute::libraryName
virtual const char * libraryName() const
Definition ShaderAttribute:35
osg::ShaderAttribute::~ShaderAttribute
virtual ~ShaderAttribute()
osg::ShaderAttribute::releaseGLObjects
virtual void releaseGLObjects(State *state=0) const
osg::ShaderAttribute::cloneType
virtual osg::Object * cloneType() const
osg::ShaderAttribute::getShader
Shader * getShader(unsigned int i)
Definition ShaderAttribute:48
osg::ShaderAttribute::setType
void setType(Type type)
osg::ShaderAttribute::compare
virtual int compare(const StateAttribute &sa) const
osg::Shader
Definition Shader:89
osg::StateAttribute::StateAttribute
StateAttribute()
osg::StateAttribute::_shaderComponent
ref_ptr< ShaderComponent > _shaderComponent
Definition StateAttribute:396
osg::StateAttribute::Type
Type
Definition StateAttribute:124
osg::State
Definition State:80
osg::Uniform
Definition Uniform:414
osg
Definition AlphaFunc:19
NULL
#define NULL
Definition osg/Export:55
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39
osg::StateAttribute::ModeUsage
Definition StateAttribute:308