Changeset f985231 in opengl-game for vulkan-game.cpp
- Timestamp:
- Nov 7, 2019, 2:30:59 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- cc4a8b5
- Parents:
- d2d9286
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
rd2d9286 rf985231 2 2 3 3 #include <array> 4 #include <chrono> 4 5 #include <iostream> 5 6 #include <set> … … 297 298 } 298 299 300 updateUniformBuffer(imageIndex); 301 299 302 VkSubmitInfo submitInfo = {}; 300 303 submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; … … 887 890 } 888 891 892 void VulkanGame::updateUniformBuffer(uint32_t currentImage) { 893 static auto startTime = chrono::high_resolution_clock::now(); 894 895 auto currentTime = chrono::high_resolution_clock::now(); 896 float time = chrono::duration<float, chrono::seconds::period>(currentTime - startTime).count(); 897 898 UniformBufferObject ubo = {}; 899 ubo.model = rotate(glm::mat4(1.0f), time * glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f)); 900 ubo.view = lookAt(glm::vec3(0.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)); 901 ubo.proj = perspective(radians(45.0f), swapChainExtent.width / (float)swapChainExtent.height, 0.1f, 10.0f); 902 ubo.proj[1][1] *= -1; // flip the y-axis so that +y is up 903 904 void* data; 905 vkMapMemory(device, uniformBuffersMemory[currentImage], 0, sizeof(ubo), 0, &data); 906 memcpy(data, &ubo, sizeof(ubo)); 907 vkUnmapMemory(device, uniformBuffersMemory[currentImage]); 908 } 909 889 910 void VulkanGame::cleanupSwapChain() { 890 911 VulkanUtils::destroyVulkanImage(device, depthImage);
Note:
See TracChangeset
for help on using the changeset viewer.