diff --git a/base/VulkanSwapChain.h b/base/VulkanSwapChain.h index bbd951da..03c69010 100644 --- a/base/VulkanSwapChain.h +++ b/base/VulkanSwapChain.h @@ -28,25 +28,25 @@ #endif typedef struct _SwapChainBuffers { - VkImage image; - VkImageView view; + VkImage image{ VK_NULL_HANDLE }; + VkImageView view{ VK_NULL_HANDLE }; } SwapChainBuffer; class VulkanSwapChain { private: - VkInstance instance; - VkDevice device; - VkPhysicalDevice physicalDevice; - VkSurfaceKHR surface; + VkInstance instance{ VK_NULL_HANDLE }; + VkDevice device{ VK_NULL_HANDLE }; + VkPhysicalDevice physicalDevice{ VK_NULL_HANDLE }; + VkSurfaceKHR surface{ VK_NULL_HANDLE }; public: - VkFormat colorFormat; - VkColorSpaceKHR colorSpace; - VkSwapchainKHR swapChain = VK_NULL_HANDLE; + VkFormat colorFormat{}; + VkColorSpaceKHR colorSpace{}; + VkSwapchainKHR swapChain{ VK_NULL_HANDLE }; uint32_t imageCount; - std::vector images; - std::vector buffers; - uint32_t queueNodeIndex = UINT32_MAX; + std::vector images{}; + std::vector buffers{}; + uint32_t queueNodeIndex{ UINT32_MAX }; #if defined(VK_USE_PLATFORM_WIN32_KHR) void initSurface(void* platformHandle, void* platformWindow); diff --git a/base/benchmark.hpp b/base/benchmark.hpp index b7f00558..9d742968 100644 --- a/base/benchmark.hpp +++ b/base/benchmark.hpp @@ -1,7 +1,7 @@ /* -* Benchmark class +* Benchmark class - Can be used for automated benchmarks * -* Copyright (C) 2016-2017 by Sascha Willems - www.saschawillems.de +* Copyright (C) 2016-2024 by Sascha Willems - www.saschawillems.de * * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) */ @@ -18,8 +18,8 @@ namespace vks { class Benchmark { private: - FILE *stream; - VkPhysicalDeviceProperties deviceProps; + FILE* stream{ nullptr }; + VkPhysicalDeviceProperties deviceProps{}; public: bool active = false; bool outputFrameTimes = false; diff --git a/base/camera.hpp b/base/camera.hpp index c13966a4..4838bde2 100644 --- a/base/camera.hpp +++ b/base/camera.hpp @@ -1,7 +1,7 @@ /* -* Basic camera class +* Basic camera class providing a look-at and first-person camera * -* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de +* Copyright (C) 2016-2024 by Sascha Willems - www.saschawillems.de * * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) */ @@ -78,16 +78,16 @@ public: bool down = false; } keys; - bool moving() + bool moving() const { return keys.left || keys.right || keys.up || keys.down; } - float getNearClip() { + float getNearClip() const { return znear; } - float getFarClip() { + float getFarClip() const { return zfar; } diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 2564252a..70184070 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -167,7 +167,7 @@ void VulkanExampleBase::renderFrame() VulkanExampleBase::submitFrame(); } -std::string VulkanExampleBase::getWindowTitle() +std::string VulkanExampleBase::getWindowTitle() const { std::string windowTitle{ title + " - " + deviceProperties.deviceName }; if (!settings.overlay) { @@ -1160,7 +1160,7 @@ HWND VulkanExampleBase::setupWindow(HINSTANCE hinstance, WNDPROC wndproc) { this->windowInstance = hinstance; - WNDCLASSEX wndClass; + WNDCLASSEX wndClass{}; wndClass.cbSize = sizeof(WNDCLASSEX); wndClass.style = CS_HREDRAW | CS_VREDRAW; @@ -3076,26 +3076,23 @@ void VulkanExampleBase::setupDepthStencil() void VulkanExampleBase::setupFrameBuffer() { - VkImageView attachments[2]; - - // Depth/Stencil attachment is the same for all frame buffers - attachments[1] = depthStencil.view; - - VkFramebufferCreateInfo frameBufferCreateInfo = {}; - frameBufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - frameBufferCreateInfo.pNext = NULL; - frameBufferCreateInfo.renderPass = renderPass; - frameBufferCreateInfo.attachmentCount = 2; - frameBufferCreateInfo.pAttachments = attachments; - frameBufferCreateInfo.width = width; - frameBufferCreateInfo.height = height; - frameBufferCreateInfo.layers = 1; - // Create frame buffers for every swap chain image frameBuffers.resize(swapChain.imageCount); for (uint32_t i = 0; i < frameBuffers.size(); i++) { - attachments[0] = swapChain.buffers[i].view; + const VkImageView attachments[2] = { + swapChain.buffers[i].view, + // Depth/Stencil attachment is the same for all frame buffers + depthStencil.view + }; + VkFramebufferCreateInfo frameBufferCreateInfo{}; + frameBufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; + frameBufferCreateInfo.renderPass = renderPass; + frameBufferCreateInfo.attachmentCount = 2; + frameBufferCreateInfo.pAttachments = attachments; + frameBufferCreateInfo.width = width; + frameBufferCreateInfo.height = height; + frameBufferCreateInfo.layers = 1; VK_CHECK_RESULT(vkCreateFramebuffer(device, &frameBufferCreateInfo, nullptr, &frameBuffers[i])); } } @@ -3142,7 +3139,7 @@ void VulkanExampleBase::setupRenderPass() subpassDescription.pResolveAttachments = nullptr; // Subpass dependencies for layout transitions - std::array dependencies; + std::array dependencies{}; dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL; dependencies[0].dstSubpass = 0; diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index d4355dc3..8901808a 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -76,7 +76,7 @@ class VulkanExampleBase { private: - std::string getWindowTitle(); + std::string getWindowTitle() const; uint32_t destWidth; uint32_t destHeight; bool resizing = false;