remove indirection in vertex builder
This commit is contained in:
@ -101,14 +101,15 @@ size_t get_quad_payload_size(struct QuadBatch batch) {
|
||||
}
|
||||
|
||||
|
||||
bool push_quad_payload_to_vertex_buffer_builder(struct QuadBatch batch,
|
||||
void push_quad_payload_to_vertex_buffer_builder(struct QuadBatch batch,
|
||||
size_t index,
|
||||
VertexBufferBuilder *builder,
|
||||
Vec2 v0, Vec2 v1, Vec2 v2, Vec2 v3,
|
||||
Vec2 uv0, Vec2 uv1, Vec2 uv2, Vec2 uv3,
|
||||
Color color)
|
||||
{
|
||||
if (!batch.constant_colored && batch.textured) {
|
||||
ElementIndexedQuad const buffer_element = {
|
||||
ElementIndexedQuad const payload = {
|
||||
.v0 = v0,
|
||||
.v1 = v1,
|
||||
.v2 = v2,
|
||||
@ -126,10 +127,10 @@ bool push_quad_payload_to_vertex_buffer_builder(struct QuadBatch batch,
|
||||
// .c3 = color,
|
||||
};
|
||||
|
||||
return push_to_vertex_buffer_builder(builder, &buffer_element, sizeof buffer_element);
|
||||
((ElementIndexedQuad *)builder->base)[index] = payload;
|
||||
|
||||
} else if (batch.constant_colored && batch.textured) {
|
||||
ElementIndexedQuadWithoutColor const buffer_element = {
|
||||
ElementIndexedQuadWithoutColor const payload = {
|
||||
.v0 = v0,
|
||||
.v1 = v1,
|
||||
.v2 = v2,
|
||||
@ -141,10 +142,10 @@ bool push_quad_payload_to_vertex_buffer_builder(struct QuadBatch batch,
|
||||
.uv3 = uv3,
|
||||
};
|
||||
|
||||
return push_to_vertex_buffer_builder(builder, &buffer_element, sizeof buffer_element);
|
||||
((ElementIndexedQuadWithoutColor *)builder->base)[index] = payload;
|
||||
|
||||
} else if (!batch.constant_colored && !batch.textured) {
|
||||
ElementIndexedQuadWithoutTexture const buffer_element = {
|
||||
ElementIndexedQuadWithoutTexture const payload = {
|
||||
.v0 = v0,
|
||||
.v1 = v1,
|
||||
.v2 = v2,
|
||||
@ -157,19 +158,18 @@ bool push_quad_payload_to_vertex_buffer_builder(struct QuadBatch batch,
|
||||
// .c3 = color,
|
||||
};
|
||||
|
||||
return push_to_vertex_buffer_builder(builder, &buffer_element, sizeof buffer_element);
|
||||
((ElementIndexedQuadWithoutTexture *)builder->base)[index] = payload;
|
||||
|
||||
} else if (batch.constant_colored && !batch.textured) {
|
||||
ElementIndexedQuadWithoutColorWithoutTexture const buffer_element = {
|
||||
ElementIndexedQuadWithoutColorWithoutTexture const payload = {
|
||||
.v0 = v0,
|
||||
.v1 = v1,
|
||||
.v2 = v2,
|
||||
.v3 = v3,
|
||||
};
|
||||
|
||||
return push_to_vertex_buffer_builder(builder, &buffer_element, sizeof buffer_element);
|
||||
((ElementIndexedQuadWithoutColorWithoutTexture *)builder->base)[index] = payload;
|
||||
}
|
||||
|
||||
SDL_assert(false);
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user