MCPcopy Create free account
hub / github.com/NVIDIA-RTX/RTXPT / BuildUIResolutionPicker

Method BuildUIResolutionPicker

Rtxpt/SampleUI.cpp:274–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274void SampleUI::BuildUIResolutionPicker()
275{
276 if (!ImGui::BeginPopupModal("Resolution Picker", nullptr, ImGuiWindowFlags_AlwaysAutoResize))
277 return;
278
279 struct Resolution { int w, h; const char* label; };
280 static const Resolution standardResolutions[] = {
281 { 1280, 720, "1280 x 720 (16:9)" },
282 { 1280, 800, "1280 x 800 (16:10)" },
283 { 1366, 768, "1366 x 768 (16:9)" },
284 { 1440, 900, "1440 x 900 (16:10)" },
285 { 1600, 900, "1600 x 900 (16:9)" },
286 { 1680, 1050, "1680 x 1050 (16:10)" },
287 { 1920, 1080, "1920 x 1080 (16:9)" },
288 { 1920, 1200, "1920 x 1200 (16:10)" },
289 { 2560, 1440, "2560 x 1440 (16:9)" },
290 { 2560, 1600, "2560 x 1600 (16:10)" },
291 { 3840, 2160, "3840 x 2160 (16:9)" },
292 { 3840, 2400, "3840 x 2400 (16:10)" },
293 };
294
295 const GLFWvidmode* monitorMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
296 int currentW = (int)m_app.GetDisplaySize().x;
297 int currentH = (int)m_app.GetDisplaySize().y;
298
299 ImGui::Text("Click to change resolution:");
300 ImGui::Separator();
301
302 for (const auto& res : standardResolutions)
303 {
304 if (res.w > monitorMode->width || res.h > monitorMode->height)
305 continue;
306
307 bool isCurrent = (res.w == currentW && res.h == currentH);
308 std::string displayLabel = std::string(res.label) + (isCurrent ? " [current]" : "");
309 if (ImGui::Selectable(displayLabel.c_str(), isCurrent))
310 {
311 glfwSetWindowSize(GetDeviceManager()->GetWindow(), res.w, res.h);
312 ImGui::CloseCurrentPopup();
313 }
314 }
315
316 ImGui::Separator();
317 if (ImGui::Button("Cancel", { -1, 0 }) || ImGui::IsKeyPressed(ImGuiKey_Escape))
318 ImGui::CloseCurrentPopup();
319
320 ImGui::EndPopup();
321}
322
323void SampleUI::BuildUIPerformancePresets()
324{

Callers

nothing calls this directly

Calls 2

ButtonClass · 0.85
GetDisplaySizeMethod · 0.80

Tested by

no test coverage detected