Replaced text overlay with proper UI overlay

This commit is contained in:
saschawillems 2017-11-01 14:22:10 +01:00
parent 570750c16f
commit 68692367e0
54 changed files with 564 additions and 1649 deletions

View file

@ -138,10 +138,7 @@ public:
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
{
zoom = -8.0f;
rotation = { 0.0f, 0.0f, 0.0f };
enableTextOverlay = true;
title = "Vulkan Example - Deferred shading (2016 by Sascha Willems)";
title = "Multi sampled deferred shading";
camera.type = Camera::CameraType::firstperson;
camera.movementSpeed = 5.0f;
#ifndef __ANDROID__
@ -151,6 +148,7 @@ public:
camera.setRotation(glm::vec3(-0.75f, 12.5f, 0.0f));
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
paused = true;
settings.overlay = true;
}
~VulkanExample()
@ -1171,51 +1169,19 @@ public:
uboFragmentLights.windowSize = glm::ivec2(width, height);
}
void toggleDebugDisplay()
virtual void OnUpdateUIOverlay(vks::UIOverlay *overlay)
{
debugDisplay = !debugDisplay;
buildCommandBuffers();
updateUniformBuffersScreen();
}
virtual void keyPressed(uint32_t keyCode)
{
switch (keyCode)
{
case KEY_F2:
useMSAA = !useMSAA;
updateTextOverlay();
buildCommandBuffers();
break;
case KEY_F3:
useSampleShading = !useSampleShading;
updateTextOverlay();
buildCommandBuffers();
break;
case KEY_F4:
case GAMEPAD_BUTTON_A:
toggleDebugDisplay();
updateTextOverlay();
break;
}
}
virtual void getOverlayText(VulkanTextOverlay *textOverlay)
{
#if defined(__ANDROID__)
textOverlay->addText("Press \"Button A\" to toggle debug display", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
#else
textOverlay->addText("MSAA (\"F2\"): " + std::to_string(useMSAA), 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
textOverlay->addText("Sample Shading (\"F3\"): " + std::to_string(useSampleShading), 5.0f, 105.0f, VulkanTextOverlay::alignLeft);
textOverlay->addText("G-Buffers (\"F4\")", 5.0f, 125.0f, VulkanTextOverlay::alignLeft);
#endif
// Render targets
if (debugDisplay)
{
textOverlay->addText("World space position", (float)width * 0.25f, (float)height * 0.5f - 25.0f, VulkanTextOverlay::alignCenter);
textOverlay->addText("World space normals", (float)width * 0.75f, (float)height * 0.5f - 25.0f, VulkanTextOverlay::alignCenter);
textOverlay->addText("Albedo", (float)width * 0.25f, (float)height - 25.0f, VulkanTextOverlay::alignCenter);
textOverlay->addText("Final image", (float)width * 0.75f, (float)height - 25.0f, VulkanTextOverlay::alignCenter);
if (overlay->header("Settings")) {
if (overlay->checkBox("Display render targets", &debugDisplay)) {
buildCommandBuffers();
updateUniformBuffersScreen();
}
if (overlay->checkBox("MSAA", &useMSAA)) {
buildCommandBuffers();
}
if (overlay->checkBox("Sample rate shading", &useSampleShading)) {
buildDeferredCommandBuffer();
}
}
}
};