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:
Robert Osfield
2005-04-07 20:23:58 +00:00
parent c8a3198129
commit 84e8338be1
11 changed files with 373 additions and 34 deletions

View File

@@ -13,7 +13,7 @@
*/
/* file: src/osg/Shader.cpp
* author: Mike Weiblen 2005-03-30
* author: Mike Weiblen 2005-04-06
*/
#include <fstream>
@@ -99,11 +99,8 @@ Shader::Shader(Type type, const char* sourceText) :
}
Shader::Shader() :
_type(VERTEX)
_type(UNDEFINED)
{
// TODO this default constructor is inappropriate for the Shader class.
// It exists for now because it is required by META_OBject
osg::notify(osg::FATAL) << "how got here?" << std::endl;
}
Shader::Shader(const Shader& rhs, const osg::CopyOp& copyop):
@@ -118,6 +115,17 @@ Shader::~Shader()
{
}
bool Shader::setType( Type t )
{
if( _type != UNDEFINED )
{
osg::notify(osg::WARN) << "cannot change type of Shader" << std::endl;
return false;
}
_type = t;
return true;
}
int Shader::compare(const Shader& rhs) const
{
@@ -172,13 +180,21 @@ const char* Shader::getTypename() const
{
switch( getType() )
{
case VERTEX: return "Vertex";
case FRAGMENT: return "Fragment";
case VERTEX: return "VERTEX";
case FRAGMENT: return "FRAGMENT";
default: return "UNDEFINED";
}
}
/*static*/ Shader::Type Shader::getTypeId( const std::string& tname )
{
if( tname == "VERTEX" ) return VERTEX;
if( tname == "FRAGMENT" ) return FRAGMENT;
return UNDEFINED;
}
void Shader::compileShader( unsigned int contextID ) const
{
getPCS( contextID )->compileShader();