1#ifndef RENDERER_H
2#define RENDERER_H
3
4#include "types.h"
5#include "mgmath.h"
6#include "platform/platform.h"
7
8typedef u32 MGMesh;
9#define MGMESH_INVALID ((MGMesh)0)
10
11typedef u32 MGTexture;
12#define MGTEXTURE_INVALID ((MGTexture)0)
13
14typedef struct {
15 const u8* pixels;
16 i32 width;
17 i32 height;
18} MGTextureDesc;
19
20typedef struct {
21 float x;
22 float y;
23 float z;
24
25 float u;
26 float v;
27
28 u32 col;
29} MGVertex;
30
31typedef struct {
32 const MGVertex* vtc; /* vertices */
33 u32 vtcc; /* vertices count */
34 const u16* idc; /* indecies */
35 u32 idcc; /* indecies count */
36} MGMeshDesc;
37
38/* create renderer with chosen context
39 (just GL for now) */
40void renderer_create(MGContext* ctx);
41
42/* start drawing to screen */
43void renderer_begin(void);
44
45/* finish drawing to screen */
46void renderer_end(void);
47
48/* destroy renderer resources */
49void renderer_destroy(void);
50
51/* create mesh from descriptor */
52MGMesh renderer_mesh_create(const MGMeshDesc* desc);
53
54/* draws mesh using specified texture and mat */
55void renderer_mesh_draw(MGMesh mesh, MGTexture texture, const MGMat4* mvp);
56
57/* destroy mesh */
58void renderer_mesh_destroy(MGMesh id);
59
60/* load texture from file */
61MGTexture renderer_texture_load(const char* path);
62
63/* create an RGBA8 texture from pixels */
64MGTexture renderer_texture_create(const MGTextureDesc* desc);
65
66/* destroy texture */
67void renderer_texture_destroy(MGTexture id);
68
69#endif /* RENDERER_H */