VertexArray.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. private:
  25. // How many vertices in the vertex buffer?
  26. unsigned int mNumVerts;
  27. // How many indices in the index buffer
  28. unsigned int mNumIndices;
  29. // OpenGL ID of the vertex buffer
  30. unsigned int mVertexBuffer;
  31. // OpenGL ID of the index buffer
  32. unsigned int mIndexBuffer;
  33. // OpenGL ID of the vertex array object
  34. unsigned int mVertexArray;
  35. };