Code cleanup, rename ui overlay property
This commit is contained in:
parent
9a8710a57c
commit
fb881ab76f
8 changed files with 69 additions and 69 deletions
|
|
@ -233,14 +233,14 @@ void VulkanExampleBase::prepare()
|
||||||
setupFrameBuffer();
|
setupFrameBuffer();
|
||||||
settings.overlay = settings.overlay && (!benchmark.active);
|
settings.overlay = settings.overlay && (!benchmark.active);
|
||||||
if (settings.overlay) {
|
if (settings.overlay) {
|
||||||
UIOverlay.device = vulkanDevice;
|
ui.device = vulkanDevice;
|
||||||
UIOverlay.queue = queue;
|
ui.queue = queue;
|
||||||
UIOverlay.shaders = {
|
ui.shaders = {
|
||||||
loadShader(getShadersPath() + "base/uioverlay.vert.spv", VK_SHADER_STAGE_VERTEX_BIT),
|
loadShader(getShadersPath() + "base/ui.vert.spv", VK_SHADER_STAGE_VERTEX_BIT),
|
||||||
loadShader(getShadersPath() + "base/uioverlay.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT),
|
loadShader(getShadersPath() + "base/ui.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT),
|
||||||
};
|
};
|
||||||
UIOverlay.prepareResources();
|
ui.prepareResources();
|
||||||
UIOverlay.preparePipeline(pipelineCache, renderPass, swapChain.colorFormat, depthFormat);
|
ui.preparePipeline(pipelineCache, renderPass, swapChain.colorFormat, depthFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -691,12 +691,12 @@ void VulkanExampleBase::updateOverlay()
|
||||||
|
|
||||||
// The overlay does not need to be updated with each frame, so we limit the update rate
|
// The overlay does not need to be updated with each frame, so we limit the update rate
|
||||||
// Not only does this save performance but it also makes display of fast changig values like fps more stable
|
// Not only does this save performance but it also makes display of fast changig values like fps more stable
|
||||||
UIOverlay.updateTimer -= frameTimer;
|
ui.updateTimer -= frameTimer;
|
||||||
if (UIOverlay.updateTimer >= 0.0f) {
|
if (ui.updateTimer >= 0.0f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Update at max. rate of 30 fps
|
// Update at max. rate of 30 fps
|
||||||
UIOverlay.updateTimer = 1.0f / 30.0f;
|
ui.updateTimer = 1.0f / 30.0f;
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
|
@ -704,14 +704,14 @@ void VulkanExampleBase::updateOverlay()
|
||||||
io.DeltaTime = frameTimer;
|
io.DeltaTime = frameTimer;
|
||||||
|
|
||||||
io.MousePos = ImVec2(mouseState.position.x, mouseState.position.y);
|
io.MousePos = ImVec2(mouseState.position.x, mouseState.position.y);
|
||||||
io.MouseDown[0] = mouseState.buttons.left && UIOverlay.visible;
|
io.MouseDown[0] = mouseState.buttons.left && ui.visible;
|
||||||
io.MouseDown[1] = mouseState.buttons.right && UIOverlay.visible;
|
io.MouseDown[1] = mouseState.buttons.right && ui.visible;
|
||||||
io.MouseDown[2] = mouseState.buttons.middle && UIOverlay.visible;
|
io.MouseDown[2] = mouseState.buttons.middle && ui.visible;
|
||||||
|
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0);
|
||||||
ImGui::SetNextWindowPos(ImVec2(10 * UIOverlay.scale, 10 * UIOverlay.scale));
|
ImGui::SetNextWindowPos(ImVec2(10 * ui.scale, 10 * ui.scale));
|
||||||
ImGui::SetNextWindowSize(ImVec2(0, 0), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(0, 0), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::Begin("Vulkan Example", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
|
ImGui::Begin("Vulkan Example", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
|
||||||
ImGui::TextUnformatted(title.c_str());
|
ImGui::TextUnformatted(title.c_str());
|
||||||
|
|
@ -719,10 +719,10 @@ void VulkanExampleBase::updateOverlay()
|
||||||
ImGui::Text("%.2f ms/frame (%.1d fps)", (1000.0f / lastFPS), lastFPS);
|
ImGui::Text("%.2f ms/frame (%.1d fps)", (1000.0f / lastFPS), lastFPS);
|
||||||
|
|
||||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 5.0f * UIOverlay.scale));
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 5.0f * ui.scale));
|
||||||
#endif
|
#endif
|
||||||
ImGui::PushItemWidth(110.0f * UIOverlay.scale);
|
ImGui::PushItemWidth(110.0f * ui.scale);
|
||||||
OnUpdateUIOverlay(&UIOverlay);
|
OnUpdateUIOverlay(&ui);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
|
@ -732,9 +732,9 @@ void VulkanExampleBase::updateOverlay()
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
if (UIOverlay.update() || UIOverlay.updated) {
|
if (ui.update() || ui.updated) {
|
||||||
buildCommandBuffers();
|
buildCommandBuffers();
|
||||||
UIOverlay.updated = false;
|
ui.updated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||||
|
|
@ -746,13 +746,13 @@ void VulkanExampleBase::updateOverlay()
|
||||||
|
|
||||||
void VulkanExampleBase::drawUI(const VkCommandBuffer commandBuffer)
|
void VulkanExampleBase::drawUI(const VkCommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
if (settings.overlay && UIOverlay.visible) {
|
if (settings.overlay && ui.visible) {
|
||||||
const VkViewport viewport = vks::initializers::viewport((float)width, (float)height, 0.0f, 1.0f);
|
const VkViewport viewport = vks::initializers::viewport((float)width, (float)height, 0.0f, 1.0f);
|
||||||
const VkRect2D scissor = vks::initializers::rect2D(width, height, 0, 0);
|
const VkRect2D scissor = vks::initializers::rect2D(width, height, 0, 0);
|
||||||
vkCmdSetViewport(commandBuffer, 0, 1, &viewport);
|
vkCmdSetViewport(commandBuffer, 0, 1, &viewport);
|
||||||
vkCmdSetScissor(commandBuffer, 0, 1, &scissor);
|
vkCmdSetScissor(commandBuffer, 0, 1, &scissor);
|
||||||
|
|
||||||
UIOverlay.draw(commandBuffer);
|
ui.draw(commandBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -940,7 +940,7 @@ VulkanExampleBase::~VulkanExampleBase()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.overlay) {
|
if (settings.overlay) {
|
||||||
UIOverlay.freeResources();
|
ui.freeResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete vulkanDevice;
|
delete vulkanDevice;
|
||||||
|
|
@ -1290,8 +1290,8 @@ void VulkanExampleBase::handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
|
||||||
paused = !paused;
|
paused = !paused;
|
||||||
break;
|
break;
|
||||||
case KEY_F1:
|
case KEY_F1:
|
||||||
UIOverlay.visible = !UIOverlay.visible;
|
ui.visible = !ui.visible;
|
||||||
UIOverlay.updated = true;
|
ui.updated = true;
|
||||||
break;
|
break;
|
||||||
case KEY_F2:
|
case KEY_F2:
|
||||||
if (camera.type == Camera::CameraType::lookat) {
|
if (camera.type == Camera::CameraType::lookat) {
|
||||||
|
|
@ -1477,7 +1477,7 @@ int32_t VulkanExampleBase::handleAppInput(struct android_app* app, AInputEvent*
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
if (vulkanExample->settings.overlay) {
|
if (vulkanExample->settings.overlay) {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
handled = io.WantCaptureMouse && vulkanExample->UIOverlay.visible;
|
handled = io.WantCaptureMouse && vulkanExample->ui.visible;
|
||||||
}
|
}
|
||||||
if (!handled) {
|
if (!handled) {
|
||||||
int32_t eventX = AMotionEvent_getX(event, 0);
|
int32_t eventX = AMotionEvent_getX(event, 0);
|
||||||
|
|
@ -1530,8 +1530,8 @@ int32_t VulkanExampleBase::handleAppInput(struct android_app* app, AInputEvent*
|
||||||
case AKEYCODE_1: // support keyboards with no function keys
|
case AKEYCODE_1: // support keyboards with no function keys
|
||||||
case AKEYCODE_F1:
|
case AKEYCODE_F1:
|
||||||
case AKEYCODE_BUTTON_L1:
|
case AKEYCODE_BUTTON_L1:
|
||||||
vulkanExample->UIOverlay.visible = !vulkanExample->UIOverlay.visible;
|
vulkanExample->ui.visible = !vulkanExample->ui.visible;
|
||||||
vulkanExample->UIOverlay.updated = true;
|
vulkanExample->ui.updated = true;
|
||||||
break;
|
break;
|
||||||
case AKEYCODE_BUTTON_R1:
|
case AKEYCODE_BUTTON_R1:
|
||||||
vulkanExample->keyPressed(GAMEPAD_BUTTON_R1);
|
vulkanExample->keyPressed(GAMEPAD_BUTTON_R1);
|
||||||
|
|
@ -1734,8 +1734,8 @@ static CVReturn displayLinkOutputCallback(CVDisplayLinkRef displayLink, const CV
|
||||||
break;
|
break;
|
||||||
case KEY_1: // support keyboards with no function keys
|
case KEY_1: // support keyboards with no function keys
|
||||||
case KEY_F1:
|
case KEY_F1:
|
||||||
vulkanExample->UIOverlay.visible = !vulkanExample->UIOverlay.visible;
|
vulkanExample->ui.visible = !vulkanExample->ui.visible;
|
||||||
vulkanExample->UIOverlay.updated = true;
|
vulkanExample->ui.updated = true;
|
||||||
break;
|
break;
|
||||||
case KEY_DELETE: // support keyboards with no escape key
|
case KEY_DELETE: // support keyboards with no escape key
|
||||||
case KEY_ESCAPE:
|
case KEY_ESCAPE:
|
||||||
|
|
@ -2130,8 +2130,8 @@ void VulkanExampleBase::handleEvent(const DFBWindowEvent *event)
|
||||||
paused = !paused;
|
paused = !paused;
|
||||||
break;
|
break;
|
||||||
case KEY_F1:
|
case KEY_F1:
|
||||||
UIOverlay.visible = !UIOverlay.visible;
|
ui.visible = !ui.visible;
|
||||||
UIOverlay.updated = true;
|
ui.updated = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -2305,8 +2305,8 @@ void VulkanExampleBase::keyboardKey(struct wl_keyboard *keyboard,
|
||||||
break;
|
break;
|
||||||
case KEY_F1:
|
case KEY_F1:
|
||||||
if (state) {
|
if (state) {
|
||||||
UIOverlay.visible = !UIOverlay.visible;
|
ui.visible = !ui.visible;
|
||||||
UIOverlay.updated = true;
|
ui.updated = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_ESCAPE:
|
case KEY_ESCAPE:
|
||||||
|
|
@ -2667,8 +2667,8 @@ void VulkanExampleBase::handleEvent(const xcb_generic_event_t *event)
|
||||||
paused = !paused;
|
paused = !paused;
|
||||||
break;
|
break;
|
||||||
case KEY_F1:
|
case KEY_F1:
|
||||||
UIOverlay.visible = !UIOverlay.visible;
|
ui.visible = !ui.visible;
|
||||||
UIOverlay.updated = true;
|
ui.updated = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2793,8 +2793,8 @@ void VulkanExampleBase::handleEvent()
|
||||||
paused = !paused;
|
paused = !paused;
|
||||||
break;
|
break;
|
||||||
case KEYCODE_F1:
|
case KEYCODE_F1:
|
||||||
UIOverlay.visible = !UIOverlay.visible;
|
ui.visible = !ui.visible;
|
||||||
UIOverlay.updated = true;
|
ui.updated = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -3198,7 +3198,7 @@ void VulkanExampleBase::windowResize()
|
||||||
|
|
||||||
if ((width > 0.0f) && (height > 0.0f)) {
|
if ((width > 0.0f) && (height > 0.0f)) {
|
||||||
if (settings.overlay) {
|
if (settings.overlay) {
|
||||||
UIOverlay.resize(width, height);
|
ui.resize(width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3235,7 +3235,7 @@ void VulkanExampleBase::handleMouseMove(int32_t x, int32_t y)
|
||||||
|
|
||||||
if (settings.overlay) {
|
if (settings.overlay) {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
handled = io.WantCaptureMouse && UIOverlay.visible;
|
handled = io.WantCaptureMouse && ui.visible;
|
||||||
}
|
}
|
||||||
mouseMoved((float)x, (float)y, handled);
|
mouseMoved((float)x, (float)y, handled);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ public:
|
||||||
uint32_t width = 1280;
|
uint32_t width = 1280;
|
||||||
uint32_t height = 720;
|
uint32_t height = 720;
|
||||||
|
|
||||||
vks::UIOverlay UIOverlay;
|
vks::UIOverlay ui;
|
||||||
CommandLineParser commandLineParser;
|
CommandLineParser commandLineParser;
|
||||||
|
|
||||||
/** @brief Last frame time measured using a high performance timer (if available) */
|
/** @brief Last frame time measured using a high performance timer (if available) */
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Vulkan Example - imGui (https://github.com/ocornut/imgui)
|
* Vulkan Example - imGui (https://github.com/ocornut/imgui)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017-2023 by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2017-2024 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*/
|
*/
|
||||||
|
|
@ -61,9 +61,9 @@ public:
|
||||||
|
|
||||||
//SRS - Set ImGui font and style scale factors to handle retina and other HiDPI displays
|
//SRS - Set ImGui font and style scale factors to handle retina and other HiDPI displays
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.FontGlobalScale = example->UIOverlay.scale;
|
io.FontGlobalScale = example->ui.scale;
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
style.ScaleAllSizes(example->UIOverlay.scale);
|
style.ScaleAllSizes(example->ui.scale);
|
||||||
};
|
};
|
||||||
|
|
||||||
~ImGUI()
|
~ImGUI()
|
||||||
|
|
@ -380,8 +380,8 @@ public:
|
||||||
// Init imGui windows and elements
|
// Init imGui windows and elements
|
||||||
|
|
||||||
// Debug window
|
// Debug window
|
||||||
ImGui::SetWindowPos(ImVec2(20 * example->UIOverlay.scale, 20 * example->UIOverlay.scale), ImGuiSetCond_FirstUseEver);
|
ImGui::SetWindowPos(ImVec2(20 * example->ui.scale, 20 * example->ui.scale), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::SetWindowSize(ImVec2(300 * example->UIOverlay.scale, 300 * example->UIOverlay.scale), ImGuiSetCond_Always);
|
ImGui::SetWindowSize(ImVec2(300 * example->ui.scale, 300 * example->ui.scale), ImGuiSetCond_Always);
|
||||||
ImGui::TextUnformatted(example->title.c_str());
|
ImGui::TextUnformatted(example->title.c_str());
|
||||||
ImGui::TextUnformatted(device->properties.deviceName);
|
ImGui::TextUnformatted(device->properties.deviceName);
|
||||||
|
|
||||||
|
|
@ -409,8 +409,8 @@ public:
|
||||||
ImGui::InputFloat3("rotation", &example->camera.rotation.x, 2);
|
ImGui::InputFloat3("rotation", &example->camera.rotation.x, 2);
|
||||||
|
|
||||||
// Example settings window
|
// Example settings window
|
||||||
ImGui::SetNextWindowPos(ImVec2(20 * example->UIOverlay.scale, 360 * example->UIOverlay.scale), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(20 * example->ui.scale, 360 * example->ui.scale), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::SetNextWindowSize(ImVec2(300 * example->UIOverlay.scale, 200 * example->UIOverlay.scale), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(300 * example->ui.scale, 200 * example->ui.scale), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::Begin("Example settings");
|
ImGui::Begin("Example settings");
|
||||||
ImGui::Checkbox("Render models", &uiSettings.displayModels);
|
ImGui::Checkbox("Render models", &uiSettings.displayModels);
|
||||||
ImGui::Checkbox("Display logos", &uiSettings.displayLogos);
|
ImGui::Checkbox("Display logos", &uiSettings.displayLogos);
|
||||||
|
|
@ -638,7 +638,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render imGui
|
// Render imGui
|
||||||
if (UIOverlay.visible) {
|
if (ui.visible) {
|
||||||
imGui->drawFrame(drawCmdBuffers[i]);
|
imGui->drawFrame(drawCmdBuffers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -794,9 +794,9 @@ public:
|
||||||
io.DeltaTime = frameTimer;
|
io.DeltaTime = frameTimer;
|
||||||
|
|
||||||
io.MousePos = ImVec2(mouseState.position.x, mouseState.position.y);
|
io.MousePos = ImVec2(mouseState.position.x, mouseState.position.y);
|
||||||
io.MouseDown[0] = mouseState.buttons.left && UIOverlay.visible;
|
io.MouseDown[0] = mouseState.buttons.left && ui.visible;
|
||||||
io.MouseDown[1] = mouseState.buttons.right && UIOverlay.visible;
|
io.MouseDown[1] = mouseState.buttons.right && ui.visible;
|
||||||
io.MouseDown[2] = mouseState.buttons.middle && UIOverlay.visible;
|
io.MouseDown[2] = mouseState.buttons.middle && ui.visible;
|
||||||
|
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
@ -804,7 +804,7 @@ public:
|
||||||
virtual void mouseMoved(double x, double y, bool &handled)
|
virtual void mouseMoved(double x, double y, bool &handled)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
handled = io.WantCaptureMouse && UIOverlay.visible;
|
handled = io.WantCaptureMouse && ui.visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Input handling is platform specific, to show how it's basically done this sample implements it for Windows
|
// Input handling is platform specific, to show how it's basically done this sample implements it for Windows
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Vulkan Example - Using input attachments
|
* Vulkan Example - Using input attachments
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018-2023 by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2018-2024 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*
|
*
|
||||||
|
|
@ -77,7 +77,7 @@ public:
|
||||||
camera.setPosition(glm::vec3(1.65f, 1.75f, -6.15f));
|
camera.setPosition(glm::vec3(1.65f, 1.75f, -6.15f));
|
||||||
camera.setRotation(glm::vec3(-12.75f, 380.0f, 0.0f));
|
camera.setRotation(glm::vec3(-12.75f, 380.0f, 0.0f));
|
||||||
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
||||||
UIOverlay.subpass = 1;
|
ui.subpass = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
~VulkanExample()
|
~VulkanExample()
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
* This sample shows how to do multisampled anti aliasing using built-in hardware via resolve attachments
|
* This sample shows how to do multisampled anti aliasing using built-in hardware via resolve attachments
|
||||||
* These are special attachments that a multi-sampled is resolved to using a fixed sample pattern
|
* These are special attachments that a multi-sampled is resolved to using a fixed sample pattern
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2016-2024 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*/
|
*/
|
||||||
|
|
@ -508,7 +508,7 @@ public:
|
||||||
void prepare()
|
void prepare()
|
||||||
{
|
{
|
||||||
sampleCount = getMaxAvailableSampleCount();
|
sampleCount = getMaxAvailableSampleCount();
|
||||||
UIOverlay.rasterizationSamples = sampleCount;
|
ui.rasterizationSamples = sampleCount;
|
||||||
VulkanExampleBase::prepare();
|
VulkanExampleBase::prepare();
|
||||||
loadAssets();
|
loadAssets();
|
||||||
prepareUniformBuffers();
|
prepareUniformBuffers();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Vulkan Example - Multi threaded command buffer generation and rendering
|
* Vulkan Example - Multi threaded command buffer generation and rendering
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2016-2024 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*/
|
*/
|
||||||
|
|
@ -388,7 +388,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render ui last
|
// Render ui last
|
||||||
if (UIOverlay.visible) {
|
if (ui.visible) {
|
||||||
commandBuffers.push_back(secondaryCommandBuffers.ui);
|
commandBuffers.push_back(secondaryCommandBuffers.ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Vulkan Example - Using subpasses for G-Buffer compositing
|
* Vulkan Example - Using subpasses for G-Buffer compositing
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2016-2024 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*
|
*
|
||||||
|
|
@ -98,7 +98,7 @@ public:
|
||||||
camera.setPosition(glm::vec3(-3.2f, 1.0f, 5.9f));
|
camera.setPosition(glm::vec3(-3.2f, 1.0f, 5.9f));
|
||||||
camera.setRotation(glm::vec3(0.5f, 210.05f, 0.0f));
|
camera.setRotation(glm::vec3(0.5f, 210.05f, 0.0f));
|
||||||
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
||||||
UIOverlay.subpass = 2;
|
ui.subpass = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
~VulkanExample()
|
~VulkanExample()
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
* This sample renders a basic text overlay on top of a 3D scene that can be used e.g. for debug purposes
|
* This sample renders a basic text overlay on top of a 3D scene that can be used e.g. for debug purposes
|
||||||
* For a more complete GUI sample see the ImGui sample
|
* For a more complete GUI sample see the ImGui sample
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2016-2024 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*/
|
*/
|
||||||
|
|
@ -535,23 +535,23 @@ public:
|
||||||
|
|
||||||
textOverlay->beginTextUpdate();
|
textOverlay->beginTextUpdate();
|
||||||
|
|
||||||
textOverlay->addText(title, 5.0f * UIOverlay.scale, 5.0f * UIOverlay.scale, TextOverlay::alignLeft);
|
textOverlay->addText(title, 5.0f * ui.scale, 5.0f * ui.scale, TextOverlay::alignLeft);
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::fixed << std::setprecision(2) << (frameTimer * 1000.0f) << "ms (" << lastFPS << " fps)";
|
ss << std::fixed << std::setprecision(2) << (frameTimer * 1000.0f) << "ms (" << lastFPS << " fps)";
|
||||||
textOverlay->addText(ss.str(), 5.0f * UIOverlay.scale, 25.0f * UIOverlay.scale, TextOverlay::alignLeft);
|
textOverlay->addText(ss.str(), 5.0f * ui.scale, 25.0f * ui.scale, TextOverlay::alignLeft);
|
||||||
|
|
||||||
textOverlay->addText(deviceProperties.deviceName, 5.0f * UIOverlay.scale, 45.0f * UIOverlay.scale, TextOverlay::alignLeft);
|
textOverlay->addText(deviceProperties.deviceName, 5.0f * ui.scale, 45.0f * ui.scale, TextOverlay::alignLeft);
|
||||||
|
|
||||||
// Display current model view matrix
|
// Display current model view matrix
|
||||||
textOverlay->addText("model view matrix", (float)width - 5.0f * UIOverlay.scale, 5.0f * UIOverlay.scale, TextOverlay::alignRight);
|
textOverlay->addText("model view matrix", (float)width - 5.0f * ui.scale, 5.0f * ui.scale, TextOverlay::alignRight);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < 4; i++)
|
for (uint32_t i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << std::fixed << std::setprecision(2) << std::showpos;
|
ss << std::fixed << std::setprecision(2) << std::showpos;
|
||||||
ss << uniformData.modelView[0][i] << " " << uniformData.modelView[1][i] << " " << uniformData.modelView[2][i] << " " << uniformData.modelView[3][i];
|
ss << uniformData.modelView[0][i] << " " << uniformData.modelView[1][i] << " " << uniformData.modelView[2][i] << " " << uniformData.modelView[3][i];
|
||||||
textOverlay->addText(ss.str(), (float)width - 5.0f * UIOverlay.scale, (25.0f + (float)i * 20.0f) * UIOverlay.scale, TextOverlay::alignRight);
|
textOverlay->addText(ss.str(), (float)width - 5.0f * ui.scale, (25.0f + (float)i * 20.0f) * ui.scale, TextOverlay::alignRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 projected = glm::project(glm::vec3(0.0f), uniformData.modelView, uniformData.projection, glm::vec4(0, 0, (float)width, (float)height));
|
glm::vec3 projected = glm::project(glm::vec3(0.0f), uniformData.modelView, uniformData.projection, glm::vec4(0, 0, (float)width, (float)height));
|
||||||
|
|
@ -559,8 +559,8 @@ public:
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
#else
|
#else
|
||||||
textOverlay->addText("Press \"space\" to toggle text overlay", 5.0f * UIOverlay.scale, 65.0f * UIOverlay.scale, TextOverlay::alignLeft);
|
textOverlay->addText("Press \"space\" to toggle text overlay", 5.0f * ui.scale, 65.0f * ui.scale, TextOverlay::alignLeft);
|
||||||
textOverlay->addText("Hold middle mouse button and drag to move", 5.0f * UIOverlay.scale, 85.0f * UIOverlay.scale, TextOverlay::alignLeft);
|
textOverlay->addText("Hold middle mouse button and drag to move", 5.0f * ui.scale, 85.0f * ui.scale, TextOverlay::alignLeft);
|
||||||
#endif
|
#endif
|
||||||
textOverlay->endTextUpdate();
|
textOverlay->endTextUpdate();
|
||||||
|
|
||||||
|
|
@ -666,7 +666,7 @@ public:
|
||||||
renderPass,
|
renderPass,
|
||||||
&width,
|
&width,
|
||||||
&height,
|
&height,
|
||||||
UIOverlay.scale,
|
ui.scale,
|
||||||
shaderStages
|
shaderStages
|
||||||
);
|
);
|
||||||
updateTextOverlay();
|
updateTextOverlay();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue