mirror of
https://github.com/slendidev/lunar.git
synced 2026-01-30 16:28:58 +02:00
@@ -489,8 +489,8 @@ struct OpenXrState {
|
|||||||
|
|
||||||
Application::Application()
|
Application::Application()
|
||||||
{
|
{
|
||||||
auto const *display_env = getenv("DISPLAY");
|
auto const *display_env { getenv("DISPLAY") };
|
||||||
auto const *wayland_env = getenv("WAYLAND_DISPLAY");
|
auto const *wayland_env { getenv("WAYLAND_DISPLAY") };
|
||||||
bool const has_display
|
bool const has_display
|
||||||
= (display_env && *display_env) || (wayland_env && *wayland_env);
|
= (display_env && *display_env) || (wayland_env && *wayland_env);
|
||||||
m_backend = has_display ? Backend::SDL : Backend::KMS;
|
m_backend = has_display ? Backend::SDL : Backend::KMS;
|
||||||
@@ -578,7 +578,7 @@ auto Application::binary_directory() const -> std::filesystem::path
|
|||||||
return std::filesystem::current_path();
|
return std::filesystem::current_path();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const *base_path = SDL_GetBasePath();
|
auto const *base_path { SDL_GetBasePath() };
|
||||||
if (!base_path) {
|
if (!base_path) {
|
||||||
return std::filesystem::current_path();
|
return std::filesystem::current_path();
|
||||||
}
|
}
|
||||||
@@ -589,9 +589,9 @@ auto Application::asset_directory() -> std::filesystem::path
|
|||||||
{
|
{
|
||||||
std::vector<std::filesystem::path> candidates;
|
std::vector<std::filesystem::path> candidates;
|
||||||
|
|
||||||
auto add_xdg_path = [&](std::filesystem::path const &base) {
|
auto const add_xdg_path { [&](std::filesystem::path const &base) {
|
||||||
candidates.emplace_back(base / "lunar" / "assets");
|
candidates.emplace_back(base / "lunar" / "assets");
|
||||||
};
|
} };
|
||||||
|
|
||||||
if (auto const *xdg_data_home = getenv("XDG_DATA_HOME");
|
if (auto const *xdg_data_home = getenv("XDG_DATA_HOME");
|
||||||
xdg_data_home && *xdg_data_home) {
|
xdg_data_home && *xdg_data_home) {
|
||||||
@@ -618,7 +618,7 @@ auto Application::asset_directory() -> std::filesystem::path
|
|||||||
add_xdg_path("/usr/share");
|
add_xdg_path("/usr/share");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto base_dir { binary_directory() };
|
auto const base_dir { binary_directory() };
|
||||||
candidates.emplace_back(base_dir / "assets");
|
candidates.emplace_back(base_dir / "assets");
|
||||||
candidates.emplace_back(base_dir / "../assets");
|
candidates.emplace_back(base_dir / "../assets");
|
||||||
|
|
||||||
@@ -636,9 +636,9 @@ auto Application::asset_directory() -> std::filesystem::path
|
|||||||
|
|
||||||
auto Application::init_test_meshes() -> void
|
auto Application::init_test_meshes() -> void
|
||||||
{
|
{
|
||||||
auto assets_dir { asset_directory() };
|
auto const assets_dir { asset_directory() };
|
||||||
auto mesh_path { assets_dir / "basicmesh.glb" };
|
auto const mesh_path { assets_dir / "basicmesh.glb" };
|
||||||
auto meshes { Mesh::load_gltf_meshes(*m_renderer, mesh_path) };
|
auto const meshes { Mesh::load_gltf_meshes(*m_renderer, mesh_path) };
|
||||||
if (!meshes) {
|
if (!meshes) {
|
||||||
m_logger.err("Failed to load test mesh: {}", mesh_path.string());
|
m_logger.err("Failed to load test mesh: {}", mesh_path.string());
|
||||||
return;
|
return;
|
||||||
@@ -651,9 +651,9 @@ auto Application::run() -> void
|
|||||||
|
|
||||||
{
|
{
|
||||||
SDL_Event e;
|
SDL_Event e;
|
||||||
bool const use_sdl = (m_backend == Backend::SDL);
|
bool const use_sdl { (m_backend == Backend::SDL) };
|
||||||
bool const openxr_enabled = m_openxr != nullptr;
|
bool const openxr_enabled { m_openxr != nullptr };
|
||||||
bool const use_imgui = use_sdl && !openxr_enabled;
|
bool const use_imgui { use_sdl && !openxr_enabled };
|
||||||
|
|
||||||
if (use_imgui) {
|
if (use_imgui) {
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO &io = ImGui::GetIO();
|
||||||
@@ -1089,7 +1089,7 @@ auto Application::shutdown_input() -> void
|
|||||||
|
|
||||||
auto Application::init_openxr() -> void
|
auto Application::init_openxr() -> void
|
||||||
{
|
{
|
||||||
if (auto const *no_xr = getenv("LUNAR_NO_XR"); no_xr) {
|
if (auto const *no_xr = getenv("LUNAR_NO_XR"); no_xr && *no_xr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_openxr = std::make_unique<OpenXrState>();
|
m_openxr = std::make_unique<OpenXrState>();
|
||||||
@@ -1106,8 +1106,10 @@ auto Application::init_openxr() -> void
|
|||||||
create_info.applicationInfo.apiVersion = XR_CURRENT_API_VERSION;
|
create_info.applicationInfo.apiVersion = XR_CURRENT_API_VERSION;
|
||||||
|
|
||||||
uint32_t extension_count = 0;
|
uint32_t extension_count = 0;
|
||||||
auto extension_count_result = xrEnumerateInstanceExtensionProperties(
|
auto extension_count_result {
|
||||||
nullptr, 0, &extension_count, nullptr);
|
xrEnumerateInstanceExtensionProperties(
|
||||||
|
nullptr, 0, &extension_count, nullptr),
|
||||||
|
};
|
||||||
if (XR_FAILED(extension_count_result) || extension_count == 0) {
|
if (XR_FAILED(extension_count_result) || extension_count == 0) {
|
||||||
m_logger.warn("OpenXR instance extensions unavailable: {}",
|
m_logger.warn("OpenXR instance extensions unavailable: {}",
|
||||||
xr_result_to_string(XR_NULL_HANDLE, extension_count_result));
|
xr_result_to_string(XR_NULL_HANDLE, extension_count_result));
|
||||||
@@ -1121,8 +1123,10 @@ auto Application::init_openxr() -> void
|
|||||||
extension.type = XR_TYPE_EXTENSION_PROPERTIES;
|
extension.type = XR_TYPE_EXTENSION_PROPERTIES;
|
||||||
extension.next = nullptr;
|
extension.next = nullptr;
|
||||||
}
|
}
|
||||||
auto enumerate_result = xrEnumerateInstanceExtensionProperties(nullptr,
|
auto enumerate_result {
|
||||||
extension_count, &extension_count, available_extensions.data());
|
xrEnumerateInstanceExtensionProperties(nullptr, extension_count,
|
||||||
|
&extension_count, available_extensions.data()),
|
||||||
|
};
|
||||||
if (XR_FAILED(enumerate_result)) {
|
if (XR_FAILED(enumerate_result)) {
|
||||||
m_logger.warn("Failed to enumerate OpenXR extensions: {}",
|
m_logger.warn("Failed to enumerate OpenXR extensions: {}",
|
||||||
xr_result_to_string(XR_NULL_HANDLE, enumerate_result));
|
xr_result_to_string(XR_NULL_HANDLE, enumerate_result));
|
||||||
@@ -1130,15 +1134,16 @@ auto Application::init_openxr() -> void
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto has_extension = [&](char const *name) {
|
auto const has_extension { [&](char const *name) {
|
||||||
return std::any_of(available_extensions.begin(),
|
return std::any_of(available_extensions.begin(),
|
||||||
available_extensions.end(), [&](auto const &extension) {
|
available_extensions.end(), [&](auto const &extension) {
|
||||||
return std::strcmp(extension.extensionName, name) == 0;
|
return std::strcmp(extension.extensionName, name) == 0;
|
||||||
});
|
});
|
||||||
};
|
} };
|
||||||
|
|
||||||
bool const has_enable2
|
bool const has_enable2 {
|
||||||
= has_extension(XR_KHR_VULKAN_ENABLE2_EXTENSION_NAME);
|
has_extension(XR_KHR_VULKAN_ENABLE2_EXTENSION_NAME),
|
||||||
|
};
|
||||||
bool const has_enable1 = has_extension(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME);
|
bool const has_enable1 = has_extension(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME);
|
||||||
if (!has_enable2 && !has_enable1) {
|
if (!has_enable2 && !has_enable1) {
|
||||||
m_logger.warn("OpenXR Vulkan extensions missing");
|
m_logger.warn("OpenXR Vulkan extensions missing");
|
||||||
@@ -1155,8 +1160,9 @@ auto Application::init_openxr() -> void
|
|||||||
m_openxr->use_vulkan_enable2 = true;
|
m_openxr->use_vulkan_enable2 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool const has_hand_tracking
|
bool const has_hand_tracking {
|
||||||
= has_extension(XR_EXT_HAND_TRACKING_EXTENSION_NAME);
|
has_extension(XR_EXT_HAND_TRACKING_EXTENSION_NAME),
|
||||||
|
};
|
||||||
if (has_hand_tracking) {
|
if (has_hand_tracking) {
|
||||||
extensions.push_back(XR_EXT_HAND_TRACKING_EXTENSION_NAME);
|
extensions.push_back(XR_EXT_HAND_TRACKING_EXTENSION_NAME);
|
||||||
m_openxr->hand_tracking_supported = true;
|
m_openxr->hand_tracking_supported = true;
|
||||||
@@ -1166,8 +1172,9 @@ auto Application::init_openxr() -> void
|
|||||||
= static_cast<uint32_t>(extensions.size());
|
= static_cast<uint32_t>(extensions.size());
|
||||||
create_info.enabledExtensionNames = extensions.data();
|
create_info.enabledExtensionNames = extensions.data();
|
||||||
|
|
||||||
auto const instance_result
|
auto const instance_result {
|
||||||
= xrCreateInstance(&create_info, &m_openxr->instance);
|
xrCreateInstance(&create_info, &m_openxr->instance),
|
||||||
|
};
|
||||||
if (XR_FAILED(instance_result)) {
|
if (XR_FAILED(instance_result)) {
|
||||||
m_logger.info("OpenXR not available (no instance)");
|
m_logger.info("OpenXR not available (no instance)");
|
||||||
m_openxr.reset();
|
m_openxr.reset();
|
||||||
@@ -1178,8 +1185,9 @@ auto Application::init_openxr() -> void
|
|||||||
system_info.type = XR_TYPE_SYSTEM_GET_INFO;
|
system_info.type = XR_TYPE_SYSTEM_GET_INFO;
|
||||||
system_info.next = nullptr;
|
system_info.next = nullptr;
|
||||||
system_info.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
|
system_info.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
|
||||||
auto const system_result
|
auto const system_result {
|
||||||
= xrGetSystem(m_openxr->instance, &system_info, &m_openxr->system_id);
|
xrGetSystem(m_openxr->instance, &system_info, &m_openxr->system_id),
|
||||||
|
};
|
||||||
if (XR_FAILED(system_result)) {
|
if (XR_FAILED(system_result)) {
|
||||||
m_logger.info("OpenXR system not detected");
|
m_logger.info("OpenXR system not detected");
|
||||||
xrDestroyInstance(m_openxr->instance);
|
xrDestroyInstance(m_openxr->instance);
|
||||||
@@ -1188,9 +1196,11 @@ auto Application::init_openxr() -> void
|
|||||||
}
|
}
|
||||||
|
|
||||||
PFN_xrGetVulkanInstanceExtensionsKHR get_instance_exts {};
|
PFN_xrGetVulkanInstanceExtensionsKHR get_instance_exts {};
|
||||||
auto instance_ext_result = xrGetInstanceProcAddr(m_openxr->instance,
|
auto instance_ext_result {
|
||||||
|
xrGetInstanceProcAddr(m_openxr->instance,
|
||||||
"xrGetVulkanInstanceExtensionsKHR",
|
"xrGetVulkanInstanceExtensionsKHR",
|
||||||
reinterpret_cast<PFN_xrVoidFunction *>(&get_instance_exts));
|
reinterpret_cast<PFN_xrVoidFunction *>(&get_instance_exts)),
|
||||||
|
};
|
||||||
if (XR_FAILED(instance_ext_result) || !get_instance_exts) {
|
if (XR_FAILED(instance_ext_result) || !get_instance_exts) {
|
||||||
m_logger.warn("OpenXR missing Vulkan instance extensions (proc)");
|
m_logger.warn("OpenXR missing Vulkan instance extensions (proc)");
|
||||||
xrDestroyInstance(m_openxr->instance);
|
xrDestroyInstance(m_openxr->instance);
|
||||||
@@ -1199,9 +1209,11 @@ auto Application::init_openxr() -> void
|
|||||||
}
|
}
|
||||||
|
|
||||||
PFN_xrGetVulkanDeviceExtensionsKHR get_device_exts {};
|
PFN_xrGetVulkanDeviceExtensionsKHR get_device_exts {};
|
||||||
auto device_ext_result = xrGetInstanceProcAddr(m_openxr->instance,
|
auto device_ext_result {
|
||||||
|
xrGetInstanceProcAddr(m_openxr->instance,
|
||||||
"xrGetVulkanDeviceExtensionsKHR",
|
"xrGetVulkanDeviceExtensionsKHR",
|
||||||
reinterpret_cast<PFN_xrVoidFunction *>(&get_device_exts));
|
reinterpret_cast<PFN_xrVoidFunction *>(&get_device_exts)),
|
||||||
|
};
|
||||||
if (XR_FAILED(device_ext_result) || !get_device_exts) {
|
if (XR_FAILED(device_ext_result) || !get_device_exts) {
|
||||||
m_logger.warn("OpenXR missing Vulkan device extensions");
|
m_logger.warn("OpenXR missing Vulkan device extensions");
|
||||||
xrDestroyInstance(m_openxr->instance);
|
xrDestroyInstance(m_openxr->instance);
|
||||||
@@ -1231,7 +1243,7 @@ auto Application::init_openxr() -> void
|
|||||||
m_openxr->instance_extensions = split_extension_list(
|
m_openxr->instance_extensions = split_extension_list(
|
||||||
std::string_view { instance_ext_string.c_str() });
|
std::string_view { instance_ext_string.c_str() });
|
||||||
|
|
||||||
uint32_t device_ext_size = 0;
|
uint32_t device_ext_size { 0 };
|
||||||
device_ext_result = get_device_exts(
|
device_ext_result = get_device_exts(
|
||||||
m_openxr->instance, m_openxr->system_id, 0, &device_ext_size, nullptr);
|
m_openxr->instance, m_openxr->system_id, 0, &device_ext_size, nullptr);
|
||||||
if (XR_FAILED(device_ext_result) || device_ext_size == 0) {
|
if (XR_FAILED(device_ext_result) || device_ext_size == 0) {
|
||||||
@@ -1254,39 +1266,47 @@ auto Application::init_openxr() -> void
|
|||||||
m_openxr->enabled = true;
|
m_openxr->enabled = true;
|
||||||
|
|
||||||
if (m_openxr->use_vulkan_enable2) {
|
if (m_openxr->use_vulkan_enable2) {
|
||||||
auto graphics_device_result = xrGetInstanceProcAddr(m_openxr->instance,
|
auto const graphics_device_result {
|
||||||
|
xrGetInstanceProcAddr(m_openxr->instance,
|
||||||
"xrGetVulkanGraphicsDevice2KHR",
|
"xrGetVulkanGraphicsDevice2KHR",
|
||||||
reinterpret_cast<PFN_xrVoidFunction *>(
|
reinterpret_cast<PFN_xrVoidFunction *>(
|
||||||
&m_openxr->get_graphics_device2));
|
&m_openxr->get_graphics_device2)),
|
||||||
|
};
|
||||||
if (XR_FAILED(graphics_device_result)
|
if (XR_FAILED(graphics_device_result)
|
||||||
|| !m_openxr->get_graphics_device2) {
|
|| !m_openxr->get_graphics_device2) {
|
||||||
m_logger.warn("OpenXR missing Vulkan graphics device hook");
|
m_logger.warn("OpenXR missing Vulkan graphics device hook");
|
||||||
m_openxr->get_graphics_device2 = nullptr;
|
m_openxr->get_graphics_device2 = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto requirements_result = xrGetInstanceProcAddr(m_openxr->instance,
|
auto const requirements_result {
|
||||||
|
xrGetInstanceProcAddr(m_openxr->instance,
|
||||||
"xrGetVulkanGraphicsRequirements2KHR",
|
"xrGetVulkanGraphicsRequirements2KHR",
|
||||||
reinterpret_cast<PFN_xrVoidFunction *>(
|
reinterpret_cast<PFN_xrVoidFunction *>(
|
||||||
&m_openxr->get_requirements2));
|
&m_openxr->get_requirements2)),
|
||||||
|
};
|
||||||
if (XR_FAILED(requirements_result) || !m_openxr->get_requirements2) {
|
if (XR_FAILED(requirements_result) || !m_openxr->get_requirements2) {
|
||||||
m_logger.warn("OpenXR missing Vulkan requirements hook");
|
m_logger.warn("OpenXR missing Vulkan requirements hook");
|
||||||
m_openxr->get_requirements2 = nullptr;
|
m_openxr->get_requirements2 = nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto graphics_device_result = xrGetInstanceProcAddr(m_openxr->instance,
|
auto const graphics_device_result {
|
||||||
|
xrGetInstanceProcAddr(m_openxr->instance,
|
||||||
"xrGetVulkanGraphicsDeviceKHR",
|
"xrGetVulkanGraphicsDeviceKHR",
|
||||||
reinterpret_cast<PFN_xrVoidFunction *>(
|
reinterpret_cast<PFN_xrVoidFunction *>(
|
||||||
&m_openxr->get_graphics_device));
|
&m_openxr->get_graphics_device)),
|
||||||
|
};
|
||||||
if (XR_FAILED(graphics_device_result)
|
if (XR_FAILED(graphics_device_result)
|
||||||
|| !m_openxr->get_graphics_device) {
|
|| !m_openxr->get_graphics_device) {
|
||||||
m_logger.warn("OpenXR missing Vulkan graphics device hook");
|
m_logger.warn("OpenXR missing Vulkan graphics device hook");
|
||||||
m_openxr->get_graphics_device = nullptr;
|
m_openxr->get_graphics_device = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto requirements_result = xrGetInstanceProcAddr(m_openxr->instance,
|
auto const requirements_result {
|
||||||
|
xrGetInstanceProcAddr(m_openxr->instance,
|
||||||
"xrGetVulkanGraphicsRequirementsKHR",
|
"xrGetVulkanGraphicsRequirementsKHR",
|
||||||
reinterpret_cast<PFN_xrVoidFunction *>(
|
reinterpret_cast<PFN_xrVoidFunction *>(
|
||||||
&m_openxr->get_requirements));
|
&m_openxr->get_requirements)),
|
||||||
|
};
|
||||||
if (XR_FAILED(requirements_result) || !m_openxr->get_requirements) {
|
if (XR_FAILED(requirements_result) || !m_openxr->get_requirements) {
|
||||||
m_logger.warn("OpenXR missing Vulkan requirements hook");
|
m_logger.warn("OpenXR missing Vulkan requirements hook");
|
||||||
m_openxr->get_requirements = nullptr;
|
m_openxr->get_requirements = nullptr;
|
||||||
@@ -1294,28 +1314,31 @@ auto Application::init_openxr() -> void
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_openxr->hand_tracking_supported) {
|
if (m_openxr->hand_tracking_supported) {
|
||||||
auto create_result = xrGetInstanceProcAddr(m_openxr->instance,
|
auto const create_result {
|
||||||
"xrCreateHandTrackerEXT",
|
xrGetInstanceProcAddr(m_openxr->instance, "xrCreateHandTrackerEXT",
|
||||||
reinterpret_cast<PFN_xrVoidFunction *>(
|
reinterpret_cast<PFN_xrVoidFunction *>(
|
||||||
&m_openxr->create_hand_tracker));
|
&m_openxr->create_hand_tracker)),
|
||||||
|
};
|
||||||
if (XR_FAILED(create_result) || !m_openxr->create_hand_tracker) {
|
if (XR_FAILED(create_result) || !m_openxr->create_hand_tracker) {
|
||||||
m_logger.warn("OpenXR hand tracking create function unavailable");
|
m_logger.warn("OpenXR hand tracking create function unavailable");
|
||||||
m_openxr->hand_tracking_supported = false;
|
m_openxr->hand_tracking_supported = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto destroy_result = xrGetInstanceProcAddr(m_openxr->instance,
|
auto const destroy_result {
|
||||||
"xrDestroyHandTrackerEXT",
|
xrGetInstanceProcAddr(m_openxr->instance, "xrDestroyHandTrackerEXT",
|
||||||
reinterpret_cast<PFN_xrVoidFunction *>(
|
reinterpret_cast<PFN_xrVoidFunction *>(
|
||||||
&m_openxr->destroy_hand_tracker));
|
&m_openxr->destroy_hand_tracker)),
|
||||||
|
};
|
||||||
if (XR_FAILED(destroy_result) || !m_openxr->destroy_hand_tracker) {
|
if (XR_FAILED(destroy_result) || !m_openxr->destroy_hand_tracker) {
|
||||||
m_logger.warn("OpenXR hand tracking destroy function unavailable");
|
m_logger.warn("OpenXR hand tracking destroy function unavailable");
|
||||||
m_openxr->hand_tracking_supported = false;
|
m_openxr->hand_tracking_supported = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto locate_result
|
auto const locate_result {
|
||||||
= xrGetInstanceProcAddr(m_openxr->instance, "xrLocateHandJointsEXT",
|
xrGetInstanceProcAddr(m_openxr->instance, "xrLocateHandJointsEXT",
|
||||||
reinterpret_cast<PFN_xrVoidFunction *>(
|
reinterpret_cast<PFN_xrVoidFunction *>(
|
||||||
&m_openxr->locate_hand_joints));
|
&m_openxr->locate_hand_joints)),
|
||||||
|
};
|
||||||
if (XR_FAILED(locate_result) || !m_openxr->locate_hand_joints) {
|
if (XR_FAILED(locate_result) || !m_openxr->locate_hand_joints) {
|
||||||
m_logger.warn("OpenXR hand tracking locate function unavailable");
|
m_logger.warn("OpenXR hand tracking locate function unavailable");
|
||||||
m_openxr->hand_tracking_supported = false;
|
m_openxr->hand_tracking_supported = false;
|
||||||
@@ -1345,8 +1368,10 @@ auto Application::init_openxr_session() -> void
|
|||||||
XrGraphicsRequirementsVulkan2KHR requirements {};
|
XrGraphicsRequirementsVulkan2KHR requirements {};
|
||||||
requirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN2_KHR;
|
requirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN2_KHR;
|
||||||
requirements.next = nullptr;
|
requirements.next = nullptr;
|
||||||
auto const requirements_result = m_openxr->get_requirements2(
|
auto const requirements_result {
|
||||||
m_openxr->instance, m_openxr->system_id, &requirements);
|
m_openxr->get_requirements2(
|
||||||
|
m_openxr->instance, m_openxr->system_id, &requirements),
|
||||||
|
};
|
||||||
if (XR_FAILED(requirements_result)) {
|
if (XR_FAILED(requirements_result)) {
|
||||||
m_logger.warn("OpenXR Vulkan requirements failed: {}",
|
m_logger.warn("OpenXR Vulkan requirements failed: {}",
|
||||||
xr_result_to_string(m_openxr->instance, requirements_result));
|
xr_result_to_string(m_openxr->instance, requirements_result));
|
||||||
@@ -1360,8 +1385,10 @@ auto Application::init_openxr_session() -> void
|
|||||||
device_info.systemId = m_openxr->system_id;
|
device_info.systemId = m_openxr->system_id;
|
||||||
device_info.vulkanInstance
|
device_info.vulkanInstance
|
||||||
= static_cast<VkInstance>(m_renderer->instance());
|
= static_cast<VkInstance>(m_renderer->instance());
|
||||||
auto const phys_result = m_openxr->get_graphics_device2(
|
auto const phys_result {
|
||||||
m_openxr->instance, &device_info, &xr_physical_device);
|
m_openxr->get_graphics_device2(
|
||||||
|
m_openxr->instance, &device_info, &xr_physical_device),
|
||||||
|
};
|
||||||
if (XR_FAILED(phys_result)) {
|
if (XR_FAILED(phys_result)) {
|
||||||
m_logger.warn("Failed to fetch OpenXR Vulkan device: {}",
|
m_logger.warn("Failed to fetch OpenXR Vulkan device: {}",
|
||||||
xr_result_to_string(m_openxr->instance, phys_result));
|
xr_result_to_string(m_openxr->instance, phys_result));
|
||||||
@@ -1388,8 +1415,10 @@ auto Application::init_openxr_session() -> void
|
|||||||
XrGraphicsRequirementsVulkanKHR requirements {};
|
XrGraphicsRequirementsVulkanKHR requirements {};
|
||||||
requirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR;
|
requirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR;
|
||||||
requirements.next = nullptr;
|
requirements.next = nullptr;
|
||||||
auto const requirements_result = m_openxr->get_requirements(
|
auto const requirements_result {
|
||||||
m_openxr->instance, m_openxr->system_id, &requirements);
|
m_openxr->get_requirements(
|
||||||
|
m_openxr->instance, m_openxr->system_id, &requirements),
|
||||||
|
};
|
||||||
if (XR_FAILED(requirements_result)) {
|
if (XR_FAILED(requirements_result)) {
|
||||||
m_logger.warn("OpenXR Vulkan requirements failed: {}",
|
m_logger.warn("OpenXR Vulkan requirements failed: {}",
|
||||||
xr_result_to_string(m_openxr->instance, requirements_result));
|
xr_result_to_string(m_openxr->instance, requirements_result));
|
||||||
@@ -1397,10 +1426,12 @@ auto Application::init_openxr_session() -> void
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const phys_result = m_openxr->get_graphics_device(
|
auto const phys_result {
|
||||||
m_openxr->instance, m_openxr->system_id,
|
m_openxr->get_graphics_device(m_openxr->instance,
|
||||||
|
m_openxr->system_id,
|
||||||
static_cast<VkInstance>(m_renderer->instance()),
|
static_cast<VkInstance>(m_renderer->instance()),
|
||||||
&xr_physical_device);
|
&xr_physical_device),
|
||||||
|
};
|
||||||
if (XR_FAILED(phys_result)) {
|
if (XR_FAILED(phys_result)) {
|
||||||
m_logger.warn("Failed to fetch OpenXR Vulkan device: {}",
|
m_logger.warn("Failed to fetch OpenXR Vulkan device: {}",
|
||||||
xr_result_to_string(m_openxr->instance, phys_result));
|
xr_result_to_string(m_openxr->instance, phys_result));
|
||||||
@@ -1428,8 +1459,9 @@ auto Application::init_openxr_session() -> void
|
|||||||
session_info.type = XR_TYPE_SESSION_CREATE_INFO;
|
session_info.type = XR_TYPE_SESSION_CREATE_INFO;
|
||||||
session_info.next = binding_ptr;
|
session_info.next = binding_ptr;
|
||||||
session_info.systemId = m_openxr->system_id;
|
session_info.systemId = m_openxr->system_id;
|
||||||
auto const session_result = xrCreateSession(
|
auto const session_result {
|
||||||
m_openxr->instance, &session_info, &m_openxr->session);
|
xrCreateSession(m_openxr->instance, &session_info, &m_openxr->session),
|
||||||
|
};
|
||||||
if (XR_FAILED(session_result)) {
|
if (XR_FAILED(session_result)) {
|
||||||
m_logger.warn("Failed to create OpenXR session: {}",
|
m_logger.warn("Failed to create OpenXR session: {}",
|
||||||
xr_result_to_string(m_openxr->instance, session_result));
|
xr_result_to_string(m_openxr->instance, session_result));
|
||||||
@@ -1442,8 +1474,10 @@ auto Application::init_openxr_session() -> void
|
|||||||
space_info.next = nullptr;
|
space_info.next = nullptr;
|
||||||
space_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL;
|
space_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL;
|
||||||
space_info.poseInReferenceSpace.orientation.w = 1.0f;
|
space_info.poseInReferenceSpace.orientation.w = 1.0f;
|
||||||
auto const space_result = xrCreateReferenceSpace(
|
auto const space_result {
|
||||||
m_openxr->session, &space_info, &m_openxr->app_space);
|
xrCreateReferenceSpace(
|
||||||
|
m_openxr->session, &space_info, &m_openxr->app_space),
|
||||||
|
};
|
||||||
if (XR_FAILED(space_result)) {
|
if (XR_FAILED(space_result)) {
|
||||||
m_logger.warn("Failed to create OpenXR space: {}",
|
m_logger.warn("Failed to create OpenXR space: {}",
|
||||||
xr_result_to_string(m_openxr->instance, space_result));
|
xr_result_to_string(m_openxr->instance, space_result));
|
||||||
@@ -1452,9 +1486,10 @@ auto Application::init_openxr_session() -> void
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t view_count = 0;
|
uint32_t view_count = 0;
|
||||||
auto const view_count_result
|
auto const view_count_result {
|
||||||
= xrEnumerateViewConfigurationViews(m_openxr->instance,
|
xrEnumerateViewConfigurationViews(m_openxr->instance,
|
||||||
m_openxr->system_id, m_openxr->view_type, 0, &view_count, nullptr);
|
m_openxr->system_id, m_openxr->view_type, 0, &view_count, nullptr),
|
||||||
|
};
|
||||||
if (XR_FAILED(view_count_result) || view_count == 0) {
|
if (XR_FAILED(view_count_result) || view_count == 0) {
|
||||||
m_logger.warn("OpenXR view configuration missing: {}",
|
m_logger.warn("OpenXR view configuration missing: {}",
|
||||||
xr_result_to_string(m_openxr->instance, view_count_result));
|
xr_result_to_string(m_openxr->instance, view_count_result));
|
||||||
@@ -1467,9 +1502,11 @@ auto Application::init_openxr_session() -> void
|
|||||||
config.type = XR_TYPE_VIEW_CONFIGURATION_VIEW;
|
config.type = XR_TYPE_VIEW_CONFIGURATION_VIEW;
|
||||||
config.next = nullptr;
|
config.next = nullptr;
|
||||||
}
|
}
|
||||||
auto const view_result = xrEnumerateViewConfigurationViews(
|
auto const view_result {
|
||||||
m_openxr->instance, m_openxr->system_id, m_openxr->view_type,
|
xrEnumerateViewConfigurationViews(m_openxr->instance,
|
||||||
view_count, &view_count, m_openxr->view_configs.data());
|
m_openxr->system_id, m_openxr->view_type, view_count, &view_count,
|
||||||
|
m_openxr->view_configs.data()),
|
||||||
|
};
|
||||||
if (XR_FAILED(view_result)) {
|
if (XR_FAILED(view_result)) {
|
||||||
m_logger.warn("Failed to enumerate OpenXR views: {}",
|
m_logger.warn("Failed to enumerate OpenXR views: {}",
|
||||||
xr_result_to_string(m_openxr->instance, view_result));
|
xr_result_to_string(m_openxr->instance, view_result));
|
||||||
@@ -1484,8 +1521,10 @@ auto Application::init_openxr_session() -> void
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t format_count = 0;
|
uint32_t format_count = 0;
|
||||||
auto const format_count_result = xrEnumerateSwapchainFormats(
|
auto const format_count_result {
|
||||||
m_openxr->session, 0, &format_count, nullptr);
|
xrEnumerateSwapchainFormats(
|
||||||
|
m_openxr->session, 0, &format_count, nullptr),
|
||||||
|
};
|
||||||
if (XR_FAILED(format_count_result) || format_count == 0) {
|
if (XR_FAILED(format_count_result) || format_count == 0) {
|
||||||
m_logger.warn("OpenXR swapchain formats unavailable: {}",
|
m_logger.warn("OpenXR swapchain formats unavailable: {}",
|
||||||
xr_result_to_string(m_openxr->instance, format_count_result));
|
xr_result_to_string(m_openxr->instance, format_count_result));
|
||||||
@@ -1493,8 +1532,10 @@ auto Application::init_openxr_session() -> void
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::vector<int64_t> formats(format_count);
|
std::vector<int64_t> formats(format_count);
|
||||||
auto const format_result = xrEnumerateSwapchainFormats(
|
auto const format_result {
|
||||||
m_openxr->session, format_count, &format_count, formats.data());
|
xrEnumerateSwapchainFormats(
|
||||||
|
m_openxr->session, format_count, &format_count, formats.data()),
|
||||||
|
};
|
||||||
if (XR_FAILED(format_result)) {
|
if (XR_FAILED(format_result)) {
|
||||||
m_logger.warn("Failed to enumerate OpenXR swapchain formats: {}",
|
m_logger.warn("Failed to enumerate OpenXR swapchain formats: {}",
|
||||||
xr_result_to_string(m_openxr->instance, format_result));
|
xr_result_to_string(m_openxr->instance, format_result));
|
||||||
@@ -1520,7 +1561,7 @@ auto Application::init_openxr_session() -> void
|
|||||||
m_openxr->swapchains.clear();
|
m_openxr->swapchains.clear();
|
||||||
m_openxr->swapchains.resize(view_count);
|
m_openxr->swapchains.resize(view_count);
|
||||||
for (uint32_t i = 0; i < view_count; ++i) {
|
for (uint32_t i = 0; i < view_count; ++i) {
|
||||||
auto const &view_config = m_openxr->view_configs[i];
|
auto const &view_config { m_openxr->view_configs[i] };
|
||||||
XrSwapchainCreateInfo swapchain_info {};
|
XrSwapchainCreateInfo swapchain_info {};
|
||||||
swapchain_info.type = XR_TYPE_SWAPCHAIN_CREATE_INFO;
|
swapchain_info.type = XR_TYPE_SWAPCHAIN_CREATE_INFO;
|
||||||
swapchain_info.next = nullptr;
|
swapchain_info.next = nullptr;
|
||||||
@@ -1535,8 +1576,10 @@ auto Application::init_openxr_session() -> void
|
|||||||
swapchain_info.arraySize = 1;
|
swapchain_info.arraySize = 1;
|
||||||
swapchain_info.mipCount = 1;
|
swapchain_info.mipCount = 1;
|
||||||
|
|
||||||
auto const swapchain_result = xrCreateSwapchain(m_openxr->session,
|
auto const swapchain_result {
|
||||||
&swapchain_info, &m_openxr->swapchains[i].handle);
|
xrCreateSwapchain(m_openxr->session, &swapchain_info,
|
||||||
|
&m_openxr->swapchains[i].handle),
|
||||||
|
};
|
||||||
if (XR_FAILED(swapchain_result)) {
|
if (XR_FAILED(swapchain_result)) {
|
||||||
m_logger.warn("Failed to create OpenXR swapchain: {}",
|
m_logger.warn("Failed to create OpenXR swapchain: {}",
|
||||||
xr_result_to_string(m_openxr->instance, swapchain_result));
|
xr_result_to_string(m_openxr->instance, swapchain_result));
|
||||||
@@ -1547,9 +1590,11 @@ auto Application::init_openxr_session() -> void
|
|||||||
m_openxr->swapchains[i].extent
|
m_openxr->swapchains[i].extent
|
||||||
= vk::Extent2D { swapchain_info.width, swapchain_info.height };
|
= vk::Extent2D { swapchain_info.width, swapchain_info.height };
|
||||||
|
|
||||||
uint32_t image_count = 0;
|
uint32_t image_count { 0 };
|
||||||
auto const image_count_result = xrEnumerateSwapchainImages(
|
auto const image_count_result {
|
||||||
m_openxr->swapchains[i].handle, 0, &image_count, nullptr);
|
xrEnumerateSwapchainImages(
|
||||||
|
m_openxr->swapchains[i].handle, 0, &image_count, nullptr),
|
||||||
|
};
|
||||||
if (XR_FAILED(image_count_result) || image_count == 0) {
|
if (XR_FAILED(image_count_result) || image_count == 0) {
|
||||||
m_logger.warn("Failed to enumerate OpenXR swapchain images: {}",
|
m_logger.warn("Failed to enumerate OpenXR swapchain images: {}",
|
||||||
xr_result_to_string(m_openxr->instance, image_count_result));
|
xr_result_to_string(m_openxr->instance, image_count_result));
|
||||||
@@ -1562,10 +1607,12 @@ auto Application::init_openxr_session() -> void
|
|||||||
image.type = XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR;
|
image.type = XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR;
|
||||||
image.next = nullptr;
|
image.next = nullptr;
|
||||||
}
|
}
|
||||||
auto const image_result = xrEnumerateSwapchainImages(
|
auto const image_result {
|
||||||
m_openxr->swapchains[i].handle, image_count, &image_count,
|
xrEnumerateSwapchainImages(m_openxr->swapchains[i].handle,
|
||||||
|
image_count, &image_count,
|
||||||
reinterpret_cast<XrSwapchainImageBaseHeader *>(
|
reinterpret_cast<XrSwapchainImageBaseHeader *>(
|
||||||
m_openxr->swapchains[i].images.data()));
|
m_openxr->swapchains[i].images.data())),
|
||||||
|
};
|
||||||
if (XR_FAILED(image_result)) {
|
if (XR_FAILED(image_result)) {
|
||||||
m_logger.warn("Failed to read OpenXR swapchain images: {}",
|
m_logger.warn("Failed to read OpenXR swapchain images: {}",
|
||||||
xr_result_to_string(m_openxr->instance, image_result));
|
xr_result_to_string(m_openxr->instance, image_result));
|
||||||
@@ -1584,8 +1631,8 @@ auto Application::init_openxr_session() -> void
|
|||||||
left_info.next = nullptr;
|
left_info.next = nullptr;
|
||||||
left_info.hand = XR_HAND_LEFT_EXT;
|
left_info.hand = XR_HAND_LEFT_EXT;
|
||||||
left_info.handJointSet = XR_HAND_JOINT_SET_DEFAULT_EXT;
|
left_info.handJointSet = XR_HAND_JOINT_SET_DEFAULT_EXT;
|
||||||
auto left_result = m_openxr->create_hand_tracker(
|
auto const left_result { m_openxr->create_hand_tracker(
|
||||||
m_openxr->session, &left_info, &m_openxr->left_hand_tracker);
|
m_openxr->session, &left_info, &m_openxr->left_hand_tracker) };
|
||||||
if (XR_FAILED(left_result)) {
|
if (XR_FAILED(left_result)) {
|
||||||
m_logger.warn("Failed to create left hand tracker");
|
m_logger.warn("Failed to create left hand tracker");
|
||||||
m_openxr->left_hand_tracker = XR_NULL_HANDLE;
|
m_openxr->left_hand_tracker = XR_NULL_HANDLE;
|
||||||
@@ -1596,8 +1643,8 @@ auto Application::init_openxr_session() -> void
|
|||||||
right_info.next = nullptr;
|
right_info.next = nullptr;
|
||||||
right_info.hand = XR_HAND_RIGHT_EXT;
|
right_info.hand = XR_HAND_RIGHT_EXT;
|
||||||
right_info.handJointSet = XR_HAND_JOINT_SET_DEFAULT_EXT;
|
right_info.handJointSet = XR_HAND_JOINT_SET_DEFAULT_EXT;
|
||||||
auto right_result = m_openxr->create_hand_tracker(
|
auto const right_result { m_openxr->create_hand_tracker(
|
||||||
m_openxr->session, &right_info, &m_openxr->right_hand_tracker);
|
m_openxr->session, &right_info, &m_openxr->right_hand_tracker) };
|
||||||
if (XR_FAILED(right_result)) {
|
if (XR_FAILED(right_result)) {
|
||||||
m_logger.warn("Failed to create right hand tracker");
|
m_logger.warn("Failed to create right hand tracker");
|
||||||
m_openxr->right_hand_tracker = XR_NULL_HANDLE;
|
m_openxr->right_hand_tracker = XR_NULL_HANDLE;
|
||||||
@@ -1663,9 +1710,10 @@ auto Application::poll_openxr_events() -> void
|
|||||||
while (xrPollEvent(m_openxr->instance, &event) == XR_SUCCESS) {
|
while (xrPollEvent(m_openxr->instance, &event) == XR_SUCCESS) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED: {
|
case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED: {
|
||||||
auto const &state_event
|
auto const &state_event {
|
||||||
= *reinterpret_cast<XrEventDataSessionStateChanged const *>(
|
*reinterpret_cast<XrEventDataSessionStateChanged const *>(
|
||||||
&event);
|
&event)
|
||||||
|
};
|
||||||
m_openxr->session_state = state_event.state;
|
m_openxr->session_state = state_event.state;
|
||||||
if (state_event.state == XR_SESSION_STATE_READY
|
if (state_event.state == XR_SESSION_STATE_READY
|
||||||
&& !m_openxr->session_running) {
|
&& !m_openxr->session_running) {
|
||||||
@@ -1743,7 +1791,7 @@ auto Application::render_openxr_frame(
|
|||||||
XrViewState view_state {};
|
XrViewState view_state {};
|
||||||
view_state.type = XR_TYPE_VIEW_STATE;
|
view_state.type = XR_TYPE_VIEW_STATE;
|
||||||
view_state.next = nullptr;
|
view_state.next = nullptr;
|
||||||
uint32_t view_count = static_cast<uint32_t>(m_openxr->views.size());
|
auto view_count { static_cast<uint32_t>(m_openxr->views.size()) };
|
||||||
view_count = std::min(
|
view_count = std::min(
|
||||||
view_count, static_cast<uint32_t>(m_openxr->swapchains.size()));
|
view_count, static_cast<uint32_t>(m_openxr->swapchains.size()));
|
||||||
if (XR_FAILED(xrLocateViews(m_openxr->session, &locate_info, &view_state,
|
if (XR_FAILED(xrLocateViews(m_openxr->session, &locate_info, &view_state,
|
||||||
@@ -1760,8 +1808,8 @@ auto Application::render_openxr_frame(
|
|||||||
projection_view.next = nullptr;
|
projection_view.next = nullptr;
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < view_count; ++i) {
|
for (uint32_t i = 0; i < view_count; ++i) {
|
||||||
auto &swapchain = m_openxr->swapchains[i];
|
auto const &swapchain { m_openxr->swapchains[i] };
|
||||||
uint32_t image_index = 0;
|
uint32_t image_index { 0 };
|
||||||
XrSwapchainImageAcquireInfo acquire_info {};
|
XrSwapchainImageAcquireInfo acquire_info {};
|
||||||
acquire_info.type = XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO;
|
acquire_info.type = XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO;
|
||||||
acquire_info.next = nullptr;
|
acquire_info.next = nullptr;
|
||||||
@@ -1806,8 +1854,9 @@ auto Application::render_openxr_frame(
|
|||||||
layer.viewCount = view_count;
|
layer.viewCount = view_count;
|
||||||
layer.views = projection_views.data();
|
layer.views = projection_views.data();
|
||||||
|
|
||||||
XrCompositionLayerBaseHeader const *layers[]
|
XrCompositionLayerBaseHeader const *layers[] {
|
||||||
= { reinterpret_cast<XrCompositionLayerBaseHeader *>(&layer) };
|
reinterpret_cast<XrCompositionLayerBaseHeader *>(&layer)
|
||||||
|
};
|
||||||
XrFrameEndInfo end_info {};
|
XrFrameEndInfo end_info {};
|
||||||
end_info.type = XR_TYPE_FRAME_END_INFO;
|
end_info.type = XR_TYPE_FRAME_END_INFO;
|
||||||
end_info.next = nullptr;
|
end_info.next = nullptr;
|
||||||
@@ -1820,12 +1869,13 @@ auto Application::render_openxr_frame(
|
|||||||
|
|
||||||
auto Application::update_camera_from_xr_view(XrView const &view) -> void
|
auto Application::update_camera_from_xr_view(XrView const &view) -> void
|
||||||
{
|
{
|
||||||
auto const &pose = view.pose;
|
auto const &pose { view.pose };
|
||||||
smath::Vec3 position { pose.position.x, pose.position.y, pose.position.z };
|
smath::Vec3 const position { pose.position.x, pose.position.y,
|
||||||
auto forward
|
pose.position.z };
|
||||||
= xr_rotate_vector(pose.orientation, smath::Vec3 { 0.0f, 0.0f, -1.0f });
|
auto const forward { xr_rotate_vector(
|
||||||
auto up
|
pose.orientation, smath::Vec3 { 0.0f, 0.0f, -1.0f }) };
|
||||||
= xr_rotate_vector(pose.orientation, smath::Vec3 { 0.0f, 1.0f, 0.0f });
|
auto const up { xr_rotate_vector(
|
||||||
|
pose.orientation, smath::Vec3 { 0.0f, 1.0f, 0.0f }) };
|
||||||
m_camera.position = position;
|
m_camera.position = position;
|
||||||
m_camera.target = position + forward;
|
m_camera.target = position + forward;
|
||||||
m_camera.up = up;
|
m_camera.up = up;
|
||||||
@@ -1862,7 +1912,7 @@ auto Application::update_hands(XrTime display_time) -> void
|
|||||||
& XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
& XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||||
!= 0;
|
!= 0;
|
||||||
if (m_left_hand_valid) {
|
if (m_left_hand_valid) {
|
||||||
for (uint32_t j = 0; j < XR_HAND_JOINT_COUNT_EXT; j++) {
|
for (uint32_t j { 0 }; j < XR_HAND_JOINT_COUNT_EXT; j++) {
|
||||||
m_left_joints[j]
|
m_left_joints[j]
|
||||||
= smath::Vec3 { locations[j].pose.position.x,
|
= smath::Vec3 { locations[j].pose.position.x,
|
||||||
locations[j].pose.position.y,
|
locations[j].pose.position.y,
|
||||||
@@ -1895,7 +1945,7 @@ auto Application::update_hands(XrTime display_time) -> void
|
|||||||
& XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
& XR_SPACE_LOCATION_POSITION_VALID_BIT)
|
||||||
!= 0;
|
!= 0;
|
||||||
if (m_right_hand_valid) {
|
if (m_right_hand_valid) {
|
||||||
for (uint32_t j = 0; j < XR_HAND_JOINT_COUNT_EXT; j++) {
|
for (uint32_t j { 0 }; j < XR_HAND_JOINT_COUNT_EXT; j++) {
|
||||||
m_right_joints[j]
|
m_right_joints[j]
|
||||||
= smath::Vec3 { locations[j].pose.position.x,
|
= smath::Vec3 { locations[j].pose.position.x,
|
||||||
locations[j].pose.position.y,
|
locations[j].pose.position.y,
|
||||||
@@ -1912,11 +1962,11 @@ auto Application::render_hands(
|
|||||||
VulkanRenderer::GL &gl, smath::Mat4 const &view_projection) -> void
|
VulkanRenderer::GL &gl, smath::Mat4 const &view_projection) -> void
|
||||||
{
|
{
|
||||||
gl.set_texture(&m_renderer->white_texture());
|
gl.set_texture(&m_renderer->white_texture());
|
||||||
float const radius = 0.005f;
|
auto constexpr radius { 0.005f };
|
||||||
|
|
||||||
if (m_left_hand_valid) {
|
if (m_left_hand_valid) {
|
||||||
for (uint32_t j = 0; j < XR_HAND_JOINT_COUNT_EXT; j++) {
|
for (uint32_t j { 0 }; j < XR_HAND_JOINT_COUNT_EXT; j++) {
|
||||||
smath::Vec3 const &pos = m_left_joints[j];
|
auto const &pos { m_left_joints[j] };
|
||||||
gl.set_transform(view_projection * smath::translate(pos));
|
gl.set_transform(view_projection * smath::translate(pos));
|
||||||
gl.draw_sphere(smath::Vec3 { 0.0f, 0.0f, 0.0f }, radius, 8, 16,
|
gl.draw_sphere(smath::Vec3 { 0.0f, 0.0f, 0.0f }, radius, 8, 16,
|
||||||
smath::Vec4 { 1.0f, 0.0f, 0.0f, 1.0f });
|
smath::Vec4 { 1.0f, 0.0f, 0.0f, 1.0f });
|
||||||
@@ -1924,8 +1974,8 @@ auto Application::render_hands(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_right_hand_valid) {
|
if (m_right_hand_valid) {
|
||||||
for (uint32_t j = 0; j < XR_HAND_JOINT_COUNT_EXT; j++) {
|
for (uint32_t j { 0 }; j < XR_HAND_JOINT_COUNT_EXT; j++) {
|
||||||
smath::Vec3 const &pos = m_right_joints[j];
|
auto const &pos { m_right_joints[j] };
|
||||||
gl.set_transform(view_projection * smath::translate(pos));
|
gl.set_transform(view_projection * smath::translate(pos));
|
||||||
gl.draw_sphere(smath::Vec3 { 0.0f, 0.0f, 0.0f }, radius, 8, 16,
|
gl.draw_sphere(smath::Vec3 { 0.0f, 0.0f, 0.0f }, radius, 8, 16,
|
||||||
smath::Vec4 { 1.0f, 0.0f, 0.0f, 1.0f });
|
smath::Vec4 { 1.0f, 0.0f, 0.0f, 1.0f });
|
||||||
|
|||||||
Reference in New Issue
Block a user