2
0

VertexArray.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. class VertexArray
  10. {
  11. public:
  12. // Different supported vertex layouts
  13. enum Layout
  14. {
  15. PosNormTex,
  16. PosNormSkinTex
  17. };
  18. VertexArray(const void* verts, unsigned int numVerts, Layout layout,
  19. const unsigned int* indices, unsigned int numIndices);
  20. ~VertexArray();
  21. void SetActive();
  22. unsigned int GetNumIndices() const { return mNumIndices; }
  23. unsigned int GetNumVerts() const { return mNumVerts; }
  24. static unsigned int GetVertexSize(VertexArray::Layout layout);
  25. private:
  26. // How many vertices in the vertex buffer?
  27. unsigned int mNumVerts;
  28. // How many indices in the index buffer
  29. unsigned int mNumIndices;
  30. // OpenGL ID of the vertex buffer
  31. unsigned int mVertexBuffer;
  32. // OpenGL ID of the index buffer
  33. unsigned int mIndexBuffer;
  34. // OpenGL ID of the vertex array object
  35. unsigned int mVertexArray;
  36. };