|
@@ -14,10 +14,8 @@
|
|
|
#include <boost/lexical_cast.hpp>
|
|
#include <boost/lexical_cast.hpp>
|
|
|
#include <algorithm>
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
-
|
|
|
|
|
namespace anki {
|
|
namespace anki {
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
// MaterialVariable =
|
|
// MaterialVariable =
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
@@ -26,21 +24,18 @@ namespace anki {
|
|
|
MaterialVariable::~MaterialVariable()
|
|
MaterialVariable::~MaterialVariable()
|
|
|
{}
|
|
{}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
GLenum MaterialVariable::getGlDataType() const
|
|
GLenum MaterialVariable::getGlDataType() const
|
|
|
{
|
|
{
|
|
|
return oneSProgVar->getGlDataType();
|
|
return oneSProgVar->getGlDataType();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
const std::string& MaterialVariable::getName() const
|
|
const std::string& MaterialVariable::getName() const
|
|
|
{
|
|
{
|
|
|
return oneSProgVar->getName();
|
|
return oneSProgVar->getName();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
void MaterialVariable::init(const char* shaderProgVarName,
|
|
void MaterialVariable::init(const char* shaderProgVarName,
|
|
|
const PassLevelToShaderProgramHashMap& sProgs)
|
|
const PassLevelToShaderProgramHashMap& sProgs)
|
|
@@ -87,7 +82,6 @@ void MaterialVariable::init(const char* shaderProgVarName,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
// Material =
|
|
// Material =
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
@@ -117,12 +111,10 @@ ConstCharPtrHashMap<GLenum>::Type Material::txtToBlengGlEnum =
|
|
|
Material::Material()
|
|
Material::Material()
|
|
|
{}
|
|
{}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
Material::~Material()
|
|
Material::~Material()
|
|
|
{}
|
|
{}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
void Material::load(const char* filename)
|
|
void Material::load(const char* filename)
|
|
|
{
|
|
{
|
|
@@ -140,18 +132,15 @@ void Material::load(const char* filename)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
|
|
void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
|
|
|
{
|
|
{
|
|
|
using namespace boost::property_tree;
|
|
using namespace boost::property_tree;
|
|
|
|
|
|
|
|
- //
|
|
|
|
|
// renderingStage
|
|
// renderingStage
|
|
|
//
|
|
//
|
|
|
renderingStage = pt.get<int>("renderingStage");
|
|
renderingStage = pt.get<int>("renderingStage");
|
|
|
|
|
|
|
|
- //
|
|
|
|
|
// passes
|
|
// passes
|
|
|
//
|
|
//
|
|
|
boost::optional<std::string> pass =
|
|
boost::optional<std::string> pass =
|
|
@@ -166,7 +155,6 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
|
|
|
passes.push_back("DUMMY");
|
|
passes.push_back("DUMMY");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //
|
|
|
|
|
// levelsOfDetail
|
|
// levelsOfDetail
|
|
|
//
|
|
//
|
|
|
boost::optional<int> lod = pt.get_optional<int>("levelsOfDetail");
|
|
boost::optional<int> lod = pt.get_optional<int>("levelsOfDetail");
|
|
@@ -180,7 +168,6 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
|
|
|
levelsOfDetail = 1;
|
|
levelsOfDetail = 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //
|
|
|
|
|
// shadow
|
|
// shadow
|
|
|
//
|
|
//
|
|
|
boost::optional<int> sw = pt.get_optional<int>("shadow");
|
|
boost::optional<int> sw = pt.get_optional<int>("shadow");
|
|
@@ -190,7 +177,6 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
|
|
|
shadow = sw.get();
|
|
shadow = sw.get();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //
|
|
|
|
|
// blendFunctions
|
|
// blendFunctions
|
|
|
//
|
|
//
|
|
|
boost::optional<const ptree&> blendFuncsTree =
|
|
boost::optional<const ptree&> blendFuncsTree =
|
|
@@ -230,7 +216,6 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //
|
|
|
|
|
// depthTesting
|
|
// depthTesting
|
|
|
//
|
|
//
|
|
|
boost::optional<int> dp = pt.get_optional<int>("depthTesting");
|
|
boost::optional<int> dp = pt.get_optional<int>("depthTesting");
|
|
@@ -240,7 +225,6 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
|
|
|
depthTesting = dp.get();
|
|
depthTesting = dp.get();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //
|
|
|
|
|
// wireframe
|
|
// wireframe
|
|
|
//
|
|
//
|
|
|
boost::optional<int> wf = pt.get_optional<int>("wireframe");
|
|
boost::optional<int> wf = pt.get_optional<int>("wireframe");
|
|
@@ -250,7 +234,6 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
|
|
|
wireframe = wf.get();
|
|
wireframe = wf.get();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //
|
|
|
|
|
// shaderProgram
|
|
// shaderProgram
|
|
|
//
|
|
//
|
|
|
MaterialShaderProgramCreator mspc(pt.get_child("shaderProgram"));
|
|
MaterialShaderProgramCreator mspc(pt.get_child("shaderProgram"));
|
|
@@ -284,7 +267,6 @@ void Material::parseMaterialTag(const boost::property_tree::ptree& pt)
|
|
|
populateVariables(pt.get_child("shaderProgram"));
|
|
populateVariables(pt.get_child("shaderProgram"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
std::string Material::createShaderProgSourceToCache(const std::string& source)
|
|
std::string Material::createShaderProgSourceToCache(const std::string& source)
|
|
|
{
|
|
{
|
|
@@ -316,7 +298,6 @@ std::string Material::createShaderProgSourceToCache(const std::string& source)
|
|
|
return newfPathName.string();
|
|
return newfPathName.string();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
void Material::populateVariables(const boost::property_tree::ptree& pt)
|
|
void Material::populateVariables(const boost::property_tree::ptree& pt)
|
|
|
{
|
|
{
|
|
@@ -382,7 +363,6 @@ void Material::populateVariables(const boost::property_tree::ptree& pt)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //
|
|
|
|
|
// Now combine
|
|
// Now combine
|
|
|
//
|
|
//
|
|
|
std::map<std::string, GLenum>::const_iterator it = allVarNames.begin();
|
|
std::map<std::string, GLenum>::const_iterator it = allVarNames.begin();
|
|
@@ -487,7 +467,6 @@ void Material::populateVariables(const boost::property_tree::ptree& pt)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
template<typename Type, size_t n>
|
|
template<typename Type, size_t n>
|
|
|
Type Material::setMathType(const char* str)
|
|
Type Material::setMathType(const char* str)
|
|
@@ -504,7 +483,6 @@ Type Material::setMathType(const char* str)
|
|
|
return out;
|
|
return out;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//==============================================================================
|
|
//==============================================================================
|
|
|
const MaterialVariable& Material::findVariableByName(const char* name) const
|
|
const MaterialVariable& Material::findVariableByName(const char* name) const
|
|
|
{
|
|
{
|
|
@@ -517,5 +495,4 @@ const MaterialVariable& Material::findVariableByName(const char* name) const
|
|
|
return *(it->second);
|
|
return *(it->second);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
} // end namespace
|
|
} // end namespace
|