Use example base prepare and submit frame function, added ext overlay
This commit is contained in:
parent
d365b7ccd5
commit
3d93c383d8
1 changed files with 22 additions and 23 deletions
|
|
@ -80,6 +80,7 @@ public:
|
||||||
rotationSpeed = 0.75f;
|
rotationSpeed = 0.75f;
|
||||||
zoomSpeed = 0.25f;
|
zoomSpeed = 0.25f;
|
||||||
rotation = glm::vec3(-25.0f, 23.75f, 0.0f);
|
rotation = glm::vec3(-25.0f, 23.75f, 0.0f);
|
||||||
|
enableTextOverlay = true;
|
||||||
title = "Vulkan Example - Spherical Environment Mapping";
|
title = "Vulkan Example - Spherical Environment Mapping";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,27 +158,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));
|
|
||||||
}
|
|
||||||
|
|
||||||
void loadMeshes()
|
void loadMeshes()
|
||||||
{
|
{
|
||||||
loadMesh(getAssetPath() + "models/chinesedragon.dae", &meshes.object, vertexLayout, 0.05f);
|
loadMesh(getAssetPath() + "models/chinesedragon.dae", &meshes.object, vertexLayout, 0.05f);
|
||||||
|
|
@ -397,6 +377,7 @@ public:
|
||||||
// Vertex shader uniform buffer block
|
// Vertex shader uniform buffer block
|
||||||
createBuffer(
|
createBuffer(
|
||||||
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||||
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||||
sizeof(uboVS),
|
sizeof(uboVS),
|
||||||
&uboVS,
|
&uboVS,
|
||||||
&uniformData.vertexShader.buffer,
|
&uniformData.vertexShader.buffer,
|
||||||
|
|
@ -429,6 +410,17 @@ public:
|
||||||
vkUnmapMemory(device, uniformData.vertexShader.memory);
|
vkUnmapMemory(device, uniformData.vertexShader.memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw()
|
||||||
|
{
|
||||||
|
VulkanExampleBase::prepareFrame();
|
||||||
|
|
||||||
|
submitInfo.commandBufferCount = 1;
|
||||||
|
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
|
||||||
|
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
|
||||||
|
|
||||||
|
VulkanExampleBase::submitFrame();
|
||||||
|
}
|
||||||
|
|
||||||
void prepare()
|
void prepare()
|
||||||
{
|
{
|
||||||
VulkanExampleBase::prepare();
|
VulkanExampleBase::prepare();
|
||||||
|
|
@ -448,9 +440,7 @@ public:
|
||||||
{
|
{
|
||||||
if (!prepared)
|
if (!prepared)
|
||||||
return;
|
return;
|
||||||
vkDeviceWaitIdle(device);
|
|
||||||
draw();
|
draw();
|
||||||
vkDeviceWaitIdle(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void viewChanged()
|
virtual void viewChanged()
|
||||||
|
|
@ -474,6 +464,15 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void getOverlayText(VulkanTextOverlay *textOverlay)
|
||||||
|
{
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
textOverlay->addText("Press \"Button A\" to toggle material cap", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||||
|
#else
|
||||||
|
textOverlay->addText("Press \"space\" to toggle material cap", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void changeMatCapIndex(uint32_t delta)
|
void changeMatCapIndex(uint32_t delta)
|
||||||
{
|
{
|
||||||
uboVS.texIndex += delta;
|
uboVS.texIndex += delta;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue