MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / screenSizeUI

Function screenSizeUI

Source/Falcor/Core/SampleApp.cpp:304–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302}
303
304bool screenSizeUI(Gui::Widgets& widget, uint2& screenDims)
305{
306 static const uint2 resolutions[] = {
307 {0, 0},
308 {1280, 720},
309 {1920, 1080},
310 {1920, 1200},
311 {2560, 1440},
312 {3840, 2160},
313 };
314
315 static const auto initDropDown = [](const uint2 resolutions[], uint32_t count) -> Gui::DropdownList
316 {
317 Gui::DropdownList list;
318 for (uint32_t i = 0; i < count; i++)
319 {
320 list.push_back({i, std::to_string(resolutions[i].x) + "x" + std::to_string(resolutions[i].y)});
321 }
322 list[0] = {0, "Custom"};
323 return list;
324 };
325
326 auto initDropDownVal = [](const uint2 resolutions[], uint32_t count, uint2 screenDims)
327 {
328 for (uint32_t i = 0; i < count; i++)
329 {
330 if (all(screenDims == resolutions[i]))
331 return i;
332 }
333 return 0u;
334 };
335
336 static const Gui::DropdownList dropdownList = initDropDown(resolutions, (uint32_t)std::size(resolutions));
337 uint32_t currentVal = initDropDownVal(resolutions, (uint32_t)std::size(resolutions), screenDims);
338
339 widget.var("Screen Resolution", screenDims);
340 if (widget.dropdown("Change Resolution", dropdownList, currentVal) && (currentVal != 0))
341 {
342 screenDims = resolutions[currentVal];
343 return true;
344 }
345 return false;
346}
347
348std::string SampleApp::getKeyboardShortcutsStr()
349{

Callers 1

renderGlobalUIMethod · 0.85

Calls 6

varMethod · 0.80
dropdownMethod · 0.80
to_stringFunction · 0.50
allFunction · 0.50
sizeFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected