fix mixing up of SDL and libc allocators, proper flushing of quad build buffers
This commit is contained in:
@ -43,7 +43,7 @@ typedef struct {
|
||||
TextureKey texture_key;
|
||||
GPUTexture gpu_texture;
|
||||
|
||||
/* could be either `element_count` with supplied `element_buffer`, or this, but not both */
|
||||
/* could be either `element_count` with supplied `element_buffer`, or `primitive_count`, but not both */
|
||||
uint32_t primitive_count;
|
||||
uint32_t element_buffer;
|
||||
uint32_t element_count;
|
||||
|
@ -229,7 +229,8 @@ VertexBufferBuilder build_vertex_buffer(VertexBuffer buffer, size_t bytes) {
|
||||
|
||||
|
||||
void finish_vertex_builder(VertexBufferBuilder *builder) {
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
if (!glUnmapBuffer(GL_ARRAY_BUFFER))
|
||||
CRY("finish_vertex_builder", "Error unmapping a vertex array buffer");
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
builder->base = 0;
|
||||
|
@ -31,6 +31,7 @@ void delete_vertex_buffer(VertexBuffer buffer) {
|
||||
void specify_vertex_buffer(VertexBuffer buffer, void const *data, size_t bytes) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, bytes, data, GL_STREAM_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,6 +90,8 @@ void render_rect_batch(const Primitive2D primitives[],
|
||||
(Vec2){0}, (Vec2){0}, (Vec2){0}, (Vec2){0},
|
||||
rect.color);
|
||||
}
|
||||
|
||||
finish_vertex_builder(&payload);
|
||||
}
|
||||
|
||||
finally_render_quads(primitives, batch, vertex_array);
|
||||
|
@ -244,6 +244,8 @@ void render_sprite_batch(const Primitive2D primitives[],
|
||||
|
||||
push_quad_payload_to_vertex_buffer_builder(batch, i, &payload, v0, v1, v2, v3, uv0, uv1, uv2, uv3, sprite.color);
|
||||
}
|
||||
|
||||
finish_vertex_builder(&payload);
|
||||
}
|
||||
|
||||
finally_render_quads(primitives, batch, vertex_array);
|
||||
|
@ -11,6 +11,10 @@
|
||||
#define MAX SDL_max
|
||||
#define MIN SDL_min
|
||||
|
||||
void *cmalloc(size_t size);
|
||||
void *crealloc(void *ptr, size_t size);
|
||||
void *ccalloc(size_t num, size_t size);
|
||||
|
||||
void cry_impl(const char *file, const int line, const char *title, const char *text);
|
||||
#define CRY(title, text) cry_impl(__FILE__, __LINE__, title, text)
|
||||
#define CRY_SDL(title) cry_impl(__FILE__, __LINE__, title, SDL_GetError())
|
||||
|
Reference in New Issue
Block a user