39 lines
853 B
C++
39 lines
853 B
C++
#ifndef __BATCH_H__
|
|
#define __BATCH_H__
|
|
|
|
#include <gearlib.h>
|
|
#include <vector>
|
|
|
|
typedef struct BatchStats {
|
|
uint32_t draw_calls;
|
|
uint32_t total_verts;
|
|
} BatchStats;
|
|
|
|
typedef struct RenderBatch {
|
|
uint32_t vbo, vao;
|
|
|
|
uint32_t shader;
|
|
|
|
void* vertices;
|
|
void* vertex_ptr;
|
|
size_t vertex_size;
|
|
uint32_t vertex_count;
|
|
uint32_t max_vertices;
|
|
std::vector<VertexAttrib> layout;
|
|
|
|
BatchStats stats;
|
|
|
|
void* data;
|
|
void (*flush_callback)(struct RenderBatch*);
|
|
} RenderBatch;
|
|
|
|
extern std::vector<RenderBatch*> batches;
|
|
|
|
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
|