From c8cea7bf454ca57dc35895f579e137d4aad34361 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Thu, 11 Mar 2021 16:52:47 +0100 Subject: [PATCH] Give native types initial value --- inferno/src/inferno/render/buffer.cpp | 4 +--- inferno/src/inferno/render/buffer.h | 16 ++++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/inferno/src/inferno/render/buffer.cpp b/inferno/src/inferno/render/buffer.cpp index 3e5ac35..8a6db3d 100644 --- a/inferno/src/inferno/render/buffer.cpp +++ b/inferno/src/inferno/render/buffer.cpp @@ -13,7 +13,6 @@ namespace Inferno { m_type(type), m_name(name), m_size(BufferElement::getTypeSize(type)), - m_offset(0), m_normalized(normalized) { } @@ -144,14 +143,13 @@ namespace Inferno { // ----------------------------------------- BufferLayout::BufferLayout(const std::initializer_list& elements) - : m_elements(elements), m_stride(0) + : m_elements(elements) { calculateOffsetsAndStride(); } void BufferLayout::calculateOffsetsAndStride() { - m_stride = 0; for (auto& element : m_elements) { element.setOffset(m_stride); m_stride += element.getSize(); diff --git a/inferno/src/inferno/render/buffer.h b/inferno/src/inferno/render/buffer.h index abd43e3..a339c7d 100644 --- a/inferno/src/inferno/render/buffer.h +++ b/inferno/src/inferno/render/buffer.h @@ -50,9 +50,9 @@ namespace Inferno { private: BufferElementType m_type; std::string m_name; - uint32_t m_size; - uint32_t m_offset; - bool m_normalized; + uint32_t m_size { 0 }; + uint32_t m_offset { 0 }; + bool m_normalized { false }; }; // ----------------------------------------- @@ -77,7 +77,7 @@ namespace Inferno { private: std::vector m_elements; - uint32_t m_stride; + uint32_t m_stride { 0 }; }; // ----------------------------------------- @@ -99,7 +99,7 @@ namespace Inferno { inline void setLayout(const BufferLayout& layout) { m_layout = layout; } private: - uint32_t m_id; + uint32_t m_id { 0 }; BufferLayout m_layout; }; @@ -117,8 +117,8 @@ namespace Inferno { inline uint32_t getCount() const { return m_count; } private: - uint32_t m_id; - uint32_t m_count; + uint32_t m_id { 0 }; + uint32_t m_count { 0 }; }; // ----------------------------------------- @@ -139,7 +139,7 @@ namespace Inferno { inline std::shared_ptr getIndexBuffer() const { return m_indexBuffer; } private: - uint32_t m_id; + uint32_t m_id { 0 }; std::vector> m_vertexBuffers; std::shared_ptr m_indexBuffer; };