jubilant-funicular
DebugBatch.h
1 #ifndef NTA_DEBUGBATCH_H_INCLUDED
2 #define NTA_DEBUGBATCH_H_INCLUDED
3 
4 #include <GL/glew.h>
5 #include <vector>
6 
7 #include "nta/Vertex.h"
8 
9 namespace nta {
10  // \todo Make abstract RenderBatch class for this, SpriteBatch, and PrimitiveBatch
12  class DebugBatch {
13  private:
14  std::vector<Vertex2D> m_vertices;
15  std::vector<GLuint> m_indices;
16  GLuint m_vao = 0;
17  GLuint m_vbo = 0;
18  GLuint m_ibo = 0;
19  public:
21  DebugBatch();
22  ~DebugBatch();
24  void init();
26  void begin();
28  void end();
29  // \todo Learn how to have doxygen use one comment for multiple functions
31  void addLine(crvec2 start, crvec2 end, crvec4 color = glm::vec4(1), int num_pieces = 2);
32  void addLine(crvec2 start, crvec2 end, int num_pieces, crvec4 color = glm::vec4(1));
33  void addRect(crvec4 posRect, crvec4 color = glm::vec4(1), float orientation = 0);
34  void addRect(crvec4 posRect, float orientation, crvec4 color = glm::vec4(1));
35  void addCircle(crvec2 center, float radius, crvec4 color = glm::vec4(1));
36  void addPolygon(std::size_t numSides, crvec2 center, float sideLength, float orientation,
37  crvec4 color = glm::vec4(1));
39  void render() const;
40  };
41 }
42 
43 #endif // NTA_DEBUGBATCH_H_INCLUDED
nta::DebugBatch::render
void render() const
renders the batch
Definition: DebugBatch.cpp:106
nta::DebugBatch
A collection of debug primitives (outlines of shapes) to be drawn.
Definition: DebugBatch.h:12
nta
Definition: Animation2D.h:6
nta::DebugBatch::DebugBatch
DebugBatch()
Constructor. Doesn't actually do anything; use init() to initialize instead.
Definition: DebugBatch.cpp:6
nta::DebugBatch::init
void init()
initializes the batch (only needs to be called once)
Definition: DebugBatch.cpp:17
nta::DebugBatch::addLine
void addLine(crvec2 start, crvec2 end, crvec4 color=glm::vec4(1), int num_pieces=2)
Adds a shape to the batch.
Definition: DebugBatch.cpp:50
nta::DebugBatch::end
void end()
ends collecting shapes
Definition: DebugBatch.cpp:39
nta::DebugBatch::begin
void begin()
begins collecting shapes to be drawn
Definition: DebugBatch.cpp:35