Refactoring, added text overlay
This commit is contained in:
parent
dd5b64e356
commit
332d4a6fef
1 changed files with 26 additions and 23 deletions
|
|
@ -88,6 +88,7 @@ public:
|
|||
rotationSpeed = 0.5f;
|
||||
rotation = { -0.5f, -112.75f, 0.0f };
|
||||
cameraPos = { 0.1f, 1.1f, 0.0f };
|
||||
enableTextOverlay = true;
|
||||
title = "Vulkan Example - Mesh rendering";
|
||||
}
|
||||
|
||||
|
|
@ -170,27 +171,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
// Get next image in the swap chain (back/front buffer)
|
||||
VK_CHECK_RESULT(swapChain.acquireNextImage(semaphores.presentComplete, ¤tBuffer));
|
||||
|
||||
submitPostPresentBarrier(swapChain.buffers[currentBuffer].image);
|
||||
|
||||
// Command buffer to be sumitted to the queue
|
||||
submitInfo.commandBufferCount = 1;
|
||||
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
|
||||
|
||||
// Submit to queue
|
||||
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
|
||||
|
||||
submitPrePresentBarrier(swapChain.buffers[currentBuffer].image);
|
||||
|
||||
VK_CHECK_RESULT(swapChain.queuePresent(queue, currentBuffer, semaphores.renderComplete));
|
||||
|
||||
VK_CHECK_RESULT(vkQueueWaitIdle(queue));
|
||||
}
|
||||
|
||||
// Load a mesh based on data read via assimp
|
||||
// The other example will use the VulkanMesh loader which has some additional functionality for loading meshes
|
||||
void loadMesh()
|
||||
|
|
@ -562,8 +542,9 @@ public:
|
|||
// Vertex shader uniform buffer block
|
||||
createBuffer(
|
||||
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||
sizeof(uboVS),
|
||||
&uboVS,
|
||||
nullptr,
|
||||
&uniformData.vsScene.buffer,
|
||||
&uniformData.vsScene.memory,
|
||||
&uniformData.vsScene.descriptor);
|
||||
|
|
@ -587,6 +568,20 @@ public:
|
|||
vkUnmapMemory(device, uniformData.vsScene.memory);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
VulkanExampleBase::prepareFrame();
|
||||
|
||||
// Command buffer to be sumitted to the queue
|
||||
submitInfo.commandBufferCount = 1;
|
||||
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
|
||||
|
||||
// Submit to queue
|
||||
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
|
||||
|
||||
VulkanExampleBase::submitFrame();
|
||||
}
|
||||
|
||||
void prepare()
|
||||
{
|
||||
VulkanExampleBase::prepare();
|
||||
|
|
@ -611,7 +606,6 @@ public:
|
|||
|
||||
virtual void viewChanged()
|
||||
{
|
||||
vkDeviceWaitIdle(device);
|
||||
updateUniformBuffers();
|
||||
}
|
||||
|
||||
|
|
@ -626,6 +620,15 @@ public:
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void getOverlayText(VulkanTextOverlay *textOverlay)
|
||||
{
|
||||
#if defined(__ANDROID__)
|
||||
textOverlay->addText("Press \"Button A\" to toggle wireframe", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||
#else
|
||||
textOverlay->addText("Press \"w\" to toggle wireframe", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
VulkanExample *vulkanExample;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue