Browse Source

Give native types initial value

master
Riyyi 3 years ago
parent
commit
c8cea7bf45
  1. 4
      inferno/src/inferno/render/buffer.cpp
  2. 16
      inferno/src/inferno/render/buffer.h

4
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<BufferElement>& 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();

16
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<BufferElement> 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<IndexBuffer> getIndexBuffer() const { return m_indexBuffer; }
private:
uint32_t m_id;
uint32_t m_id { 0 };
std::vector<std::shared_ptr<VertexBuffer>> m_vertexBuffers;
std::shared_ptr<IndexBuffer> m_indexBuffer;
};

Loading…
Cancel
Save