From Mike Weiblen, updates to GL Shadler Language support
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
/* file: src/osg/Shader.cpp
|
||||
* author: Mike Weiblen 2005-04-06
|
||||
* author: Mike Weiblen 2005-04-07
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
@@ -197,12 +197,19 @@ const char* Shader::getTypename() const
|
||||
|
||||
void Shader::compileShader( unsigned int contextID ) const
|
||||
{
|
||||
getPCS( contextID )->compileShader();
|
||||
PerContextShader* pcs = getPCS( contextID );
|
||||
if( pcs ) pcs->compileShader();
|
||||
}
|
||||
|
||||
|
||||
Shader::PerContextShader* Shader::getPCS(unsigned int contextID) const
|
||||
{
|
||||
if( getType() == UNDEFINED )
|
||||
{
|
||||
osg::notify(osg::WARN) << "Shader type is UNDEFINED" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( ! _pcsList[contextID].valid() )
|
||||
{
|
||||
_pcsList[contextID] = new PerContextShader( this, contextID );
|
||||
@@ -213,13 +220,15 @@ Shader::PerContextShader* Shader::getPCS(unsigned int contextID) const
|
||||
|
||||
void Shader::attachShader(unsigned int contextID, GLuint program) const
|
||||
{
|
||||
getPCS( contextID )->attachShader( program );
|
||||
PerContextShader* pcs = getPCS( contextID );
|
||||
if( pcs ) pcs->attachShader( program );
|
||||
}
|
||||
|
||||
|
||||
void Shader::getGlShaderInfoLog(unsigned int contextID, std::string& log) const
|
||||
{
|
||||
getPCS( contextID )->getInfoLog( log );
|
||||
PerContextShader* pcs = getPCS( contextID );
|
||||
if( pcs ) pcs->getInfoLog( log );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
/* file: src/osg/Uniform.cpp
|
||||
* author: Mike Weiblen 2005-04-06
|
||||
* author: Mike Weiblen 2005-04-07
|
||||
*/
|
||||
|
||||
// NOTICE: This code is CLOSED during construction and/or renovation!
|
||||
@@ -64,7 +64,7 @@ Uniform::Uniform( const char* name, Type type ) :
|
||||
case SAMPLER_1D_SHADOW: set( 0 ); break;
|
||||
case SAMPLER_2D_SHADOW: set( 0 ); break;
|
||||
default:
|
||||
osg::notify(osg::WARN) << "unhandled Uniform type" << std::endl;
|
||||
osg::notify(osg::WARN) << "UNDEFINED Uniform type" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ bool Uniform::setType( Type t )
|
||||
{
|
||||
if( _type != UNDEFINED )
|
||||
{
|
||||
osg::notify(osg::WARN) << "cannot change type of Uniform" << std::endl;
|
||||
osg::notify(osg::WARN) << "cannot change Uniform type" << std::endl;
|
||||
return false;
|
||||
}
|
||||
_type = t;
|
||||
@@ -90,7 +90,7 @@ bool Uniform::setName( const std::string& name )
|
||||
{
|
||||
if( _name != "" )
|
||||
{
|
||||
osg::notify(osg::WARN) << "cannot change name of Uniform" << std::endl;
|
||||
osg::notify(osg::WARN) << "cannot change Uniform name" << std::endl;
|
||||
return false;
|
||||
}
|
||||
_name = name;
|
||||
@@ -191,7 +191,7 @@ int Uniform::compareData(const Uniform& rhs) const
|
||||
return 0;
|
||||
|
||||
default:
|
||||
osg::notify(osg::FATAL) << "how got here?" << std::endl;
|
||||
osg::notify(osg::WARN) << "cannot compare UNDEFINED Uniform type" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -257,13 +257,14 @@ void Uniform::copyData(const Uniform& rhs)
|
||||
break;
|
||||
|
||||
default:
|
||||
osg::notify(osg::FATAL) << "how got here?" << std::endl;
|
||||
osg::notify(osg::WARN) << "cannot copy UNDEFINED Uniform type" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool Uniform::isCompatibleType( Type t ) const
|
||||
{
|
||||
if( (t==UNDEFINED) || (getType()==UNDEFINED) ) return false;
|
||||
if( t == getType() ) return true;
|
||||
if( repType(t) == repType(getType()) ) return true;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ bool Shader_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
Shader& shader = static_cast<Shader&>(obj);
|
||||
|
||||
if (fr.matchSequence("type %s"))
|
||||
if (fr.matchSequence("type %w"))
|
||||
{
|
||||
shader.setType( Shader::getTypeId(fr[1].getStr()) );
|
||||
fr+=2;
|
||||
|
||||
@@ -29,7 +29,7 @@ bool Uniform_readLocalData(Object& obj, Input& fr)
|
||||
|
||||
Uniform& uniform = static_cast<Uniform&>(obj);
|
||||
|
||||
if (fr.matchSequence("type %s"))
|
||||
if (fr.matchSequence("type %w"))
|
||||
{
|
||||
uniform.setType( Uniform::getTypeId(fr[1].getStr()) );
|
||||
fr+=2;
|
||||
@@ -53,9 +53,9 @@ bool Uniform_writeLocalData(const Object& obj,Output& fw)
|
||||
{
|
||||
const Uniform& uniform = static_cast<const Uniform&>(obj);
|
||||
|
||||
fw.indent() << "type " << uniform.getTypename( uniform.getType() ) << std::endl;
|
||||
fw.indent() << "type " << Uniform::getTypename( uniform.getType() ) << std::endl;
|
||||
|
||||
fw.indent() << "name "<< uniform.getName() << std::endl;
|
||||
fw.indent() << "name "<< fw.wrapString(uniform.getName()) << std::endl;
|
||||
|
||||
// TODO write uniform value based on type
|
||||
|
||||
|
||||
Reference in New Issue
Block a user