From ab30228b1a57053323363674fa7f137c0329a180 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Tue, 7 Jul 2020 23:12:04 -0300 Subject: Voltage heat map implemented Voltage heat map implemented using modern OpenGL =) New external library required: -GLEW -GLFW -GLM (incorporeted at the source) Old memory leaks fixed =) --- Project/VertexBufferLayout.h | 72 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Project/VertexBufferLayout.h (limited to 'Project/VertexBufferLayout.h') diff --git a/Project/VertexBufferLayout.h b/Project/VertexBufferLayout.h new file mode 100644 index 0000000..d50b19c --- /dev/null +++ b/Project/VertexBufferLayout.h @@ -0,0 +1,72 @@ +#ifndef VERTEXBUFFERLAYOUT_H +#define VERTEXBUFFERLAYOUT_H + +#include +#include + +#include "Renderer.h" + +struct VertexBufferElement +{ + unsigned int type; + unsigned int count; + unsigned char normalized; + + static unsigned int GetSizeOfType(unsigned int type) + { + switch (type) + { + case GL_FLOAT: return 4; + case GL_UNSIGNED_INT: return 4; + case GL_UNSIGNED_BYTE: return 1; + default: break; + } + ASSERT(false); + return(0); + } +}; + +class VertexBufferLayout +{ +public: + VertexBufferLayout() + : m_stride(0) {} + ~VertexBufferLayout() {} + + + template + void Push(unsigned int count) + { + static_assert(false); + } + + template<> + void Push(unsigned int count) + { + m_elements.push_back({ GL_FLOAT, count, GL_FALSE }); + m_stride += count * VertexBufferElement::GetSizeOfType(GL_FLOAT); + } + + template<> + void Push(unsigned int count) + { + m_elements.push_back({ GL_UNSIGNED_INT, count, GL_FALSE }); + m_stride += count * VertexBufferElement::GetSizeOfType(GL_UNSIGNED_INT); + } + + template<> + void Push(unsigned int count) + { + m_elements.push_back({ GL_UNSIGNED_BYTE, count, GL_TRUE }); + m_stride += count * VertexBufferElement::GetSizeOfType(GL_UNSIGNED_BYTE); + } + + inline const std::vector GetElements() const& { return m_elements; } + inline unsigned int GetStride() const& { return m_stride; } + +private: + std::vector m_elements; + unsigned int m_stride; +}; + +#endif // VERTEXBUFFERLAYOUT_H -- cgit