You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

chunkmesh.h 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include <memory>
  3. #include <glm/glm.hpp>
  4. #include <vector>
  5. #include "graphics/voxelmodel.h"
  6. namespace vtk {
  7. class World;
  8. class ChunkMesh {
  9. public:
  10. ChunkMesh(World& world, glm::ivec3 linkedChunkPos);
  11. bool rebuildChunkGeometry();
  12. void rebuildChunkLighting();
  13. void draw();
  14. bool updateGeometry(); //puts the geometry into the VBOs because OGL can't into threading
  15. protected:
  16. //position of chunk since chunk does NOT have to exist to rebuild
  17. //if chunk is not loaded, rebuild will fail silently
  18. //this is useful for allowing you to unload distant chunks but still draw them
  19. //it's also faster to look up adjacent chunk positions when you have the position
  20. glm::ivec3 mLinkedChunkPos;
  21. World& mLinkedWorld;
  22. std::vector<float> geometry;
  23. std::vector<unsigned> mGeometry;
  24. std::vector<unsigned> mFaceAttribs;
  25. std::vector<unsigned short> mLighting;
  26. bool mLocked;
  27. bool mUpdated;
  28. unsigned mVAO;
  29. unsigned mGeometryTexVBO;
  30. unsigned mLightVBO;
  31. unsigned mFaceAttribsVBO;
  32. int mFaceCount;
  33. int mGeometryFaceCount;
  34. VoxelModel mVoxelModel;
  35. };
  36. }