Text overlay, android buttons
This commit is contained in:
parent
3d60342be0
commit
2c8d63e0b4
1 changed files with 44 additions and 33 deletions
|
|
@ -397,6 +397,7 @@ public:
|
||||||
zoomSpeed = 2.5f;
|
zoomSpeed = 2.5f;
|
||||||
rotationSpeed = 0.5f;
|
rotationSpeed = 0.5f;
|
||||||
rotation = { -182.5f, -38.5f, 180.0f };
|
rotation = { -182.5f, -38.5f, 180.0f };
|
||||||
|
enableTextOverlay = true;
|
||||||
title = "Vulkan Example - Skeletal animation";
|
title = "Vulkan Example - Skeletal animation";
|
||||||
cameraPos = { 0.0f, 0.0f, 12.0f };
|
cameraPos = { 0.0f, 0.0f, 12.0f };
|
||||||
}
|
}
|
||||||
|
|
@ -476,27 +477,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
|
// 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
|
// The other example will use the VulkanMesh loader which has some additional functionality for loading meshes
|
||||||
void loadMesh()
|
void loadMesh()
|
||||||
|
|
@ -935,6 +915,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),
|
||||||
nullptr,
|
nullptr,
|
||||||
&uniformData.vsScene.buffer,
|
&uniformData.vsScene.buffer,
|
||||||
|
|
@ -947,6 +928,7 @@ public:
|
||||||
// Floor
|
// Floor
|
||||||
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(uboFloor),
|
sizeof(uboFloor),
|
||||||
nullptr,
|
nullptr,
|
||||||
&uniformData.floor.buffer,
|
&uniformData.floor.buffer,
|
||||||
|
|
@ -999,6 +981,17 @@ public:
|
||||||
memcpy(uniformData.floor.mapped, &uboFloor, sizeof(uboFloor));
|
memcpy(uniformData.floor.mapped, &uboFloor, sizeof(uboFloor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
@ -1037,7 +1030,35 @@ public:
|
||||||
void changeAnimationSpeed(float delta)
|
void changeAnimationSpeed(float delta)
|
||||||
{
|
{
|
||||||
skinnedMesh->animationSpeed += delta;
|
skinnedMesh->animationSpeed += delta;
|
||||||
std::cout << "Animation speed = " << skinnedMesh->animationSpeed << std::endl;
|
}
|
||||||
|
|
||||||
|
virtual void keyPressed(uint32_t keyCode)
|
||||||
|
{
|
||||||
|
switch (keyCode)
|
||||||
|
{
|
||||||
|
case 0x6B:
|
||||||
|
case GAMEPAD_BUTTON_R1:
|
||||||
|
changeAnimationSpeed(0.1f);
|
||||||
|
break;
|
||||||
|
case 0x6D:
|
||||||
|
case GAMEPAD_BUTTON_L1:
|
||||||
|
changeAnimationSpeed(-0.1f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void getOverlayText(VulkanTextOverlay *textOverlay)
|
||||||
|
{
|
||||||
|
if (skinnedMesh != nullptr)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << std::setprecision(2) << std::fixed << skinnedMesh->animationSpeed;
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
textOverlay->addText("Animation speed: " + ss.str() + " (Buttons L1/R1 to change)", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||||
|
#else
|
||||||
|
textOverlay->addText("Animation speed: " + ss.str() + " (numpad +/- to change)", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1049,16 +1070,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
if (vulkanExample != NULL)
|
if (vulkanExample != NULL)
|
||||||
{
|
{
|
||||||
vulkanExample->handleMessages(hWnd, uMsg, wParam, lParam);
|
vulkanExample->handleMessages(hWnd, uMsg, wParam, lParam);
|
||||||
if (uMsg == WM_KEYDOWN)
|
|
||||||
{
|
|
||||||
switch (wParam)
|
|
||||||
{
|
|
||||||
case VK_ADD:
|
|
||||||
case VK_SUBTRACT:
|
|
||||||
vulkanExample->changeAnimationSpeed((wParam == VK_ADD) ? 0.1f : -0.1f);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue