1 #ifndef PRIMITIVEBATCH_H_INCLUDED
2 #define PRIMITIVEBATCH_H_INCLUDED
4 #include "nta/SpriteBatch.h"
11 Primitive(
const std::initializer_list<Vertex2D>& verts,
15 template<
class Iterator>
20 Primitive(std::size_t numSides, crvec2 center,
float sideLength,
21 crvec4 color,
float orientation,
float d) :
depth(d),
textureID(0) {
22 std::vector<Vertex2D> verts;
23 float theta = 2.*M_PI/numSides;
24 float a = sideLength/glm::sqrt(2.-2.*glm::cos(theta));
25 for (std::size_t i = 0; i < numSides; i++) {
26 float angle = i*theta + orientation;
27 glm::vec2 translate(glm::cos(angle), glm::sin(angle));
28 verts.emplace_back(a * translate + center, color);
82 void addPrimitive(
const std::initializer_list<Vertex2D>& vertices,
83 GLuint textureID = -1,
float depth = NTA_DEFAULT_DEPTH);
84 template<
class Iterator>
85 void addPrimitive(Iterator first, Iterator last, GLuint textureID = -1,
86 float depth = NTA_DEFAULT_DEPTH);
87 void addPrimitive(std::size_t numSides, crvec2 center = glm::vec2(0),
float sideLength = 1.0,
88 crvec4 color = glm::vec4(1),
float orientation = 0.,
89 float depth = NTA_DEFAULT_DEPTH);
95 template<
class Iterator>
101 #endif // PRIMITIVEBATCH_H_INCLUDED