From Mike Weiblen, "adds sourcefiles for beginnings of .osg fileformat i/o support
> - enhancemens to core GLSL classes to support file i/o"
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
/* file: include/osg/Program
|
||||
* author: Mike Weiblen 2005-03-30
|
||||
* author: Mike Weiblen 2005-04-06
|
||||
*/
|
||||
|
||||
#ifndef OSG_PROGRAM
|
||||
@@ -330,6 +330,11 @@ class SG_EXPORT Program : public osg::StateAttribute
|
||||
* Mark Program as needing relink. Return true for success */
|
||||
bool addShader( Shader* shader );
|
||||
|
||||
unsigned int getNumShaders() const { return _shaderList.size(); }
|
||||
|
||||
Shader* getShader( unsigned int i ) { return _shaderList[i].get(); }
|
||||
const Shader* getShader( unsigned int i ) const { return _shaderList[i].get(); }
|
||||
|
||||
/** Remove osg::Shader from this osg::Program.
|
||||
* Mark Program as needing relink. Return true for success */
|
||||
bool removeShader( Shader* shader );
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
/* file: include/osg/Shader
|
||||
* author: Mike Weiblen 2005-03-30
|
||||
* author: Mike Weiblen 2005-04-06
|
||||
*/
|
||||
|
||||
#ifndef OSG_SHADER
|
||||
@@ -41,19 +41,21 @@ class SG_EXPORT Shader : public osg::Object
|
||||
|
||||
enum Type {
|
||||
VERTEX = GL_VERTEX_SHADER,
|
||||
FRAGMENT = GL_FRAGMENT_SHADER
|
||||
FRAGMENT = GL_FRAGMENT_SHADER,
|
||||
UNDEFINED = -1
|
||||
};
|
||||
|
||||
Shader();
|
||||
Shader( Type type, const char* sourceText = 0 );
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
Shader(const Shader& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osg, Shader); // see note in Shader.cpp Shader()
|
||||
META_Object(osg, Shader);
|
||||
|
||||
int compare(const Shader& rhs) const;
|
||||
|
||||
// data access methods.
|
||||
bool setType( Type t );
|
||||
|
||||
/** Load the Shader's source code text from a string. */
|
||||
void setShaderSource( const char* sourceText );
|
||||
@@ -97,6 +99,8 @@ class SG_EXPORT Shader : public osg::Object
|
||||
* in the OpenGL context related to contextID.*/
|
||||
static void flushDeletedGlShaders(unsigned int contextID,double currentTime, double& availableTime);
|
||||
|
||||
static Shader::Type getTypeId( const std::string& tname );
|
||||
|
||||
protected:
|
||||
/** PerContextShader (PCS) is an OSG-internal encapsulation of glShader per-GL context. */
|
||||
class PerContextShader : public osg::Referenced
|
||||
@@ -139,7 +143,6 @@ class SG_EXPORT Shader : public osg::Object
|
||||
};
|
||||
|
||||
protected: /*methods*/
|
||||
Shader(); // undesired, temporarily required by META_Object.
|
||||
virtual ~Shader();
|
||||
|
||||
PerContextShader* getPCS(unsigned int contextID) const;
|
||||
@@ -149,7 +152,7 @@ class SG_EXPORT Shader : public osg::Object
|
||||
bool removeProgramRef( Program* program );
|
||||
|
||||
protected: /*data*/
|
||||
const Type _type;
|
||||
Type _type;
|
||||
std::string _name;
|
||||
std::string _shaderSource;
|
||||
/** osg::Programs that this osg::Shader is attached to */
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
/* file: include/osg/Uniform
|
||||
* author: Mike Weiblen 2005-03-29
|
||||
* author: Mike Weiblen 2005-04-06
|
||||
*/
|
||||
|
||||
// NOTICE: This code is CLOSED during construction and/or renovation!
|
||||
@@ -158,6 +158,7 @@ class SG_EXPORT Uniform : public Object
|
||||
};
|
||||
|
||||
public:
|
||||
Uniform();
|
||||
Uniform( const char* name, Type type );
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
|
||||
@@ -165,6 +166,8 @@ class SG_EXPORT Uniform : public Object
|
||||
|
||||
META_Object(osg, Uniform);
|
||||
|
||||
bool setType( Type t );
|
||||
bool setName( const std::string& name );
|
||||
|
||||
/** Get the name of glUniform. */
|
||||
const std::string& getName() const { return _name; }
|
||||
@@ -175,6 +178,8 @@ class SG_EXPORT Uniform : public Object
|
||||
/** Return the name of a type as string. */
|
||||
static const char* getTypename( Type t );
|
||||
|
||||
static Uniform::Type getTypeId( const std::string& tname );
|
||||
|
||||
/** convenient construction w/ assignment */
|
||||
explicit Uniform( const char* name, float f );
|
||||
explicit Uniform( const char* name, int i );
|
||||
@@ -243,8 +248,8 @@ class SG_EXPORT Uniform : public Object
|
||||
|
||||
|
||||
protected:
|
||||
const std::string _name;
|
||||
const Type _type;
|
||||
std::string _name;
|
||||
Type _type;
|
||||
union {
|
||||
GLfloat f1; // float
|
||||
GLfloat f2[2]; // vec2
|
||||
@@ -259,7 +264,6 @@ class SG_EXPORT Uniform : public Object
|
||||
} _data;
|
||||
|
||||
private:
|
||||
Uniform(); // disallowed
|
||||
Uniform& operator=(const Uniform&); // disallowed
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user