Advertisement
Guest User

Untitled

a guest
May 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "Aster/Math/math.h"
  4.  
  5. namespace Aster {
  6.  
  7.     struct ASTER_API BufferElement
  8.     {
  9.         std::string name;
  10.         uint type;
  11.         uint size;
  12.         uint count;
  13.         uint offset;
  14.         bool normalized;
  15.     };
  16.  
  17.     class ASTER_API BufferLayout
  18.     {
  19.     public:
  20.         BufferLayout();
  21.  
  22.         template<typename T>
  23.         void Push(const std::string& name, uint count = 1, bool normalized = false)
  24.         {
  25.             AT_CORE_ASSERT(false, "Unknown type");
  26.         };
  27.  
  28.         template<>
  29.         virtual void Push<float>(const std::string& name, uint count, bool normalized) = 0;
  30.  
  31.         template<>
  32.         virtual void Push<uint>(const std::string& name, uint count, bool normalized) = 0;
  33.  
  34.         template<>
  35.         virtual void Push<byte>(const std::string& name, uint count, bool normalized) = 0;
  36.  
  37.         template<>
  38.         virtual void Push<math::vec2>(const std::string& name, uint count, bool normalized) = 0;
  39.  
  40.         template<>
  41.         virtual void Push<math::vec3>(const std::string& name, uint count, bool normalized) = 0;
  42.  
  43.         template<>
  44.         virtual void Push<math::vec4>(const std::string& name, uint count, bool normalized) = 0;
  45.  
  46.         inline const std::vector<BufferElement>& GetLayout() const { return m_Layout; }
  47.         inline uint GetStride() const { return m_Size; }
  48.  
  49.     protected:
  50.         void Push(const std::string& name, uint type, uint size, uint count, bool normalized);
  51.  
  52.     protected:
  53.         uint m_Size;
  54.         std::vector<BufferElement> m_Layout;
  55.     };
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement