@@ 21,7 21,7 @@ namespace vik {
class RendererTextOverlay : public Renderer {
public:
- TextOverlay *textOverlay;
+ TextOverlay *text_overlay;
VkSemaphore text_overlay_complete;
@@ 31,25 31,26 @@ class RendererTextOverlay : public Renderer {
virtual ~RendererTextOverlay() {
vkDestroySemaphore(device, text_overlay_complete, nullptr);
if (settings->enable_text_overlay)
- delete textOverlay;
+ delete text_overlay;
}
- void init(const std::string &n) {
+ void init(const std::string &n,
+ std::function<void(vik::TextOverlay *overlay)> cb) {
Renderer::init(n);
name = n;
if (settings->enable_text_overlay) {
- init_text_overlay();
+ init_text_overlay(cb);
update_text_overlay();
}
}
- void init_text_overlay() {
+ void init_text_overlay(std::function<void(vik::TextOverlay *overlay)> cb) {
// Load the text rendering shaders
std::vector<VkPipelineShaderStageCreateInfo> shaderStages;
shaderStages.push_back(Shader::load(device, "base/textoverlay.vert.spv", VK_SHADER_STAGE_VERTEX_BIT));
shaderStages.push_back(Shader::load(device, "base/textoverlay.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT));
- textOverlay = new TextOverlay(
+ text_overlay = new TextOverlay(
vksDevice,
queue,
&frame_buffers,
@@ 58,6 59,7 @@ class RendererTextOverlay : public Renderer {
&width,
&height,
shaderStages);
+ text_overlay->set_update_cb(cb);
}
VkSubmitInfo init_text_submit_info() {
@@ 86,12 88,12 @@ class RendererTextOverlay : public Renderer {
<< " fps)";
std::string deviceName(deviceProperties.deviceName);
- textOverlay->update(name, ss.str(), deviceName);
+ text_overlay->update(name, ss.str(), deviceName);
}
void submit_text_overlay() {
VkSubmitInfo submit_info = init_text_submit_info();
- submit_info.pCommandBuffers = &textOverlay->cmdBuffers[currentBuffer];
+ submit_info.pCommandBuffers = &text_overlay->cmdBuffers[currentBuffer];
vik_log_check(vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE));
}
@@ 107,14 109,14 @@ class RendererTextOverlay : public Renderer {
void resize() {
Renderer::resize();
if (settings->enable_text_overlay) {
- textOverlay->reallocateCommandBuffers();
+ text_overlay->reallocateCommandBuffers();
update_text_overlay();
}
}
void submit_frame() {
VkSemaphore waitSemaphore;
- if (settings->enable_text_overlay && textOverlay->visible) {
+ if (settings->enable_text_overlay && text_overlay->visible) {
submit_text_overlay();
waitSemaphore = text_overlay_complete;
} else {
@@ 62,23 62,25 @@ class Settings {
"A XR demo for Vulkan and OpenHMD\n"
"\n"
"Options:\n"
- " -s, --size WxH Size of the output window (default: 1280x720)\n"
- " -f, --fullscreen Run fullscreen. Optinally specify display and mode.\n"
- " -d, --display D Display to fullscreen on. (default: 0)\n"
- " -m, --mode M Mode for fullscreen (wayland-shell only) (default: 0)\n"
- " -w, --window WS Window system to use (default: auto)\n"
- " [xcb, wayland, wayland-shell, kms]\n"
- " -g, --gpu GPU GPU to use (default: 0)\n"
- " --hmd HMD HMD to use (default: 0)\n"
- " --format F Color format to use (default: VK_FORMAT_B8G8R8A8_UNORM)\n"
- " --presentmode M Present mode to use (default: VK_PRESENT_MODE_FIFO_KHR)\n"
+ " -s, --size WxH Size of the output window (default: 1280x720)\n"
+ " -f, --fullscreen Run fullscreen. Optinally specify display and mode.\n"
+ " -d, --display D Display to fullscreen on. (default: 0)\n"
+ " -m, --mode M Mode for fullscreen (wayland-shell only) (default: 0)\n"
+ " -w, --window WS Window system to use (default: auto)\n"
+ " [xcb, wayland, wayland-shell, kms]\n"
+ " -g, --gpu GPU GPU to use (default: 0)\n"
+ " --hmd HMD HMD to use (default: 0)\n"
+ " --format F Color format to use (default: VK_FORMAT_B8G8R8A8_UNORM)\n"
+ " --presentmode M Present mode to use (default: VK_PRESENT_MODE_FIFO_KHR)\n"
"\n"
- " --listgpus List available GPUs\n"
- " --listdisplays List available displays\n"
- " --listhmds List available HMDs\n"
- " --listformats List available color formats\n"
- " --listpresentmodes List available present modes\n"
- " -h, --help Show this help\n";
+ " --list-gpus List available GPUs\n"
+ " --list-displays List available displays\n"
+ " --list-hmds List available HMDs\n"
+ " --list-formats List available color formats\n"
+ " --list-presentmodes List available present modes\n"
+ "\n"
+ " --disable-overlay Disable text overlay\n"
+ " -h, --help Show this help\n";
// VK_PRESENT_MODE_FIFO_KHR for vsync
return help;
@@ 133,11 135,12 @@ class Settings {
{"hmd", 1, 0, 0},
{"format", 1, 0, 0},
{"presentmode", 1, 0, 0},
- {"listgpus", 0, 0, 0},
- {"listdisplays", 0, 0, 0},
- {"listhmds", 0, 0, 0},
- {"listformats", 0, 0, 0},
- {"listpresentmodes", 0, 0, 0},
+ {"list-gpus", 0, 0, 0},
+ {"list-displays", 0, 0, 0},
+ {"list-hmds", 0, 0, 0},
+ {"list-formats", 0, 0, 0},
+ {"list-presentmodes", 0, 0, 0},
+ {"disable-overlay", 0, 0, 0},
{0, 0, 0, 0}
};
@@ 157,16 160,18 @@ class Settings {
exit(0);
} else if (opt == 'v' || optname == "validation") {
validation = true;
- } else if (optname == "listgpus") {
+ } else if (optname == "list-gpus") {
list_gpus_and_exit = true;
- } else if (optname == "listdisplays") {
+ } else if (optname == "list-displays") {
list_screens_and_exit = true;
- } else if (optname == "listhmds") {
+ } else if (optname == "list-hmds") {
list_hmds_and_exit = true;
- } else if (optname == "listformats") {
+ } else if (optname == "list-formats") {
list_formats_and_exit = true;
- } else if (optname == "listpresentmodes") {
+ } else if (optname == "list-presentmodes") {
list_present_modes_and_exit = true;
+ } else if (optname == "disable-overlay") {
+ enable_text_overlay = false;
} else if (opt == 's' || optname == "size") {
size = parse_size(optarg);
} else if (optname == "presentmode") {