MeshBatchSample.h 943 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef MESHBATCHSAMPLE_H_
  2. #define MESHBATCHSAMPLE_H_
  3. #include "gameplay.h"
  4. #include "Sample.h"
  5. using namespace gameplay;
  6. /**
  7. * Sample drawing static mesh geometry using MeshBatch.
  8. */
  9. class MeshBatchSample : public Sample
  10. {
  11. public:
  12. MeshBatchSample();
  13. void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
  14. protected:
  15. void initialize();
  16. void finalize();
  17. void update(float elapsedTime);
  18. void render(float elapsedTime);
  19. private:
  20. void addTriangle(int x, int y);
  21. struct Vertex
  22. {
  23. Vector3 position;
  24. Vector3 color;
  25. Vertex() { }
  26. Vertex(const Vector3& position, const Vector3& color) : position(position), color(color) { }
  27. };
  28. Font* _font;
  29. MeshBatch* _meshBatch;
  30. Matrix _worldViewProjectionMatrix;
  31. std::vector<Vertex> _vertices;
  32. double _lastTriangleAdded;
  33. };
  34. #endif