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.

chunkrenderer.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * =====================================================================================
  3. *
  4. * Filename: chunkrenderer.h
  5. *
  6. * Description:
  7. *
  8. * Version: 1.0
  9. * Created: 04/04/2014 11:11:43 PM
  10. * Revision: none
  11. * Compiler: gcc
  12. *
  13. * Author: YOUR NAME (),
  14. * Organization:
  15. *
  16. * =====================================================================================
  17. */
  18. #pragma once
  19. #include "voxelutils.h"
  20. #include <array>
  21. #include <vector>
  22. #include <atomic>
  23. namespace vtk {
  24. class Chunk;
  25. class ChunkRenderer {
  26. public:
  27. void init();
  28. void drawChunk();
  29. void setChunkPosition(const int&x, const int& y, const int&z);
  30. void updateGeometry();
  31. void updateTexCoords();
  32. void updateLighting();
  33. void updateVertexData();
  34. Chunk* linkedChunk;
  35. protected:
  36. /*
  37. Info I need to reference:
  38. 0 = X+
  39. 1 = X-
  40. 2 = y+
  41. 3 = Y-
  42. 4 = Z+
  43. 5 = Z-
  44. */
  45. bool initialized;
  46. iPos chunkPos;
  47. float voxelSize;
  48. unsigned chunkSize;
  49. unsigned lightingMethod; // 0 = fullbright, 1 = blocky, 2 = smooth
  50. bool updatingGeometry; //Is geometry actively updating (for threading)
  51. //set to true after their respective update function is called
  52. bool hasGeometryChanged;
  53. bool hasTexturesChanged;
  54. bool hasLightingChanged;
  55. std::array<unsigned, 6> faceCounts;
  56. std::array<unsigned, 6> vertexCounts;
  57. std::array<std::vector<float>, 6> geometryVertices; //Holds geometry vertices as x,y,z,x,y,z...
  58. std::array<std::vector<float>, 6> textureCoords; //Holds texture coords as u,v,i,u,v,i...
  59. std::array<std::vector<float>, 6> lightingData; //Holds lighting data as r,g,b,r,g,b...
  60. std::array<std::array <unsigned, 3>, 6> vertexBuffers;//VBOs
  61. std::array<unsigned, 6> vertexArrays; //VAOs
  62. //add vertex to a vector of floats. Used for code cleanliness and flexibility
  63. void addVertex(std::vector<float>& data, const float& x, const float& y, const float& z);
  64. };
  65. }