diff --git a/displacement/displacement.cpp b/displacement/displacement.cpp index 6af6e95f..4a3ca74e 100644 --- a/displacement/displacement.cpp +++ b/displacement/displacement.cpp @@ -226,9 +226,9 @@ public: sizeof(float) * 6); vertices.inputState = vkTools::initializers::pipelineVertexInputStateCreateInfo(); - vertices.inputState.vertexBindingDescriptionCount = vertices.bindingDescriptions.size(); + vertices.inputState.vertexBindingDescriptionCount = static_cast(vertices.bindingDescriptions.size()); vertices.inputState.pVertexBindingDescriptions = vertices.bindingDescriptions.data(); - vertices.inputState.vertexAttributeDescriptionCount = vertices.attributeDescriptions.size(); + vertices.inputState.vertexAttributeDescriptionCount = static_cast(vertices.attributeDescriptions.size()); vertices.inputState.pVertexAttributeDescriptions = vertices.attributeDescriptions.data(); } @@ -243,7 +243,7 @@ public: VkDescriptorPoolCreateInfo descriptorPoolInfo = vkTools::initializers::descriptorPoolCreateInfo( - poolSizes.size(), + static_cast(poolSizes.size()), poolSizes.data(), 2); @@ -274,7 +274,7 @@ public: VkDescriptorSetLayoutCreateInfo descriptorLayout = vkTools::initializers::descriptorSetLayoutCreateInfo( setLayoutBindings.data(), - setLayoutBindings.size()); + static_cast(setLayoutBindings.size())); VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &descriptorSetLayout)); @@ -325,7 +325,7 @@ public: &texDescriptor), }; - vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL); + vkUpdateDescriptorSets(device, static_cast(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, NULL); } void preparePipelines() @@ -375,7 +375,7 @@ public: VkPipelineDynamicStateCreateInfo dynamicState = vkTools::initializers::pipelineDynamicStateCreateInfo( dynamicStateEnables.data(), - dynamicStateEnables.size(), + static_cast(dynamicStateEnables.size()), 0); VkPipelineTessellationStateCreateInfo tessellationState = @@ -404,7 +404,7 @@ public: pipelineCreateInfo.pDepthStencilState = &depthStencilState; pipelineCreateInfo.pDynamicState = &dynamicState; pipelineCreateInfo.pTessellationState = &tessellationState; - pipelineCreateInfo.stageCount = shaderStages.size(); + pipelineCreateInfo.stageCount = static_cast(shaderStages.size()); pipelineCreateInfo.pStages = shaderStages.data(); pipelineCreateInfo.renderPass = renderPass; @@ -525,7 +525,7 @@ public: void changeTessellationLevel(float delta) { uboTessControl.tessLevel += delta; - uboTessControl.tessLevel = fmax(1.0, fmin(uboTessControl.tessLevel, 32.0)); + uboTessControl.tessLevel = fmax(1.0f, fmin(uboTessControl.tessLevel, 32.0f)); updateUniformBuffers(); updateTextOverlay(); } @@ -557,11 +557,11 @@ public: { case KEY_KPADD: case GAMEPAD_BUTTON_R1: - changeTessellationStrength(0.025); + changeTessellationStrength(0.025f); break; case KEY_KPSUB: case GAMEPAD_BUTTON_L1: - changeTessellationStrength(-0.025); + changeTessellationStrength(-0.025f); break; case KEY_D: case GAMEPAD_BUTTON_A: diff --git a/gears/gears.cpp b/gears/gears.cpp index 7553eaf2..70151946 100644 --- a/gears/gears.cpp +++ b/gears/gears.cpp @@ -183,9 +183,9 @@ public: sizeof(float) * 6); vertices.inputState = vkTools::initializers::pipelineVertexInputStateCreateInfo(); - vertices.inputState.vertexBindingDescriptionCount = vertices.bindingDescriptions.size(); + vertices.inputState.vertexBindingDescriptionCount = static_cast(vertices.bindingDescriptions.size()); vertices.inputState.pVertexBindingDescriptions = vertices.bindingDescriptions.data(); - vertices.inputState.vertexAttributeDescriptionCount = vertices.attributeDescriptions.size(); + vertices.inputState.vertexAttributeDescriptionCount = static_cast(vertices.attributeDescriptions.size()); vertices.inputState.pVertexAttributeDescriptions = vertices.attributeDescriptions.data(); } @@ -199,7 +199,7 @@ public: VkDescriptorPoolCreateInfo descriptorPoolInfo = vkTools::initializers::descriptorPoolCreateInfo( - poolSizes.size(), + static_cast(poolSizes.size()), poolSizes.data(), // Three descriptor sets (for each gear) 3); @@ -221,7 +221,7 @@ public: VkDescriptorSetLayoutCreateInfo descriptorLayout = vkTools::initializers::descriptorSetLayoutCreateInfo( setLayoutBindings.data(), - setLayoutBindings.size()); + static_cast(setLayoutBindings.size())); VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &descriptorSetLayout)); @@ -287,7 +287,7 @@ public: VkPipelineDynamicStateCreateInfo dynamicState = vkTools::initializers::pipelineDynamicStateCreateInfo( dynamicStateEnables.data(), - dynamicStateEnables.size(), + static_cast(dynamicStateEnables.size()), 0); // Solid rendering pipeline @@ -311,7 +311,7 @@ public: pipelineCreateInfo.pViewportState = &viewportState; pipelineCreateInfo.pDepthStencilState = &depthStencilState; pipelineCreateInfo.pDynamicState = &dynamicState; - pipelineCreateInfo.stageCount = shaderStages.size(); + pipelineCreateInfo.stageCount = static_cast(shaderStages.size()); pipelineCreateInfo.pStages = shaderStages.data(); VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.solid)); diff --git a/gears/vulkangear.cpp b/gears/vulkangear.cpp index 561c2c15..9060276a 100644 --- a/gears/vulkangear.cpp +++ b/gears/vulkangear.cpp @@ -14,7 +14,7 @@ int32_t VulkanGear::newVertex(std::vector *vBuffer, float x, float y, fl { Vertex v(glm::vec3(x, y, z), normal, color); vBuffer->push_back(v); - return vBuffer->size() - 1; + return static_cast(vBuffer->size()) - 1; } void VulkanGear::newFace(std::vector *iBuffer, int a, int b, int c) @@ -51,26 +51,26 @@ void VulkanGear::generate(GearInfo *gearinfo, VkQueue queue) int32_t ix0, ix1, ix2, ix3, ix4, ix5; r0 = gearinfo->innerRadius; - r1 = gearinfo->outerRadius - gearinfo->toothDepth / 2.0; - r2 = gearinfo->outerRadius + gearinfo->toothDepth / 2.0; - da = 2.0 * M_PI / gearinfo->numTeeth / 4.0; + r1 = gearinfo->outerRadius - gearinfo->toothDepth / 2.0f; + r2 = gearinfo->outerRadius + gearinfo->toothDepth / 2.0f; + da = 2.0f * M_PI / gearinfo->numTeeth / 4.0f; glm::vec3 normal; for (i = 0; i < gearinfo->numTeeth; i++) { - ta = i * 2.0 * M_PI / gearinfo->numTeeth; + ta = i * 2.0f * M_PI / gearinfo->numTeeth; cos_ta = cos(ta); cos_ta_1da = cos(ta + da); - cos_ta_2da = cos(ta + 2 * da); - cos_ta_3da = cos(ta + 3 * da); - cos_ta_4da = cos(ta + 4 * da); + cos_ta_2da = cos(ta + 2.0f * da); + cos_ta_3da = cos(ta + 3.0f * da); + cos_ta_4da = cos(ta + 4.0f * da); sin_ta = sin(ta); sin_ta_1da = sin(ta + da); - sin_ta_2da = sin(ta + 2 * da); - sin_ta_3da = sin(ta + 3 * da); - sin_ta_4da = sin(ta + 4 * da); + sin_ta_2da = sin(ta + 2.0f * da); + sin_ta_3da = sin(ta + 3.0f * da); + sin_ta_4da = sin(ta + 4.0f * da); u1 = r2 * cos_ta_1da - r1 * cos_ta; v1 = r2 * sin_ta_1da - r1 * sin_ta; @@ -81,93 +81,93 @@ void VulkanGear::generate(GearInfo *gearinfo, VkQueue queue) v2 = r1 * sin_ta_3da - r2 * sin_ta_2da; // front face - normal = glm::vec3(0.0, 0.0, 1.0); - ix0 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, gearinfo->width * 0.5, normal); - ix1 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, gearinfo->width * 0.5, normal); - ix2 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, gearinfo->width * 0.5, normal); - ix3 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, gearinfo->width * 0.5, normal); - ix4 = newVertex(&vBuffer, r0 * cos_ta_4da, r0 * sin_ta_4da, gearinfo->width * 0.5, normal); - ix5 = newVertex(&vBuffer, r1 * cos_ta_4da, r1 * sin_ta_4da, gearinfo->width * 0.5, normal); + normal = glm::vec3(0.0f, 0.0f, 1.0f); + ix0 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, gearinfo->width * 0.5f, normal); + ix1 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, gearinfo->width * 0.5f, normal); + ix2 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, gearinfo->width * 0.5f, normal); + ix3 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, gearinfo->width * 0.5f, normal); + ix4 = newVertex(&vBuffer, r0 * cos_ta_4da, r0 * sin_ta_4da, gearinfo->width * 0.5f, normal); + ix5 = newVertex(&vBuffer, r1 * cos_ta_4da, r1 * sin_ta_4da, gearinfo->width * 0.5f, normal); newFace(&iBuffer, ix0, ix1, ix2); newFace(&iBuffer, ix1, ix3, ix2); newFace(&iBuffer, ix2, ix3, ix4); newFace(&iBuffer, ix3, ix5, ix4); // front sides of teeth - normal = glm::vec3(0.0, 0.0, 1.0); - ix0 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, gearinfo->width * 0.5, normal); - ix1 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, gearinfo->width * 0.5, normal); - ix2 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, gearinfo->width * 0.5, normal); - ix3 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, gearinfo->width * 0.5, normal); + normal = glm::vec3(0.0f, 0.0f, 1.0f); + ix0 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, gearinfo->width * 0.5f, normal); + ix1 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, gearinfo->width * 0.5f, normal); + ix2 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, gearinfo->width * 0.5f, normal); + ix3 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, gearinfo->width * 0.5f, normal); newFace(&iBuffer, ix0, ix1, ix2); newFace(&iBuffer, ix1, ix3, ix2); // back face - normal = glm::vec3(0.0, 0.0, -1.0); - ix0 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, -gearinfo->width * 0.5, normal); - ix1 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, -gearinfo->width * 0.5, normal); - ix2 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, -gearinfo->width * 0.5, normal); - ix3 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, -gearinfo->width * 0.5, normal); - ix4 = newVertex(&vBuffer, r1 * cos_ta_4da, r1 * sin_ta_4da, -gearinfo->width * 0.5, normal); - ix5 = newVertex(&vBuffer, r0 * cos_ta_4da, r0 * sin_ta_4da, -gearinfo->width * 0.5, normal); + normal = glm::vec3(0.0f, 0.0f, -1.0f); + ix0 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, -gearinfo->width * 0.5f, normal); + ix1 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, -gearinfo->width * 0.5f, normal); + ix2 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, -gearinfo->width * 0.5f, normal); + ix3 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, -gearinfo->width * 0.5f, normal); + ix4 = newVertex(&vBuffer, r1 * cos_ta_4da, r1 * sin_ta_4da, -gearinfo->width * 0.5f, normal); + ix5 = newVertex(&vBuffer, r0 * cos_ta_4da, r0 * sin_ta_4da, -gearinfo->width * 0.5f, normal); newFace(&iBuffer, ix0, ix1, ix2); newFace(&iBuffer, ix1, ix3, ix2); newFace(&iBuffer, ix2, ix3, ix4); newFace(&iBuffer, ix3, ix5, ix4); // back sides of teeth - normal = glm::vec3(0.0, 0.0, -1.0); - ix0 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, -gearinfo->width * 0.5, normal); - ix1 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, -gearinfo->width * 0.5, normal); - ix2 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, -gearinfo->width * 0.5, normal); - ix3 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, -gearinfo->width * 0.5, normal); + normal = glm::vec3(0.0f, 0.0f, -1.0f); + ix0 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, -gearinfo->width * 0.5f, normal); + ix1 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, -gearinfo->width * 0.5f, normal); + ix2 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, -gearinfo->width * 0.5f, normal); + ix3 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, -gearinfo->width * 0.5f, normal); newFace(&iBuffer, ix0, ix1, ix2); newFace(&iBuffer, ix1, ix3, ix2); // draw outward faces of teeth - normal = glm::vec3(v1, -u1, 0.0); - ix0 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, gearinfo->width * 0.5, normal); - ix1 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, -gearinfo->width * 0.5, normal); - ix2 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, gearinfo->width * 0.5, normal); - ix3 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, -gearinfo->width * 0.5, normal); + normal = glm::vec3(v1, -u1, 0.0f); + ix0 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, gearinfo->width * 0.5f, normal); + ix1 = newVertex(&vBuffer, r1 * cos_ta, r1 * sin_ta, -gearinfo->width * 0.5f, normal); + ix2 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, gearinfo->width * 0.5f, normal); + ix3 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, -gearinfo->width * 0.5f, normal); newFace(&iBuffer, ix0, ix1, ix2); newFace(&iBuffer, ix1, ix3, ix2); - normal = glm::vec3(cos_ta, sin_ta, 0.0); - ix0 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, gearinfo->width * 0.5, normal); - ix1 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, -gearinfo->width * 0.5, normal); - ix2 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, gearinfo->width * 0.5, normal); - ix3 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, -gearinfo->width * 0.5, normal); + normal = glm::vec3(cos_ta, sin_ta, 0.0f); + ix0 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, gearinfo->width * 0.5f, normal); + ix1 = newVertex(&vBuffer, r2 * cos_ta_1da, r2 * sin_ta_1da, -gearinfo->width * 0.5f, normal); + ix2 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, gearinfo->width * 0.5f, normal); + ix3 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, -gearinfo->width * 0.5f, normal); newFace(&iBuffer, ix0, ix1, ix2); newFace(&iBuffer, ix1, ix3, ix2); - normal = glm::vec3(v2, -u2, 0.0); - ix0 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, gearinfo->width * 0.5, normal); - ix1 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, -gearinfo->width * 0.5, normal); - ix2 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, gearinfo->width * 0.5, normal); - ix3 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, -gearinfo->width * 0.5, normal); + normal = glm::vec3(v2, -u2, 0.0f); + ix0 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, gearinfo->width * 0.5f, normal); + ix1 = newVertex(&vBuffer, r2 * cos_ta_2da, r2 * sin_ta_2da, -gearinfo->width * 0.5f, normal); + ix2 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, gearinfo->width * 0.5f, normal); + ix3 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, -gearinfo->width * 0.5f, normal); newFace(&iBuffer, ix0, ix1, ix2); newFace(&iBuffer, ix1, ix3, ix2); - normal = glm::vec3(cos_ta, sin_ta, 0.0); - ix0 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, gearinfo->width * 0.5, normal); - ix1 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, -gearinfo->width * 0.5, normal); - ix2 = newVertex(&vBuffer, r1 * cos_ta_4da, r1 * sin_ta_4da, gearinfo->width * 0.5, normal); - ix3 = newVertex(&vBuffer, r1 * cos_ta_4da, r1 * sin_ta_4da, -gearinfo->width * 0.5, normal); + normal = glm::vec3(cos_ta, sin_ta, 0.0f); + ix0 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, gearinfo->width * 0.5f, normal); + ix1 = newVertex(&vBuffer, r1 * cos_ta_3da, r1 * sin_ta_3da, -gearinfo->width * 0.5f, normal); + ix2 = newVertex(&vBuffer, r1 * cos_ta_4da, r1 * sin_ta_4da, gearinfo->width * 0.5f, normal); + ix3 = newVertex(&vBuffer, r1 * cos_ta_4da, r1 * sin_ta_4da, -gearinfo->width * 0.5f, normal); newFace(&iBuffer, ix0, ix1, ix2); newFace(&iBuffer, ix1, ix3, ix2); // draw inside radius cylinder - ix0 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, -gearinfo->width * 0.5, glm::vec3(-cos_ta, -sin_ta, 0.0)); - ix1 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, gearinfo->width * 0.5, glm::vec3(-cos_ta, -sin_ta, 0.0)); - ix2 = newVertex(&vBuffer, r0 * cos_ta_4da, r0 * sin_ta_4da, -gearinfo->width * 0.5, glm::vec3(-cos_ta_4da, -sin_ta_4da, 0.0)); - ix3 = newVertex(&vBuffer, r0 * cos_ta_4da, r0 * sin_ta_4da, gearinfo->width * 0.5, glm::vec3(-cos_ta_4da, -sin_ta_4da, 0.0)); + ix0 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, -gearinfo->width * 0.5f, glm::vec3(-cos_ta, -sin_ta, 0.0f)); + ix1 = newVertex(&vBuffer, r0 * cos_ta, r0 * sin_ta, gearinfo->width * 0.5f, glm::vec3(-cos_ta, -sin_ta, 0.0f)); + ix2 = newVertex(&vBuffer, r0 * cos_ta_4da, r0 * sin_ta_4da, -gearinfo->width * 0.5f, glm::vec3(-cos_ta_4da, -sin_ta_4da, 0.0f)); + ix3 = newVertex(&vBuffer, r0 * cos_ta_4da, r0 * sin_ta_4da, gearinfo->width * 0.5f, glm::vec3(-cos_ta_4da, -sin_ta_4da, 0.0f)); newFace(&iBuffer, ix0, ix1, ix2); newFace(&iBuffer, ix1, ix3, ix2); } - int vertexBufferSize = vBuffer.size() * sizeof(Vertex); - int indexBufferSize = iBuffer.size() * sizeof(uint32_t); + size_t vertexBufferSize = vBuffer.size() * sizeof(Vertex); + size_t indexBufferSize = iBuffer.size() * sizeof(uint32_t); bool useStaging = true;