void JsonStream::valueToString(json::Value &value, std::string& str) { if(value.GetType() == json::StringVal) { str = value.ToString(); } else { mIsOk = false; mErrorLog += "JsonStream::valueToString() Error: wrong type\n"; } }
Sampler::Ptr SamplerLoader::ParseSampler(ResourceManager& resourceManager, const json::Value& root) { if (root.GetType() == StringVal) { return resourceManager.LoadResource<Sampler>(root.ToString()); } SamplerDescription description; description.samplingMode = ParseSamplingMode(root["sampling"].ToString("basic")); description.anisotropicEnabled = root["anisotropicEnabled"].ToBool(false); description.minFilter = ParseInterpolatioMode(root["minFilter"].ToString("linear")); description.magFilter = ParseInterpolatioMode(root["magFilter"].ToString("linear")); description.mipFilter = ParseInterpolatioMode(root["mipFilter"].ToString("linear")); description.uWrap = ParseEdgeSampling(root["uWrap"].ToString("clamp")); description.vWrap = ParseEdgeSampling(root["vWrap"].ToString("clamp")); description.wWrap = ParseEdgeSampling(root["wWrap"].ToString("clamp")); description.useMipMap = root["useMipMap"].ToBool(description.useMipMap); description.mipBias = root["mipBias"].ToFloat(description.mipBias); description.minLOD = root["minLOD"].ToFloat(description.minLOD); description.maxLOD = root["maxLOD"].ToFloat(description.maxLOD); description.compareFunction = JsonTypeHelper::ParseCompareFunction(root["compareFunction"].ToString("never")); description.maxAnisotropy = root["maxAnisotropy"].ToInt(description.maxAnisotropy); if (root.HasKey("borderColor")) { description.borderColor = JsonTypeHelper::ParseColor(root["borderColor"]); } return resourceManager.GetGraphics()->CreateSampler(description); }