56 void assign(
unsigned int size,
const unsigned char* data);
59 unsigned int getSize()
const {
return static_cast<unsigned int>(
_data.size()); }
73 typedef std::vector<unsigned char>
Data;
165#ifdef OSG_USE_DEPRECATED_API
167 static Shader* readShaderFile( Type type,
const std::string& fileName );
170 bool loadShaderSourceFromFile(
const std::string& fileName );
340 typedef std::vector< osg::ref_ptr<osg::Shader> >
Shaders;
#define GL_FRAGMENT_SHADER
Definition GLDefines:92
#define GL_GEOMETRY_SHADER
Definition GLDefines:198
#define GL_TESS_CONTROL_SHADER
Definition GLDefines:242
#define GL_COMPUTE_SHADER
Definition GLDefines:477
#define GL_TESS_EVALUATION_SHADER
Definition GLDefines:241
#define GL_VERTEX_SHADER
Definition GLDefines:93
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
std::set< std::string > ShaderDefines
Definition Shader:37
Implements a simple buffered value for values that need to be buffered on a per graphics context basi...
Definition buffered_value:27
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
osg::Program is an application-level abstraction of an OpenGL glProgram.
Definition Program:52
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
Simple class for wrapping up the data used in OpenGL ES 2's glShaderBinary calls.
Definition Shader:42
Data _data
Definition Shader:74
unsigned char * getData()
Get a ptr to the shader binary data.
Definition Shader:62
ShaderBinary(const ShaderBinary &rhs, const osg::CopyOp ©op=osg::CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy.
META_Object(osg, ShaderBinary)
void allocate(unsigned int size)
Allocated a data buffer of specified size.
const unsigned char * getData() const
Get a const ptr to the shader binary data.
Definition Shader:65
static ShaderBinary * readShaderBinaryFile(const std::string &fileName)
Read shader binary from file.
unsigned int getSize() const
Get the size of the shader binary data.
Definition Shader:59
std::vector< unsigned char > Data
Definition Shader:73
void assign(unsigned int size, const unsigned char *data)
Assign shader binary data, copying the specified data into locally stored data buffer,...
osg::Shader is an application-level abstraction of an OpenGL glShader.
Definition Shader:89
ShaderDefines _shaderRequirements
Definition Shader:304
const std::string & getFileName() const
Get filename to which the shader source code belongs.
Definition Shader:127
Type _type
Definition Shader:294
Shader(const Shader &rhs, const osg::CopyOp ©op=osg::CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy.
std::string _shaderFileName
Definition Shader:295
ShaderBinary * getShaderBinary()
Get the Shader's ShaderBinary, return NULL if none is assigned.
Definition Shader:160
Shader(Type type, ShaderBinary *shaderBinary)
const ShaderDefines & getShaderRequirements() const
Definition Shader:153
Shader(Type type, const std::string &source)
void _parseShaderDefines(const std::string &str, ShaderDefines &defines)
osg::buffered_value< osg::ref_ptr< ShaderObjects > > _pcsList
Definition Shader:310
bool setType(Type t)
Set the Shader type as an enum.
ShaderDefinesMode
Definition Shader:138
@ USE_SHADER_PRAGMA
Definition Shader:139
@ USE_MANUAL_SETTINGS
Definition Shader:140
ShaderDefines _shaderDefines
Definition Shader:303
const ShaderBinary * getShaderBinary() const
Get the const Shader's ShaderBinary, return NULL if none is assigned.
Definition Shader:163
void releaseGLObjects(osg::State *state=0) const
release OpenGL objects in specified graphics context if State object is passed, otherwise release Ope...
ShaderDefines & getShaderDefines()
Definition Shader:148
virtual void resizeGLObjectBuffers(unsigned int maxSize)
Resize any per context GLObject buffers to specified size.
osg::ref_ptr< ShaderBinary > _shaderBinary
Definition Shader:297
std::string _shaderSource
Definition Shader:296
void _computeShaderDefines()
std::set< osg::Program * > ProgramSet
osg::Programs that this osg::Shader is attached to
Definition Shader:307
Type getType() const
Get the Shader type as an enum.
Definition Shader:117
ShaderDefinesMode getShaderDefinesMode() const
Definition Shader:144
void setShaderBinary(ShaderBinary *shaderBinary)
Set the Shader using a ShaderBinary.
Definition Shader:157
void setFileName(const std::string &fileName)
Set file name for the shader source code.
Definition Shader:124
const ShaderDefines & getShaderDefines() const
Definition Shader:149
ProgramSet _programSet
Definition Shader:308
void setShaderSource(const std::string &sourceText)
Set the Shader's source code text from a string.
bool addProgramRef(osg::Program *program)
void setShaderDefines(const ShaderDefines &shaderDefs)
Definition Shader:147
ShaderDefines & getShaderRequirements()
Definition Shader:152
PerContextShader * getPCS(osg::State &state) const
const char * getTypename() const
Get the Shader type as a descriptive string.
@ FRAGMENT
Definition Shader:97
@ GEOMETRY
Definition Shader:96
@ UNDEFINED
Definition Shader:99
@ TESSCONTROL
Definition Shader:94
@ COMPUTE
Definition Shader:98
@ TESSEVALUATION
Definition Shader:95
@ VERTEX
Definition Shader:93
void setShaderDefinesMode(ShaderDefinesMode sdm)
Definition Shader:143
OpenThreads::Mutex _programSetMutex
Definition Shader:309
bool removeProgramRef(osg::Program *program)
int compare(const Shader &rhs) const
Shader(Type type=UNDEFINED)
const std::string & getShaderSource() const
Query the shader's source code text.
Definition Shader:134
CodeInjectionMap & getCodeInjectionMap()
Get the code injection map.
Definition Shader:185
void setShaderRequirements(const ShaderDefines &shaderDefs)
Definition Shader:151
void addCodeInjection(float position, const std::string &code)
Add code injection that will be placed in the main shader to enable support for this shader.
Definition Shader:182
void compileShader(osg::State &state) const
If needed, compile the PCS's glShader.
void dirtyShader()
Mark our PCSs as needing recompilation.
const CodeInjectionMap & getCodeInjectionMap() const
Get the const code injection map.
Definition Shader:188
CodeInjectionMap _codeInjectionMap
Definition Shader:299
static Shader::Type getTypeId(const std::string &tname)
std::multimap< float, std::string > CodeInjectionMap
The code injection map used when generating the main shader during main shader composition.
Definition Shader:174
ShaderDefinesMode _shaderDefinesMode
Definition Shader:302
PerContextShader (PCS) is an OSG-internal encapsulation of glShader per-GL context.
Definition Shader:212
void attachShader(GLuint program) const
Attach our glShader to a glProgram.
bool needsCompile() const
Definition Shader:223
std::string _defineStr
Define string passed on to Shaders to help configure them.
Definition Shader:247
bool _needsCompile
Does our glShader need to be recompiled?
Definition Shader:250
const Shader * _shader
Pointer to our parent osg::Shader.
Definition Shader:238
bool getInfoLog(std::string &infoLog) const
void setDefineString(const std::string &defStr)
Definition Shader:216
GLuint _glShaderHandle
Handle to the actual glShader.
Definition Shader:244
bool isCompiled() const
Definition Shader:224
void compileShader(osg::State &state)
const std::string & getDefineString() const
Definition Shader:217
const unsigned int _contextID
Definition Shader:255
PerContextShader(const Shader *shader, unsigned int contextID)
GLuint getHandle() const
Definition Shader:219
bool _isCompiled
Is our glShader successfully compiled?
Definition Shader:253
osg::ref_ptr< osg::GLExtensions > _extensions
Pointer to this context's extension functions.
Definition Shader:241
void detachShader(GLuint program) const
Detach our glShader from a glProgram.
ShaderObjects(const Shader *shader, unsigned int contextID)
unsigned int _contextID
Definition Shader:270
PerContextShader * createPerContextShader(const std::string &defineStr)
PerContextShader * getPCS(const std::string &defineStr) const
PerContextShaders _perContextShaders
Definition Shader:272
std::vector< osg::ref_ptr< PerContextShader > > PerContextShaders
Definition Shader:266
const Shader * _shader
Definition Shader:271
unsigned int getNumShaders() const
Definition Shader:332
std::vector< osg::ref_ptr< osg::Shader > > Shaders
Definition Shader:340
virtual void releaseGLObjects(State *state=0) const
If State is non-zero, this function releases any associated OpenGL objects for the specified graphics...
virtual void compileGLObjects(State &state) const
const osg::Shader * getShader(unsigned int i) const
Definition Shader:330
ShaderComponent(const ShaderComponent &sc, const CopyOp ©op=CopyOp::SHALLOW_COPY)
META_Object(osg, ShaderComponent)
Shaders _shaders
Definition Shader:341
osg::Shader * getShader(unsigned int i)
Definition Shader:329
void removeShader(unsigned int i)
virtual void resizeGLObjectBuffers(unsigned int maxSize)
Resize any per context GLObject buffers to specified size.
unsigned int addShader(osg::Shader *shader)
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
#define OSG_EXPORT
Definition Export:39