diff --git a/include/neural-graphics-primitives/openxr_hmd.h b/include/neural-graphics-primitives/openxr_hmd.h index ac6cacab5f212653baf36ecd762a9f81e0444263..fd2fc197f39c671417becd20c4fa2dcf7330987b 100644 --- a/include/neural-graphics-primitives/openxr_hmd.h +++ b/include/neural-graphics-primitives/openxr_hmd.h @@ -65,9 +65,9 @@ inline std::string to_string(EnvironmentBlendMode mode) { class OpenXRHMD { public: enum class ControlFlow { - CONTINUE, - RESTART, - QUIT, + Continue, + Restart, + Quit, }; struct FrameInfo { @@ -135,8 +135,8 @@ public: return m_supported_environment_blend_modes; } - const std::string& supported_environment_blend_modes_string() const { - return m_supported_environment_blend_modes_string; + const char* supported_environment_blend_modes_imgui_string() const { + return m_supported_environment_blend_modes_imgui_string.data(); } // if true call begin_frame and end_frame - does not imply visibility @@ -193,7 +193,7 @@ private: XrViewConfigurationProperties m_view_configuration_properties = {XR_TYPE_VIEW_CONFIGURATION_PROPERTIES}; std::vector<XrViewConfigurationView> m_view_configuration_views; std::vector<EnvironmentBlendMode> m_supported_environment_blend_modes; - std::string m_supported_environment_blend_modes_string; + std::vector<char> m_supported_environment_blend_modes_imgui_string; EnvironmentBlendMode m_environment_blend_mode = EnvironmentBlendMode::Opaque; // actions diff --git a/src/openxr_hmd.cu b/src/openxr_hmd.cu index 0befdfce511a95c0fd6b2badf53dce88db4d1d38..b8f64bbe6921f9d5e2925256483f70c01b064b6c 100644 --- a/src/openxr_hmd.cu +++ b/src/openxr_hmd.cu @@ -439,12 +439,13 @@ void OpenXRHMD::init_check_for_xr_blend_mode() { throw std::runtime_error{"No OpenXR environment blend modes found"}; } + std::sort(std::begin(supported_blend_modes), std::end(supported_blend_modes)); if (m_print_environment_blend_modes) { tlog::info() << fmt::format("Environment Blend Modes ({}):", supported_blend_modes.size()); } - m_supported_environment_blend_modes.resize(size); - m_supported_environment_blend_modes_string = ""; + m_supported_environment_blend_modes.resize(supported_blend_modes.size()); + m_supported_environment_blend_modes_imgui_string.clear(); for (size_t i = 0; i < supported_blend_modes.size(); ++i) { if (m_print_environment_blend_modes) { tlog::info() << fmt::format("\t{}", XrEnumStr(supported_blend_modes[i])); @@ -452,11 +453,13 @@ void OpenXRHMD::init_check_for_xr_blend_mode() { auto b = (EnvironmentBlendMode)supported_blend_modes[i]; m_supported_environment_blend_modes[i] = b; - m_supported_environment_blend_modes_string += to_string(b) + "\0"; - } - m_supported_environment_blend_modes_string += "\0"; + auto b_str = to_string(b); + std::copy(std::begin(b_str), std::end(b_str), std::back_inserter(m_supported_environment_blend_modes_imgui_string)); + m_supported_environment_blend_modes_imgui_string.emplace_back('\0'); + } + m_supported_environment_blend_modes_imgui_string.emplace_back('\0'); m_environment_blend_mode = m_supported_environment_blend_modes.front(); } @@ -813,11 +816,11 @@ void OpenXRHMD::session_state_change(XrSessionState state, ControlFlow& flow) { break; } case XR_SESSION_STATE_EXITING: { - flow = ControlFlow::QUIT; + flow = ControlFlow::Quit; break; } case XR_SESSION_STATE_LOSS_PENDING: { - flow = ControlFlow::RESTART; + flow = ControlFlow::Restart; break; } default: { @@ -828,7 +831,7 @@ void OpenXRHMD::session_state_change(XrSessionState state, ControlFlow& flow) { OpenXRHMD::ControlFlow OpenXRHMD::poll_events() { bool more = true; - ControlFlow flow = ControlFlow::CONTINUE; + ControlFlow flow = ControlFlow::Continue; while (more) { // poll events XrEventDataBuffer event {XR_TYPE_EVENT_DATA_BUFFER, nullptr}; @@ -849,7 +852,7 @@ OpenXRHMD::ControlFlow OpenXRHMD::poll_events() { } case XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING: { - flow = ControlFlow::RESTART; + flow = ControlFlow::Restart; break; } diff --git a/src/testbed.cu b/src/testbed.cu index 9d322d6e7f058e52e29edccf3ac0eb77b4e7bef1..9ae3e4a9dd8902f5e0e6507be3971bb4c2e0372d 100644 --- a/src/testbed.cu +++ b/src/testbed.cu @@ -934,7 +934,7 @@ void Testbed::imgui() { static int blend_mode_idx = 0; const auto& supported_blend_modes = m_hmd->supported_environment_blend_modes(); if (supported_blend_modes.size() > 1) { - if (ImGui::Combo("Environment blend mode", &blend_mode_idx, m_hmd->supported_environment_blend_modes_string().c_str())) { + if (ImGui::Combo("Environment", &blend_mode_idx, m_hmd->supported_environment_blend_modes_imgui_string())) { auto b = m_hmd->supported_environment_blend_modes().at(blend_mode_idx); m_hmd->set_environment_blend_mode(b); m_render_transparency_as_checkerboard = (b == EnvironmentBlendMode::Opaque); @@ -2112,7 +2112,7 @@ void Testbed::SecondWindow::draw(GLuint texture) { glfwMakeContextCurrent(window); glfwGetFramebufferSize(window, &display_w, &display_h); glViewport(0, 0, display_w, display_h); - glClearColor(0.f,0.f,0.f, 1.f); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture);