#ifndef __MICRO_RENDERER_H__ #define __MICRO_RENDERER_H__ #include "common.h" #include "mat4.h" #include "tex.h" #define MAX_BOUND_TEX 16 enum blend_mode { BLEND_ALPHA, BLEND_ADD, }; struct color { float r; float g; float b; float a; }; struct vec3 { float x; float y; float z; }; struct vec2 { float x; float y; }; struct vertex { struct vec3 xyz; struct vec2 uv; struct color col; }; struct draw_call { struct texture textures[MAX_BOUND_TEX]; int next_tex_bind; int cur_tex_bind; int mesh_start; int vert_count; enum blend_mode blend_mode; struct vec3 *xyz; struct vec2 *uv; struct color *col; int *tex; u16 *indices; }; struct renderer { struct ctx *ctx; struct texture white_1x1; struct draw_call dc; struct color cur_col; u32 shader_program; mat4 projection; }; void init_renderer(struct renderer *r, struct ctx *ctx); void deinit_renderer(struct renderer *r); void flush_pending(struct renderer *r); void draw_clear(struct color col); void draw_rect(struct renderer *r, float x, float y, float w, float h); void draw_texture(struct renderer *r, struct texture tex, float x, float y); void set_blend_mode(struct renderer *r, enum blend_mode mode); // NULL to unbind void bind_render_texture(struct renderer *r, struct render_texture *rtex); void end_draw(struct renderer *r); #endif // __MICRO_RENDERER_H__