From Paul Martz, "This change is based on current CVS. (Note both Brede and I have submitted

changes to this plugin that aren't in current CVS yet -- this change is
based on current CVS, not our changed files.)

This changes how shader palette records are parsed to support GLSL per the
OpenFlight 16.1 spec. Existing functionality for 16.0 files is preserved.

The change to Document.h simply adds an enum for VERSION_16_1."
This commit is contained in:
Robert Osfield
2006-05-15 13:22:59 +00:00
parent 35ed4f742f
commit d42a8fd269
2 changed files with 50 additions and 16 deletions

View File

@@ -38,7 +38,8 @@ enum Version
VERSION_15_6 = 1560,
VERSION_15_7 = 1570,
VERSION_15_8 = 1580,
VERSION_16_0 = 1600
VERSION_16_0 = 1600,
VERSION_16_1 = 1610
};
enum CoordUnits {
@@ -75,8 +76,8 @@ class Document
{
public:
Document();
virtual ~Document();
Document();
virtual ~Document();
void setOptions(const osgDB::ReaderWriter::Options* options) { _options = options; }
const osgDB::ReaderWriter::Options* getOptions() const { return _options.get(); }

View File

@@ -618,28 +618,61 @@ protected:
int32 index = in.readInt32();
int32 type = in.readInt32();
std::string name = in.readString(1024);
std::string vertexProgramFilename = in.readString(1024);
std::string fragmentProgramFilename = in.readString(1024);
if (type == CG)
{
// CG support is currently not implemented. Just parse.
std::string vertexProgramFilename = in.readString(1024);
std::string fragmentProgramFilename = in.readString(1024);
int32 vertexProgramProfile = in.readInt32();
int32 fragmentProgramProfile = in.readInt32();
std::string vertexProgramEntry = in.readString(256);
std::string fragmentProgramEntry = in.readString(256);
}
if (type == GLSL)
{
int32 vertexProgramFileCount( 1 );
int32 fragmentProgramFileCount( 1 );
if (document.version() > VERSION_16_1)
{
// In 16.1, possibly multiple filenames for each vertex and fragment program.
vertexProgramFileCount = in.readInt32();
fragmentProgramFileCount = in.readInt32();
}
// else 16.0
// Technically, 16.0 didn't support GLSL, but this plugin
// supports it with a single vertex shader filename and a
// single fragment shader filename.
osg::Program* program = new osg::Program;
program->setName(name);
std::string vertexProgramFilePath = osgDB::findDataFile(vertexProgramFilename);
if (!vertexProgramFilePath.empty())
int idx;
for( idx=0; idx<vertexProgramFileCount; idx++)
{
osg::Shader* vertexShader = osg::Shader::readShaderFile(osg::Shader::VERTEX, vertexProgramFilePath);
if (vertexShader)
program->addShader( vertexShader );
}
std::string vertexProgramFilename = in.readString(1024);
std::string fragmentProgramFilePath = osgDB::findDataFile(fragmentProgramFilename);
if (!fragmentProgramFilePath.empty())
std::string vertexProgramFilePath = osgDB::findDataFile(vertexProgramFilename);
if (!vertexProgramFilePath.empty())
{
osg::Shader* vertexShader = osg::Shader::readShaderFile(osg::Shader::VERTEX, vertexProgramFilePath);
if (vertexShader)
program->addShader( vertexShader );
}
}
for( idx=0; idx<fragmentProgramFileCount; idx++)
{
osg::Shader* fragmentShader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, fragmentProgramFilePath);
if (fragmentShader)
program->addShader( fragmentShader );
std::string fragmentProgramFilename = in.readString(1024);
std::string fragmentProgramFilePath = osgDB::findDataFile(fragmentProgramFilename);
if (!fragmentProgramFilePath.empty())
{
osg::Shader* fragmentShader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, fragmentProgramFilePath);
if (fragmentShader)
program->addShader( fragmentShader );
}
}
ShaderPool* shaderPool = document.getOrCreateShaderPool();