From ff643e5e48336cc2d0b819f45dbc705a82d2fb67 Mon Sep 17 00:00:00 2001 From: saschawillems Date: Sat, 4 Feb 2017 14:37:55 +0100 Subject: [PATCH] Fixed compiler warnings (Refs #183) --- textoverlay/textoverlay.cpp | 39 ++++++++++++++++----------------- textoverlay/textoverlay.vcxproj | 1 + 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/textoverlay/textoverlay.cpp b/textoverlay/textoverlay.cpp index 4b7beaf9..6a61cdf7 100644 --- a/textoverlay/textoverlay.cpp +++ b/textoverlay/textoverlay.cpp @@ -50,7 +50,7 @@ std::vector vertexLayout = #define STB_NUM_CHARS STB_FONT_consolas_24_latin1_NUM_CHARS // Max. number of chars the text overlay buffer can hold -#define MAX_CHAR_COUNT 2048 +#define TEXTOVERLAY_MAX_CHAR_COUNT 2048 // Mostly self-contained text overlay class class TextOverlay @@ -141,7 +141,6 @@ public: vkDestroyPipelineCache(vulkanDevice->logicalDevice, pipelineCache, nullptr); vkDestroyPipeline(vulkanDevice->logicalDevice, pipeline, nullptr); vkDestroyRenderPass(vulkanDevice->logicalDevice, renderPass, nullptr); - vkFreeCommandBuffers(vulkanDevice->logicalDevice, commandPool, cmdBuffers.size(), cmdBuffers.data()); vkDestroyCommandPool(vulkanDevice->logicalDevice, commandPool, nullptr); } @@ -170,7 +169,7 @@ public: VK_CHECK_RESULT(vkAllocateCommandBuffers(vulkanDevice->logicalDevice, &cmdBufAllocateInfo, cmdBuffers.data())); // Vertex buffer - VkDeviceSize bufferSize = MAX_CHAR_COUNT * sizeof(glm::vec4); + VkDeviceSize bufferSize = TEXTOVERLAY_MAX_CHAR_COUNT * sizeof(glm::vec4); VkBufferCreateInfo bufferInfo = vkTools::initializers::bufferCreateInfo(VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, bufferSize); VK_CHECK_RESULT(vkCreateBuffer(vulkanDevice->logicalDevice, &bufferInfo, nullptr, &buffer)); @@ -324,7 +323,7 @@ public: VkDescriptorPoolCreateInfo descriptorPoolInfo = vkTools::initializers::descriptorPoolCreateInfo( - poolSizes.size(), + static_cast(poolSizes.size()), poolSizes.data(), 1); @@ -337,7 +336,7 @@ public: VkDescriptorSetLayoutCreateInfo descriptorSetLayoutInfo = vkTools::initializers::descriptorSetLayoutCreateInfo( setLayoutBindings.data(), - setLayoutBindings.size()); + static_cast(setLayoutBindings.size())); VK_CHECK_RESULT(vkCreateDescriptorSetLayout(vulkanDevice->logicalDevice, &descriptorSetLayoutInfo, nullptr, &descriptorSetLayout)); // Pipeline layout @@ -364,7 +363,7 @@ public: std::array writeDescriptorSets; writeDescriptorSets[0] = vkTools::initializers::writeDescriptorSet(descriptorSet, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 0, &texDescriptor); - vkUpdateDescriptorSets(vulkanDevice->logicalDevice, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL); + vkUpdateDescriptorSets(vulkanDevice->logicalDevice, static_cast(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, NULL); // Pipeline cache VkPipelineCacheCreateInfo pipelineCacheCreateInfo = {}; @@ -427,7 +426,7 @@ public: VkPipelineDynamicStateCreateInfo dynamicState = vkTools::initializers::pipelineDynamicStateCreateInfo( dynamicStateEnables.data(), - dynamicStateEnables.size(), + static_cast(dynamicStateEnables.size()), 0); std::array vertexBindings = {}; @@ -441,9 +440,9 @@ public: vertexAttribs[1] = vkTools::initializers::vertexInputAttributeDescription(1, 1, VK_FORMAT_R32G32_SFLOAT, sizeof(glm::vec2)); VkPipelineVertexInputStateCreateInfo inputState = vkTools::initializers::pipelineVertexInputStateCreateInfo(); - inputState.vertexBindingDescriptionCount = vertexBindings.size(); + inputState.vertexBindingDescriptionCount = static_cast(vertexBindings.size()); inputState.pVertexBindingDescriptions = vertexBindings.data(); - inputState.vertexAttributeDescriptionCount = vertexAttribs.size(); + inputState.vertexAttributeDescriptionCount = static_cast(vertexAttribs.size()); inputState.pVertexAttributeDescriptions = vertexAttribs.data(); VkGraphicsPipelineCreateInfo pipelineCreateInfo = @@ -460,7 +459,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(vulkanDevice->logicalDevice, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipeline)); @@ -845,14 +844,14 @@ public: } // Display current model view matrix - textOverlay->addText("model view matrix", width, 5.0f, TextOverlay::alignRight); + textOverlay->addText("model view matrix", (float)width, 5.0f, TextOverlay::alignRight); for (uint32_t i = 0; i < 4; i++) { ss.str(""); ss << std::fixed << std::setprecision(2) << std::showpos; ss << uboVS.model[0][i] << " " << uboVS.model[1][i] << " " << uboVS.model[2][i] << " " << uboVS.model[3][i]; - textOverlay->addText(ss.str(), width, 25.0f + (float)i * 20.0f, TextOverlay::alignRight); + textOverlay->addText(ss.str(), (float)width, 25.0f + (float)i * 20.0f, TextOverlay::alignRight); } glm::vec3 projected = glm::project(glm::vec3(0.0f), uboVS.model, uboVS.projection, glm::vec4(0, 0, (float)width, (float)height)); @@ -919,9 +918,9 @@ public: sizeof(float) * 8); 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(); } @@ -935,7 +934,7 @@ public: VkDescriptorPoolCreateInfo descriptorPoolInfo = vkTools::initializers::descriptorPoolCreateInfo( - poolSizes.size(), + static_cast(poolSizes.size()), poolSizes.data(), 2); @@ -961,7 +960,7 @@ public: VkDescriptorSetLayoutCreateInfo descriptorLayout = vkTools::initializers::descriptorSetLayoutCreateInfo( setLayoutBindings.data(), - setLayoutBindings.size()); + static_cast(setLayoutBindings.size())); VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &descriptorSetLayout)); @@ -1008,7 +1007,7 @@ public: 1, &texDescriptor)); - vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL); + vkUpdateDescriptorSets(device, static_cast(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, NULL); // Cube VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &allocInfo, &descriptorSets.cube)); @@ -1016,7 +1015,7 @@ public: texDescriptor.imageView = textures.cube.view; writeDescriptorSets[0].dstSet = descriptorSets.cube; writeDescriptorSets[1].dstSet = descriptorSets.cube; - vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL); + vkUpdateDescriptorSets(device, static_cast(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, NULL); } void preparePipelines() @@ -1065,7 +1064,7 @@ public: VkPipelineDynamicStateCreateInfo dynamicState = vkTools::initializers::pipelineDynamicStateCreateInfo( dynamicStateEnables.data(), - dynamicStateEnables.size(), + static_cast(dynamicStateEnables.size()), 0); // Wire frame rendering pipeline @@ -1088,7 +1087,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/textoverlay/textoverlay.vcxproj b/textoverlay/textoverlay.vcxproj index 31aae5c5..86615983 100644 --- a/textoverlay/textoverlay.vcxproj +++ b/textoverlay/textoverlay.vcxproj @@ -54,6 +54,7 @@ Disabled true /FS %(AdditionalOptions) + Level3 ..\libs\vulkan\vulkan-1.lib;..\libs\assimp\assimp.lib;%(AdditionalDependencies)