Add the logo in the about page
This commit is contained in:
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 73 KiB |
@@ -35,6 +35,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include "image_loader.h"
|
||||||
|
|
||||||
#include "../external/IconsFontAwesome6.h"
|
#include "../external/IconsFontAwesome6.h"
|
||||||
|
|
||||||
@@ -184,21 +185,34 @@ static const std::array pool_sizes =
|
|||||||
{
|
{
|
||||||
vk::DescriptorPoolSize{
|
vk::DescriptorPoolSize{
|
||||||
.type = vk::DescriptorType::eCombinedImageSampler,
|
.type = vk::DescriptorType::eCombinedImageSampler,
|
||||||
.descriptorCount = 1,
|
.descriptorCount = 100,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
imgui_context::imgui_context(vk::raii::Device& device, uint32_t queue_family_index, vk::raii::Queue& queue, XrSpace world, std::span<controller> controllers_, xr::swapchain& swapchain, glm::vec2 size) :
|
static const vk::DescriptorSetLayoutBinding layout_bindings{
|
||||||
|
.binding = 0,
|
||||||
|
.descriptorType = vk::DescriptorType::eCombinedImageSampler,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.stageFlags = vk::ShaderStageFlagBits::eFragment
|
||||||
|
};
|
||||||
|
|
||||||
|
imgui_context::imgui_context(vk::raii::PhysicalDevice physical_device, vk::raii::Device& device, uint32_t queue_family_index, vk::raii::Queue& queue, XrSpace world, std::span<controller> controllers_, xr::swapchain& swapchain, glm::vec2 size) :
|
||||||
|
physical_device(physical_device),
|
||||||
device(device),
|
device(device),
|
||||||
queue_family_index(queue_family_index),
|
queue_family_index(queue_family_index),
|
||||||
queue(queue),
|
queue(queue),
|
||||||
descriptor_pool(device, vk::DescriptorPoolCreateInfo
|
descriptor_pool(device, vk::DescriptorPoolCreateInfo
|
||||||
{
|
{
|
||||||
.flags = vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet,
|
.flags = vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet,
|
||||||
.maxSets = 1,
|
.maxSets = pool_sizes[0].descriptorCount,
|
||||||
.poolSizeCount = pool_sizes.size(),
|
.poolSizeCount = pool_sizes.size(),
|
||||||
.pPoolSizes = pool_sizes.data(),
|
.pPoolSizes = pool_sizes.data(),
|
||||||
}),
|
}),
|
||||||
|
ds_layout(device, vk::DescriptorSetLayoutCreateInfo
|
||||||
|
{
|
||||||
|
.bindingCount = 1,
|
||||||
|
.pBindings = &layout_bindings
|
||||||
|
}),
|
||||||
renderpass(create_renderpass(device, swapchain.format(), true)),
|
renderpass(create_renderpass(device, swapchain.format(), true)),
|
||||||
command_pool(device, vk::CommandPoolCreateInfo{
|
command_pool(device, vk::CommandPoolCreateInfo{
|
||||||
.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer | vk::CommandPoolCreateFlagBits::eTransient,
|
.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer | vk::CommandPoolCreateFlagBits::eTransient,
|
||||||
@@ -267,7 +281,7 @@ imgui_context::imgui_context(vk::raii::Device& device, uint32_t queue_family_ind
|
|||||||
{
|
{
|
||||||
ImFontConfig config;
|
ImFontConfig config;
|
||||||
config.FontDataOwnedByAtlas = false;
|
config.FontDataOwnedByAtlas = false;
|
||||||
large_font = io.Fonts->AddFontFromMemoryTTF(const_cast<std::byte*>(roboto.data()), roboto.size(), 45, &config);
|
large_font = io.Fonts->AddFontFromMemoryTTF(const_cast<std::byte*>(roboto.data()), roboto.size(), 75, &config);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,3 +517,58 @@ imgui_context::~imgui_context()
|
|||||||
ImGui_ImplVulkan_Shutdown();
|
ImGui_ImplVulkan_Shutdown();
|
||||||
ImGui::DestroyContext(context);
|
ImGui::DestroyContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ImTextureID imgui_context::load_texture(const std::string& filename, vk::raii::Sampler&& sampler)
|
||||||
|
{
|
||||||
|
bool srgb = true;
|
||||||
|
image_loader loader(physical_device, device, queue, command_pool);
|
||||||
|
loader.load(asset{filename}, srgb);
|
||||||
|
|
||||||
|
vk::raii::DescriptorSet ds = std::move(device.allocateDescriptorSets({
|
||||||
|
.descriptorPool = *descriptor_pool,
|
||||||
|
.descriptorSetCount = 1,
|
||||||
|
.pSetLayouts = &*ds_layout
|
||||||
|
})[0]);
|
||||||
|
|
||||||
|
vk::DescriptorImageInfo image_info{
|
||||||
|
.sampler = *sampler,
|
||||||
|
.imageView = *loader.image_view,
|
||||||
|
.imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal,
|
||||||
|
};
|
||||||
|
|
||||||
|
vk::WriteDescriptorSet ds_write{
|
||||||
|
.dstSet = *ds,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.descriptorType = vk::DescriptorType::eCombinedImageSampler,
|
||||||
|
.pImageInfo = &image_info
|
||||||
|
};
|
||||||
|
|
||||||
|
device.updateDescriptorSets(ds_write, nullptr);
|
||||||
|
|
||||||
|
ImTextureID id = ds.release();
|
||||||
|
|
||||||
|
textures.emplace(id, texture_data{
|
||||||
|
.sampler = std::move(sampler),
|
||||||
|
.image = std::move(loader.image),
|
||||||
|
.image_view = std::move(loader.image_view)
|
||||||
|
});
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImTextureID imgui_context::load_texture(const std::string& filename)
|
||||||
|
{
|
||||||
|
return load_texture(filename, vk::raii::Sampler(device, vk::SamplerCreateInfo{
|
||||||
|
.magFilter = vk::Filter::eLinear,
|
||||||
|
.minFilter = vk::Filter::eLinear,
|
||||||
|
.mipmapMode = vk::SamplerMipmapMode::eLinear,
|
||||||
|
.borderColor = vk::BorderColor::eFloatTransparentBlack,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void imgui_context::free_texture(ImTextureID texture)
|
||||||
|
{
|
||||||
|
textures.erase(texture);
|
||||||
|
// TODO free descriptor set
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
class imgui_context
|
class imgui_context
|
||||||
{
|
{
|
||||||
@@ -37,6 +38,13 @@ class imgui_context
|
|||||||
vk::raii::Fence fence = nullptr;
|
vk::raii::Fence fence = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct texture_data
|
||||||
|
{
|
||||||
|
vk::raii::Sampler sampler;
|
||||||
|
std::shared_ptr<vk::Image> image;
|
||||||
|
vk::raii::ImageView image_view;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct imgui_frame
|
struct imgui_frame
|
||||||
{
|
{
|
||||||
@@ -45,7 +53,6 @@ public:
|
|||||||
vk::raii::Framebuffer framebuffer = nullptr;
|
vk::raii::Framebuffer framebuffer = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct controller
|
struct controller
|
||||||
{
|
{
|
||||||
XrSpace aim;
|
XrSpace aim;
|
||||||
@@ -72,15 +79,19 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
vk::raii::PhysicalDevice physical_device;
|
||||||
vk::raii::Device& device;
|
vk::raii::Device& device;
|
||||||
uint32_t queue_family_index;
|
uint32_t queue_family_index;
|
||||||
vk::raii::Queue& queue;
|
vk::raii::Queue& queue;
|
||||||
|
|
||||||
vk::raii::Pipeline pipeline = nullptr;
|
vk::raii::Pipeline pipeline = nullptr;
|
||||||
vk::raii::DescriptorPool descriptor_pool;
|
vk::raii::DescriptorPool descriptor_pool;
|
||||||
|
vk::raii::DescriptorSetLayout ds_layout;
|
||||||
vk::raii::RenderPass renderpass;
|
vk::raii::RenderPass renderpass;
|
||||||
vk::raii::CommandPool command_pool;
|
vk::raii::CommandPool command_pool;
|
||||||
|
|
||||||
|
std::unordered_map<ImTextureID, texture_data> textures;
|
||||||
|
|
||||||
std::vector<imgui_frame> frames;
|
std::vector<imgui_frame> frames;
|
||||||
imgui_frame& get_frame(vk::Image destination);
|
imgui_frame& get_frame(vk::Image destination);
|
||||||
|
|
||||||
@@ -114,7 +125,7 @@ private:
|
|||||||
std::optional<ImVec2> ray_plane_intersection(const imgui_context::controller_state& in);
|
std::optional<ImVec2> ray_plane_intersection(const imgui_context::controller_state& in);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
imgui_context(vk::raii::Device& device, uint32_t queue_family_index, vk::raii::Queue& queue, XrSpace world, std::span<controller> controllers, xr::swapchain& swapchain, glm::vec2 size);
|
imgui_context(vk::raii::PhysicalDevice physical_device, vk::raii::Device& device, uint32_t queue_family_index, vk::raii::Queue& queue, XrSpace world, std::span<controller> controllers, xr::swapchain& swapchain, glm::vec2 size);
|
||||||
~imgui_context();
|
~imgui_context();
|
||||||
|
|
||||||
void set_position(glm::vec3 position, glm::quat orientation)
|
void set_position(glm::vec3 position, glm::quat orientation)
|
||||||
@@ -192,4 +203,8 @@ public:
|
|||||||
{
|
{
|
||||||
return focused_controller;
|
return focused_controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImTextureID load_texture(const std::string& filename, vk::raii::Sampler&& sampler);
|
||||||
|
ImTextureID load_texture(const std::string& filename);
|
||||||
|
void free_texture(ImTextureID);
|
||||||
};
|
};
|
||||||
|
|||||||
+11
-1
@@ -631,7 +631,16 @@ void scenes::lobby::on_focused()
|
|||||||
};
|
};
|
||||||
|
|
||||||
swapchain_imgui = xr::swapchain(session, device, swapchain_format, 1500, 1000);
|
swapchain_imgui = xr::swapchain(session, device, swapchain_format, 1500, 1000);
|
||||||
imgui_ctx.emplace(device, queue_family_index, queue, world_space, imgui_inputs, swapchain_imgui, glm::vec2{1.0, 0.6666});
|
imgui_ctx.emplace(physical_device, device, queue_family_index, queue, world_space, imgui_inputs, swapchain_imgui, glm::vec2{1.0, 0.6666});
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
about_picture = imgui_ctx->load_texture("wivrn.ktx2");
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
about_picture = imgui_ctx->load_texture("wivrn.png");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scenes::lobby::on_unfocused()
|
void scenes::lobby::on_unfocused()
|
||||||
@@ -640,6 +649,7 @@ void scenes::lobby::on_unfocused()
|
|||||||
|
|
||||||
renderer->wait_idle(); // Must be before the scene data because the renderer uses its descriptor sets
|
renderer->wait_idle(); // Must be before the scene data because the renderer uses its descriptor sets
|
||||||
|
|
||||||
|
about_picture = nullptr;
|
||||||
imgui_ctx.reset();
|
imgui_ctx.reset();
|
||||||
lobby_scene.reset(); // Must be reset before the renderer so that the descriptor sets are freed before their pools
|
lobby_scene.reset(); // Must be reset before the renderer so that the descriptor sets are freed before their pools
|
||||||
controllers_scene.reset();
|
controllers_scene.reset();
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class lobby : public scene_impl<lobby>
|
|||||||
|
|
||||||
tab current_tab = tab::server_list;
|
tab current_tab = tab::server_list;
|
||||||
tab last_current_tab = tab::server_list;
|
tab last_current_tab = tab::server_list;
|
||||||
|
ImTextureID about_picture;
|
||||||
|
|
||||||
void gui_connecting();
|
void gui_connecting();
|
||||||
void gui_server_list();
|
void gui_server_list();
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ void scenes::lobby::gui_server_list()
|
|||||||
// ImGui::SetTooltip("Tooltip");
|
// ImGui::SetTooltip("Tooltip");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
ImVec2 button_position(ImGui::GetWindowContentRegionMax().x + style.FramePadding.x, pos.y + (list_item_height - button_size.y) / 2);
|
ImVec2 button_position(ImGui::GetWindowContentRegionMax().x - style.WindowPadding.x - 20, pos.y + (list_item_height - button_size.y) / 2);
|
||||||
|
|
||||||
button_position.x -= button_size.x + style.WindowPadding.x;
|
button_position.x -= button_size.x + style.WindowPadding.x;
|
||||||
ImGui::SetCursorPos(button_position);
|
ImGui::SetCursorPos(button_position);
|
||||||
@@ -320,8 +320,15 @@ void scenes::lobby::gui_server_list()
|
|||||||
void scenes::lobby::gui_about()
|
void scenes::lobby::gui_about()
|
||||||
{
|
{
|
||||||
ImGui::PushFont(imgui_ctx->large_font);
|
ImGui::PushFont(imgui_ctx->large_font);
|
||||||
ImGui::TextWrapped("WiVRn %s", xrt::drivers::wivrn::git_version);
|
CenterTextH(std::string("WiVRn ") + xrt::drivers::wivrn::git_version);
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
ImGui::Dummy(ImVec2(0, 60));
|
||||||
|
|
||||||
|
float win_width = ImGui::GetWindowSize().x;
|
||||||
|
ImGui::SetCursorPosX(win_width / 4);
|
||||||
|
|
||||||
|
ImGui::Image(about_picture, {win_width / 2, win_width / 2});
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool RadioButtonWithoutCheckBox(const char * label, bool active, ImVec2 size_arg)
|
static bool RadioButtonWithoutCheckBox(const char * label, bool active, ImVec2 size_arg)
|
||||||
|
|||||||
Reference in New Issue
Block a user