添加了动画,资源也改为英文名了

This commit is contained in:
xsl
2025-10-26 21:54:34 +08:00
parent b2da84f903
commit 57b7c40835
16 changed files with 66 additions and 37 deletions
+9 -7
View File
@@ -127,8 +127,11 @@ void Application::mainLoop()
#ifdef _WIN32
while (!glfwWindowShouldClose(window))
{
auto cur_time = getCurrentTimeMillis();
glfwPollEvents();
drawFrame(); // 在这里调用
auto functionTime = (cur_time - _lastDrawFrameTime);
_lastDrawFrameTime = getCurrentTimeMillis();
drawFrame(functionTime); // 在这里调用
}
#else
@@ -448,7 +451,7 @@ void Application::createSyncObjects()
}
}
void Application::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex)
void Application::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex, long long frameTime)
{
VkCommandBufferBeginInfo beginInfo{};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
@@ -473,7 +476,7 @@ void Application::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t im
vkCmdBeginRenderPass(commandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
render(commandBuffer);
render(commandBuffer, frameTime);
// 结束渲染流程
vkCmdEndRenderPass(commandBuffer);
@@ -483,7 +486,7 @@ void Application::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t im
}
}
void Application::render(VkCommandBuffer commandBuffer)
void Application::render(VkCommandBuffer commandBuffer, long long frameTime)
{
// 绑定图形管线
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline);
@@ -492,7 +495,7 @@ void Application::render(VkCommandBuffer commandBuffer)
vkCmdDraw(commandBuffer, 3, 1, 0, 0);
}
void Application::drawFrame()
void Application::drawFrame(long long frameTime)
{
// 1. 等待前一帧完成
vkWaitForFences(device, 1, &inFlightFences[currentFrame], VK_TRUE, UINT64_MAX);
@@ -517,7 +520,7 @@ void Application::drawFrame()
// 5. 记录命令缓冲区
vkResetCommandBuffer(commandBuffers[currentFrame], 0);
recordCommandBuffer(commandBuffers[currentFrame], imageIndex);
recordCommandBuffer(commandBuffers[currentFrame], imageIndex, frameTime);
// 6. 提交命令缓冲区
VkSubmitInfo submitInfo{};
@@ -561,7 +564,6 @@ void Application::drawFrame()
// 8. 前进到下一帧
currentFrame = (currentFrame + 1) % MAX_FRAMES_IN_FLIGHT;
_lastDrawFrameTime =
}
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator) {