aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llwlparammanager.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/llwlparammanager.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/newview/llwlparammanager.cpp')
-rw-r--r--linden/indra/newview/llwlparammanager.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp
index 9f23b37..1707fe9 100644
--- a/linden/indra/newview/llwlparammanager.cpp
+++ b/linden/indra/newview/llwlparammanager.cpp
@@ -104,16 +104,16 @@ LLWLParamManager::~LLWLParamManager()
104{ 104{
105} 105}
106 106
107void LLWLParamManager::loadPresets(const LLString& file_name) 107void LLWLParamManager::loadPresets(const std::string& file_name)
108{ 108{
109 // if fileName exists, use legacy loading form the big file, otherwise, search the sky 109 // if fileName exists, use legacy loading form the big file, otherwise, search the sky
110 // directory, and add the list 110 // directory, and add the list
111 if(file_name != "") 111 if(file_name != "")
112 { 112 {
113 LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", file_name)); 113 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", file_name));
114 LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL; 114 LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL;
115 115
116 llifstream presetsXML(path_name.c_str()); 116 llifstream presetsXML(path_name);
117 117
118 if (presetsXML) 118 if (presetsXML)
119 { 119 {
@@ -136,7 +136,7 @@ void LLWLParamManager::loadPresets(const LLString& file_name)
136 // otherwise, search the sky directory and find things there 136 // otherwise, search the sky directory and find things there
137 else 137 else
138 { 138 {
139 LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); 139 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", ""));
140 LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL; 140 LL_INFOS2("AppInit", "Shaders") << "Loading WindLight settings from " << path_name << LL_ENDL;
141 141
142 //mParamList.clear(); 142 //mParamList.clear();
@@ -161,10 +161,10 @@ void LLWLParamManager::loadPresets(const LLString& file_name)
161 // not much error checking here since we're getting rid of this 161 // not much error checking here since we're getting rid of this
162 std::string sky_name = unescaped_name.substr(0, unescaped_name.size() - 4); 162 std::string sky_name = unescaped_name.substr(0, unescaped_name.size() - 4);
163 163
164 LLString cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", name)); 164 std::string cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", name));
165 LL_DEBUGS2("AppInit", "Shaders") << "Loading sky from " << cur_path << LL_ENDL; 165 LL_DEBUGS2("AppInit", "Shaders") << "Loading sky from " << cur_path << LL_ENDL;
166 166
167 std::ifstream sky_xml(cur_path.c_str()); 167 llifstream sky_xml(cur_path);
168 if (sky_xml) 168 if (sky_xml)
169 { 169 {
170 LLSD sky_data(LLSD::emptyMap()); 170 LLSD sky_data(LLSD::emptyMap());
@@ -172,17 +172,18 @@ void LLWLParamManager::loadPresets(const LLString& file_name)
172 parser->parse(sky_xml, sky_data, LLSDSerialize::SIZE_UNLIMITED); 172 parser->parse(sky_xml, sky_data, LLSDSerialize::SIZE_UNLIMITED);
173 173
174 addParamSet(sky_name, sky_data); 174 addParamSet(sky_name, sky_data);
175 sky_xml.close();
175 } 176 }
176 } 177 }
177 } 178 }
178 } 179 }
179} 180}
180 181
181void LLWLParamManager::savePresets(const LLString & fileName) 182void LLWLParamManager::savePresets(const std::string & fileName)
182{ 183{
183 LLSD paramsData(LLSD::emptyMap()); 184 LLSD paramsData(LLSD::emptyMap());
184 185
185 LLString pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", fileName)); 186 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", fileName));
186 187
187 for(std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.begin(); 188 for(std::map<std::string, LLWLParamSet>::iterator mIt = mParamList.begin();
188 mIt != mParamList.end(); 189 mIt != mParamList.end();
@@ -191,7 +192,7 @@ void LLWLParamManager::savePresets(const LLString & fileName)
191 paramsData[mIt->first] = mIt->second.getAll(); 192 paramsData[mIt->first] = mIt->second.getAll();
192 } 193 }
193 194
194 std::ofstream presetsXML(pathName.c_str()); 195 llofstream presetsXML(pathName);
195 196
196 LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); 197 LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
197 198
@@ -200,7 +201,7 @@ void LLWLParamManager::savePresets(const LLString & fileName)
200 presetsXML.close(); 201 presetsXML.close();
201} 202}
202 203
203void LLWLParamManager::loadPreset(const LLString & name) 204void LLWLParamManager::loadPreset(const std::string & name)
204{ 205{
205 // bugfix for SL-46920: preventing filenames that break stuff. 206 // bugfix for SL-46920: preventing filenames that break stuff.
206 char * curl_str = curl_escape(name.c_str(), name.size()); 207 char * curl_str = curl_escape(name.c_str(), name.size());
@@ -213,7 +214,7 @@ void LLWLParamManager::loadPreset(const LLString & name)
213 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename)); 214 std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", escaped_filename));
214 llinfos << "Loading WindLight sky setting from " << pathName << llendl; 215 llinfos << "Loading WindLight sky setting from " << pathName << llendl;
215 216
216 std::ifstream presetsXML(pathName.c_str()); 217 llifstream presetsXML(pathName);
217 218
218 if (presetsXML) 219 if (presetsXML)
219 { 220 {
@@ -232,6 +233,7 @@ void LLWLParamManager::loadPreset(const LLString & name)
232 { 233 {
233 setParamSet(name, paramsData); 234 setParamSet(name, paramsData);
234 } 235 }
236 presetsXML.close();
235 } 237 }
236 else 238 else
237 { 239 {
@@ -244,7 +246,7 @@ void LLWLParamManager::loadPreset(const LLString & name)
244 propagateParameters(); 246 propagateParameters();
245} 247}
246 248
247void LLWLParamManager::savePreset(const LLString & name) 249void LLWLParamManager::savePreset(const std::string & name)
248{ 250{
249 // bugfix for SL-46920: preventing filenames that break stuff. 251 // bugfix for SL-46920: preventing filenames that break stuff.
250 char * curl_str = curl_escape(name.c_str(), name.size()); 252 char * curl_str = curl_escape(name.c_str(), name.size());
@@ -262,7 +264,7 @@ void LLWLParamManager::savePreset(const LLString & name)
262 paramsData = mParamList[name].getAll(); 264 paramsData = mParamList[name].getAll();
263 265
264 // write to file 266 // write to file
265 std::ofstream presetsXML(pathName.c_str()); 267 llofstream presetsXML(pathName);
266 LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter(); 268 LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
267 formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY); 269 formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
268 presetsXML.close(); 270 presetsXML.close();
@@ -279,13 +281,13 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader)
279 281
280 if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) 282 if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT)
281 { 283 {
282 shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, mRotatedLightDir.mV); 284 shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mRotatedLightDir.mV);
283 shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV); 285 shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV);
284 } 286 }
285 287
286 else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) 288 else if (shader->mShaderGroup == LLGLSLShader::SG_SKY)
287 { 289 {
288 shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, mClampedLightDir.mV); 290 shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mClampedLightDir.mV);
289 } 291 }
290 292
291 shader->uniform1f("scene_light_strength", mSceneLightStrength); 293 shader->uniform1f("scene_light_strength", mSceneLightStrength);
@@ -343,9 +345,9 @@ void LLWLParamManager::propagateParameters(void)
343 mCurParams.set("lightnorm", mLightDir); 345 mCurParams.set("lightnorm", mLightDir);
344 346
345 // bind the variables for all shaders only if we're using WindLight 347 // bind the variables for all shaders only if we're using WindLight
346 LLShaderMgr::shader_iter shaders_iter, end_shaders; 348 LLViewerShaderMgr::shader_iter shaders_iter, end_shaders;
347 end_shaders = LLShaderMgr::endShaders(); 349 end_shaders = LLViewerShaderMgr::instance()->endShaders();
348 for(shaders_iter = LLShaderMgr::beginShaders(); shaders_iter != end_shaders; ++shaders_iter) 350 for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter)
349 { 351 {
350 if (shaders_iter->mProgramObject != 0 352 if (shaders_iter->mProgramObject != 0
351 && (gPipeline.canUseWindLightShaders() 353 && (gPipeline.canUseWindLightShaders()
@@ -406,9 +408,9 @@ void LLWLParamManager::update(LLViewerCamera * cam)
406 lightNorm3 *= LLQuaternion(-(camYaw + camYawDelta), LLVector3(0.f, 1.f, 0.f)); 408 lightNorm3 *= LLQuaternion(-(camYaw + camYawDelta), LLVector3(0.f, 1.f, 0.f));
407 mRotatedLightDir = LLVector4(lightNorm3, 0.f); 409 mRotatedLightDir = LLVector4(lightNorm3, 0.f);
408 410
409 LLShaderMgr::shader_iter shaders_iter, end_shaders; 411 LLViewerShaderMgr::shader_iter shaders_iter, end_shaders;
410 end_shaders = LLShaderMgr::endShaders(); 412 end_shaders = LLViewerShaderMgr::instance()->endShaders();
411 for(shaders_iter = LLShaderMgr::beginShaders(); shaders_iter != end_shaders; ++shaders_iter) 413 for(shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter)
412 { 414 {
413 if (shaders_iter->mProgramObject != 0 415 if (shaders_iter->mProgramObject != 0
414 && (gPipeline.canUseWindLightShaders() 416 && (gPipeline.canUseWindLightShaders()
@@ -531,7 +533,7 @@ bool LLWLParamManager::removeParamSet(const std::string& name, bool delete_from_
531 533
532 if(delete_from_disk) 534 if(delete_from_disk)
533 { 535 {
534 LLString path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", "")); 536 std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/skies", ""));
535 537
536 // use full curl escaped name 538 // use full curl escaped name
537 char * curl_str = curl_escape(name.c_str(), name.size()); 539 char * curl_str = curl_escape(name.c_str(), name.size());
@@ -553,10 +555,10 @@ LLWLParamManager * LLWLParamManager::instance()
553 { 555 {
554 sInstance = new LLWLParamManager(); 556 sInstance = new LLWLParamManager();
555 557
556 sInstance->loadPresets(""); 558 sInstance->loadPresets(LLStringUtil::null);
557 559
558 // load the day 560 // load the day
559 sInstance->mDay.loadDayCycle("Default.xml"); 561 sInstance->mDay.loadDayCycle(std::string("Default.xml"));
560 562
561 // *HACK - sets cloud scrolling to what we want... fix this better in the future 563 // *HACK - sets cloud scrolling to what we want... fix this better in the future
562 sInstance->getParamSet("Default", sInstance->mCurParams); 564 sInstance->getParamSet("Default", sInstance->mCurParams);