diff --git a/android/mesh/mesh.NativeActivity/main.cpp b/android/mesh/mesh.NativeActivity/main.cpp index 3daea4f3..74e30034 100644 --- a/android/mesh/mesh.NativeActivity/main.cpp +++ b/android/mesh/mesh.NativeActivity/main.cpp @@ -245,8 +245,8 @@ struct VulkanExample vkGetPhysicalDeviceMemoryProperties(physicalDevice, &deviceMemoryProperties); // Swap chain - swapChain.init(instance, physicalDevice, device); - swapChain.initSwapChain(app->window); + swapChain.connect(instance, physicalDevice, device); + swapChain.initSurface(app->window); // Command buffer pool VkCommandPoolCreateInfo cmdPoolInfo = {}; @@ -264,15 +264,17 @@ struct VulkanExample createSetupCommandBuffer(); startSetupCommandBuffer(); - swapChain.setup(setupCmdBuffer, &width, &height); - flushSetupCommandBuffer(); - createCommandBuffers(); + swapChain.create(setupCmdBuffer, &width, &height); setupDepthStencil(); setupRenderPass(); setupFrameBuffer(); + flushSetupCommandBuffer(); + + createCommandBuffers(); + prepareVertices(); prepareUniformBuffers(); setupDescriptorSetLayout(); diff --git a/android/texture/texture.NativeActivity/main.cpp b/android/texture/texture.NativeActivity/main.cpp index 79da0726..954283ea 100644 --- a/android/texture/texture.NativeActivity/main.cpp +++ b/android/texture/texture.NativeActivity/main.cpp @@ -17,6 +17,7 @@ #include #define GLM_FORCE_RADIANS +#define GLM_DEPTH_ZERO_TO_ONE #include "glm/glm.hpp" #include "glm/gtc/matrix_transform.hpp" @@ -24,7 +25,6 @@ #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "AndroidProject1.NativeActivity", __VA_ARGS__)) #define VERTEX_BUFFER_BIND_ID 0 -#define deg_to_rad(deg) deg * float(M_PI / 180) struct saved_state { glm::vec3 rotation; @@ -558,8 +558,8 @@ struct VulkanExample vkGetPhysicalDeviceMemoryProperties(physicalDevice, &deviceMemoryProperties); // Swap chain - swapChain.init(instance, physicalDevice, device); - swapChain.initSwapChain(app->window); + swapChain.connect(instance, physicalDevice, device); + swapChain.initSurface(app->window); // Command buffer pool VkCommandPoolCreateInfo cmdPoolInfo = {}; @@ -577,20 +577,22 @@ struct VulkanExample createSetupCommandBuffer(); startSetupCommandBuffer(); - swapChain.setup(setupCmdBuffer, &width, &height); - flushSetupCommandBuffer(); - createCommandBuffers(); + swapChain.create(setupCmdBuffer, &width, &height); setupDepthStencil(); setupRenderPass(); setupFrameBuffer(); + flushSetupCommandBuffer(); + loadTexture( "textures/vulkan_android_robot.ktx", VK_FORMAT_R8G8B8A8_UNORM, false); + createCommandBuffers(); + prepareVertices(); prepareUniformBuffers(); setupDescriptorSetLayout(); @@ -831,14 +833,14 @@ struct VulkanExample void updateUniformBuffers() { // Update matrices - uboVS.projection = glm::perspective(deg_to_rad(60.0f), (float)width / (float)height, 0.1f, 256.0f); + uboVS.projection = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 256.0f); glm::mat4 viewMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, 0.0f, state.zoom)); uboVS.model = viewMatrix; - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(state.rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(state.rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); - uboVS.model = glm::rotate(uboVS.model, deg_to_rad(state.rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); + uboVS.model = glm::rotate(uboVS.model, glm::radians(state.rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)); + uboVS.model = glm::rotate(uboVS.model, glm::radians(state.rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)); + uboVS.model = glm::rotate(uboVS.model, glm::radians(state.rotation.z), glm::vec3(0.0f, 0.0f, 1.0f)); // Map uniform buffer and update it uint8_t *pData; diff --git a/android/triangle/triangle.NativeActivity/main.cpp b/android/triangle/triangle.NativeActivity/main.cpp index 9a3ee62d..f5c2a004 100644 --- a/android/triangle/triangle.NativeActivity/main.cpp +++ b/android/triangle/triangle.NativeActivity/main.cpp @@ -252,7 +252,6 @@ struct VulkanExample assert(!err); createSetupCommandBuffer(); - startSetupCommandBuffer(); swapChain.create(setupCmdBuffer, &width, &height);