11 constexpr
int stride = 2 * 4 + 2 * 4 + 4 * 4;
27 ASSERT(!is_inside &&
"Already open, missing call to end.");
28 number_of_render_calls = 0;
39 const Angle& rotation,
43 ASSERT(is_inside &&
"batch need to be open");
51 const float w = quad.
width;
52 const float h = quad.
height;
53 const float sy = -
sin(rotation);
54 const float left = pos.
x + (-center.x * w) * sy;
55 const float right = pos.
x + (-center.x * w + w) * sy;
56 const float top = pos.
y + (-center.y * h) * sy;
57 const float bottom = pos.
y + (-center.y * h + h) * sy;
58 const auto upper_left =
vec2f(left, top);
59 const auto upper_right =
vec2f(right, top);
60 const auto lower_left =
vec2f(left, bottom);
61 const auto lower_right =
vec2f(right, bottom);
63 vertex_data.push_back(upper_left.x);
64 vertex_data.push_back(upper_left.y);
66 vertex_data.push_back(upper_right.x);
67 vertex_data.push_back(upper_right.y);
69 vertex_data.push_back(lower_right.x);
70 vertex_data.push_back(lower_right.y);
72 vertex_data.push_back(lower_left.x);
73 vertex_data.push_back(lower_left.y);
76 vertex_data.push_back(
uv.left);
77 vertex_data.push_back(
uv.top);
78 vertex_data.push_back(
uv.right);
79 vertex_data.push_back(
uv.top);
80 vertex_data.push_back(
uv.right);
81 vertex_data.push_back(
uv.bottom);
82 vertex_data.push_back(
uv.left);
83 vertex_data.push_back(
uv.bottom);
86 for(
int color_counter = 0; color_counter < 4; color_counter += 1)
88 vertex_data.push_back(color.r);
89 vertex_data.push_back(color.g);
90 vertex_data.push_back(color.b);
91 vertex_data.push_back(color.a);
95 int start = current_quad_count * 4;
97 quad_indices.push_back(start + 0);
98 quad_indices.push_back(start + 1);
99 quad_indices.push_back(start + 2);
101 quad_indices.push_back(start + 0);
102 quad_indices.push_back(start + 2);
103 quad_indices.push_back(start + 3);
105 current_quad_count += 1;
112 ASSERT(is_inside &&
"not open, missing begin.");
121 if(current_quad_count == 0)
127 current_quad_count = 0;
128 vertex_data.resize(0);
129 number_of_render_calls += 1;
size_t c_int_to_sizet(int i)
float sin(const Angle &ang)
void render_quad(const vec2f &pos, const size2f &quad, const Rectf &uv, const Scale2f ¢er, const Angle &rotation, const Rgba &color)