MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / SaveLightSettings

Function SaveLightSettings

BakingLab/BakingLab.cpp:167–219  ·  view source on GitHub ↗

Save lighting settings to a file

Source from the content-addressed store, hash-verified

165
166// Save lighting settings to a file
167static void SaveLightSettings(HWND parentWindow)
168{
169 wchar currDirectory[MAX_PATH] = { 0 };
170 GetCurrentDirectory(ArraySize_(currDirectory), currDirectory);
171
172 wchar filePath[MAX_PATH] = { 0 };
173
174 OPENFILENAME ofn;
175 ZeroMemory(&ofn , sizeof(ofn));
176 ofn.lStructSize = sizeof(ofn);
177 ofn.hwndOwner = parentWindow;
178 ofn.lpstrFile = filePath;
179 ofn.nMaxFile = ArraySize_(filePath);
180 ofn.lpstrFilter = L"All Files (*.*)\0*.*\0Light Settings (*.lts)\0*.lts\0";
181 ofn.nFilterIndex = 2;
182 ofn.lpstrFileTitle = nullptr;
183 ofn.nMaxFileTitle = 0;
184 ofn.lpstrInitialDir = nullptr;
185 ofn.lpstrTitle = L"Save Light Settings File As..";
186 ofn.lpstrDefExt = L"lts";
187 ofn.Flags = OFN_OVERWRITEPROMPT;
188 bool succeeded = GetSaveFileName(&ofn) != 0;
189 SetCurrentDirectory(currDirectory);
190
191 if(succeeded)
192 {
193 try
194 {
195 std::vector<SettingInfo> settingInfo;
196 settingInfo.resize(NumLightSettings);
197 for(uint64 i = 0; i < NumLightSettings; ++i)
198 {
199 // Serialize some metadata so that we can skip out of date settings on load
200 settingInfo[i].Name = LightSettings[i]->Name();
201 settingInfo[i].DataSize = LightSettings[i]->SerializedValueSize();
202 Assert_(settingInfo[i].DataSize > 0);
203 }
204
205 FileWriteSerializer serializer(filePath);
206 SerializeItem(serializer, settingInfo);
207
208 for(uint64 i = 0; i < NumLightSettings; ++i)
209 LightSettings[i]->SerializeValue(serializer);
210 }
211 catch(Exception e)
212 {
213 std::wstring errorString = L"Error occured while saving light settings file:\n" + e.GetMessage();
214 MessageBox(parentWindow, errorString.c_str(), L"Error", MB_OK | MB_ICONERROR);
215 }
216 }
217
218 SetCurrentDirectory(currDirectory);
219}
220
221// Save a skydome texture as a DDS file
222static void SaveEXRScreenshot(HWND parentWindow, ID3D11ShaderResourceView* screenSRV)

Callers 1

UpdateMethod · 0.85

Calls 4

SerializeItemFunction · 0.85
SerializedValueSizeMethod · 0.80
resizeMethod · 0.45
SerializeValueMethod · 0.45

Tested by

no test coverage detected