40 lines
852 B
C
40 lines
852 B
C
|
#ifndef __BATCH_H__
|
||
|
#define __BATCH_H__
|
||
|
|
||
|
#include <stddef.h>
|
||
|
#include <stdint.h>
|
||
|
#include <stdbool.h>
|
||
|
|
||
|
#include <gearlib.h>
|
||
|
|
||
|
typedef struct BatchStats {
|
||
|
uint32_t draw_calls;
|
||
|
uint32_t total_verts;
|
||
|
} BatchStats;
|
||
|
|
||
|
typedef struct RenderBatch {
|
||
|
uint32_t vbo;
|
||
|
uint32_t vao;
|
||
|
uint32_t shader;
|
||
|
void* vertices;
|
||
|
void* vertex_ptr;
|
||
|
size_t vertex_size;
|
||
|
uint32_t vertex_count;
|
||
|
uint32_t max_vertices;
|
||
|
VertexLayout layout;
|
||
|
|
||
|
BatchStats stats;
|
||
|
|
||
|
void* data;
|
||
|
void (*flush_callback)(struct RenderBatch*);
|
||
|
} RenderBatch;
|
||
|
|
||
|
RenderBatch* create_batch(size_t vert_size, uint32_t max_verts);
|
||
|
void flush();
|
||
|
void flush_batch(RenderBatch* batch);
|
||
|
void batch_add_attrib(RenderBatch* batch, VertexAttrib attr);
|
||
|
void batch_bind_attribs(RenderBatch* batch);
|
||
|
bool batch_needs_flush(RenderBatch* batch, uint32_t vertex_add);
|
||
|
|
||
|
#endif
|