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 float x;
16 float y;
17 float z;
18
19 float u;
20 float v;
21
22 u32 col;
23} MGVertex;
24
25typedef struct {
26 const MGVertex* vtc; /* vertices */
27 u32 vtcc; /* vertices count */
28 const u16* idc; /* indecies */
29 u32 idcc; /* indecies count */
30} MGMeshDesc;
31
32/* create renderer with chosen context
33 (just GL for now) */
34void renderer_create(MGContext* ctx);
35
36/* start drawing to screen */
37void renderer_begin(void);
38
39/* finish drawing to screen */
40void renderer_end(void);
41
42/* destroy renderer resources */
43void renderer_destroy(void);
44
45/* create mesh from descriptor */
46MGMesh renderer_mesh_create(const MGMeshDesc* desc);
47
48/* draws mesh using specified texture and mat */
49void renderer_mesh_draw(MGMesh mesh, MGTexture texture, const MGMat4* mvp);
50
51/* destroy mesh */
52void renderer_mesh_destroy(MGMesh id);
53
54/* load texture from file */
55MGTexture renderer_texture_load(const char* path);
56
57/* destroy texture */
58void renderer_texture_destroy(MGTexture id);
59
60#endif /* RENDERER_H */
61