|
|
@@ -1,21 +1,18 @@
|
|
|
-#include "ShaderProgramCreator.h"
|
|
|
+#include "MaterialShaderProgramCreator.h"
|
|
|
#include "Util/Scanner/Scanner.h"
|
|
|
#include "Misc/Parser.h"
|
|
|
-#include "BuildinVariable.h"
|
|
|
+#include "MaterialBuildinVariable.h"
|
|
|
#include <boost/assign/list_of.hpp>
|
|
|
#include <boost/foreach.hpp>
|
|
|
#include <boost/property_tree/ptree.hpp>
|
|
|
|
|
|
|
|
|
-namespace material {
|
|
|
-
|
|
|
-
|
|
|
//==============================================================================
|
|
|
// Statics =
|
|
|
//==============================================================================
|
|
|
|
|
|
boost::unordered_map<GLenum, const char*>
|
|
|
-ShaderProgramCreator::glTypeToTxt = boost::assign::map_list_of
|
|
|
+MaterialShaderProgramCreator::glTypeToTxt = boost::assign::map_list_of
|
|
|
(GL_FLOAT, "float")
|
|
|
(GL_FLOAT_VEC2, "vec2")
|
|
|
(GL_FLOAT_VEC3, "vec3")
|
|
|
@@ -26,7 +23,7 @@ ShaderProgramCreator::glTypeToTxt = boost::assign::map_list_of
|
|
|
(GL_NONE, "void");
|
|
|
|
|
|
|
|
|
-ConstCharPtrHashMap<GLenum>::Type ShaderProgramCreator::txtToGlType =
|
|
|
+ConstCharPtrHashMap<GLenum>::Type MaterialShaderProgramCreator::txtToGlType =
|
|
|
boost::assign::map_list_of
|
|
|
("float", GL_FLOAT)
|
|
|
("vec2", GL_FLOAT_VEC2)
|
|
|
@@ -38,22 +35,22 @@ ConstCharPtrHashMap<GLenum>::Type ShaderProgramCreator::txtToGlType =
|
|
|
("void", GL_NONE);
|
|
|
|
|
|
|
|
|
-boost::unordered_map<ShaderProgramCreator::ArgQualifier, const char*>
|
|
|
- ShaderProgramCreator::argQualifierToTxt = boost::assign::map_list_of
|
|
|
+boost::unordered_map<MaterialShaderProgramCreator::ArgQualifier, const char*>
|
|
|
+ MaterialShaderProgramCreator::argQualifierToTxt = boost::assign::map_list_of
|
|
|
(AQ_IN, "in")
|
|
|
(AQ_OUT, "out")
|
|
|
(AQ_INOUT, "inout");
|
|
|
|
|
|
|
|
|
-ConstCharPtrHashMap<ShaderProgramCreator::ArgQualifier>::Type
|
|
|
- ShaderProgramCreator::txtToArgQualifier = boost::assign::map_list_of
|
|
|
+ConstCharPtrHashMap<MaterialShaderProgramCreator::ArgQualifier>::Type
|
|
|
+ MaterialShaderProgramCreator::txtToArgQualifier = boost::assign::map_list_of
|
|
|
("in", AQ_IN)
|
|
|
("out", AQ_OUT)
|
|
|
("inout", AQ_INOUT);
|
|
|
|
|
|
|
|
|
ConstCharPtrHashMap<GLenum>::Type
|
|
|
- ShaderProgramCreator::varyingNameToGlType =
|
|
|
+ MaterialShaderProgramCreator::varyingNameToGlType =
|
|
|
boost::assign::map_list_of
|
|
|
("vTexCoords", GL_FLOAT_VEC2)
|
|
|
("vNormal", GL_FLOAT_VEC3)
|
|
|
@@ -65,7 +62,7 @@ ConstCharPtrHashMap<GLenum>::Type
|
|
|
//==============================================================================
|
|
|
// Constructor =
|
|
|
//==============================================================================
|
|
|
-ShaderProgramCreator::ShaderProgramCreator(
|
|
|
+MaterialShaderProgramCreator::MaterialShaderProgramCreator(
|
|
|
const boost::property_tree::ptree& pt)
|
|
|
{
|
|
|
parseShaderProgramTag(pt);
|
|
|
@@ -75,14 +72,14 @@ ShaderProgramCreator::ShaderProgramCreator(
|
|
|
//==============================================================================
|
|
|
// Destructor =
|
|
|
//==============================================================================
|
|
|
-ShaderProgramCreator::~ShaderProgramCreator()
|
|
|
+MaterialShaderProgramCreator::~MaterialShaderProgramCreator()
|
|
|
{}
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
// parseShaderFileForFunctionDefinitions =
|
|
|
//==============================================================================
|
|
|
-void ShaderProgramCreator::parseShaderFileForFunctionDefinitions(
|
|
|
+void MaterialShaderProgramCreator::parseShaderFileForFunctionDefinitions(
|
|
|
const char* filename)
|
|
|
{
|
|
|
Scanner::Scanner scanner(filename, false);
|
|
|
@@ -277,7 +274,7 @@ void ShaderProgramCreator::parseShaderFileForFunctionDefinitions(
|
|
|
//==============================================================================
|
|
|
// parseUntilNewline =
|
|
|
//==============================================================================
|
|
|
-void ShaderProgramCreator::parseUntilNewline(Scanner::Scanner& scanner)
|
|
|
+void MaterialShaderProgramCreator::parseUntilNewline(Scanner::Scanner& scanner)
|
|
|
{
|
|
|
const Scanner::Token* token = &scanner.getCrntToken();
|
|
|
Scanner::TokenCode prevTc;
|
|
|
@@ -303,7 +300,7 @@ void ShaderProgramCreator::parseUntilNewline(Scanner::Scanner& scanner)
|
|
|
//==============================================================================
|
|
|
// getNextTokenAndSkipNewlines =
|
|
|
//==============================================================================
|
|
|
-void ShaderProgramCreator::getNextTokenAndSkipNewlines(
|
|
|
+void MaterialShaderProgramCreator::getNextTokenAndSkipNewlines(
|
|
|
Scanner::Scanner& scanner)
|
|
|
{
|
|
|
const Scanner::Token* token;
|
|
|
@@ -322,7 +319,7 @@ void ShaderProgramCreator::getNextTokenAndSkipNewlines(
|
|
|
//==============================================================================
|
|
|
// parseShaderProgramTag =
|
|
|
//==============================================================================
|
|
|
-void ShaderProgramCreator::parseShaderProgramTag(
|
|
|
+void MaterialShaderProgramCreator::parseShaderProgramTag(
|
|
|
const boost::property_tree::ptree& pt)
|
|
|
{
|
|
|
usingTexCoordsAttrib = usingNormalAttrib = usingTangentAttrib = false;
|
|
|
@@ -435,7 +432,7 @@ void ShaderProgramCreator::parseShaderProgramTag(
|
|
|
//==============================================================================
|
|
|
// parseInputTag =
|
|
|
//==============================================================================
|
|
|
-void ShaderProgramCreator::parseInputTag(
|
|
|
+void MaterialShaderProgramCreator::parseInputTag(
|
|
|
const boost::property_tree::ptree& pt, std::string& line)
|
|
|
{
|
|
|
using namespace boost::property_tree;
|
|
|
@@ -447,9 +444,9 @@ void ShaderProgramCreator::parseInputTag(
|
|
|
// Buildin or varying
|
|
|
if(!valuePt)
|
|
|
{
|
|
|
- BuildinVariable::BuildinEnum tmp;
|
|
|
+ MaterialBuildinVariable::BuildinEnum tmp;
|
|
|
|
|
|
- if(BuildinVariable::isBuildin(name.c_str(), &tmp, &glType))
|
|
|
+ if(MaterialBuildinVariable::isBuildin(name.c_str(), &tmp, &glType))
|
|
|
{
|
|
|
const char* glTypeTxt = glTypeToTxt.at(glType);
|
|
|
line += "uniform ";
|
|
|
@@ -512,7 +509,7 @@ void ShaderProgramCreator::parseInputTag(
|
|
|
//==============================================================================
|
|
|
// parseOperatorTag =
|
|
|
//==============================================================================
|
|
|
-void ShaderProgramCreator::parseOperatorTag(
|
|
|
+void MaterialShaderProgramCreator::parseOperatorTag(
|
|
|
const boost::property_tree::ptree& pt)
|
|
|
{
|
|
|
using namespace boost::property_tree;
|
|
|
@@ -579,11 +576,8 @@ void ShaderProgramCreator::parseOperatorTag(
|
|
|
//==============================================================================
|
|
|
// compareStrings =
|
|
|
//==============================================================================
|
|
|
-bool ShaderProgramCreator::compareStrings(
|
|
|
+bool MaterialShaderProgramCreator::compareStrings(
|
|
|
const std::string& a, const std::string& b)
|
|
|
{
|
|
|
return a < b;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-} // end namespace
|