rayzor

view src/min3d.h @ 0:2a5340a6eee4

rayzor first commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 05 Apr 2014 08:46:27 +0300
parents
children a826bf0fb169
line source
1 #ifndef MIN3D_H_
2 #define MIN3D_H_
4 #include "inttypes.h"
6 /* state toggles */
7 enum {
8 M3D_DEPTH_TEST,
9 M3D_CULL_FACE,
10 M3D_LIGHTING,
11 M3D_LIGHT0,
12 M3D_LIGHT1,
13 M3D_LIGHT2,
14 M3D_LIGHT3
15 };
17 /* buffer bits */
18 enum {
19 M3D_COLOR_BUFFER_BIT = 1,
20 M3D_DEPTH_BUFFER_BIT = 2
21 };
23 /* primitives */
24 enum {
25 M3D_POINTS = 1,
26 M3D_LINES = 2,
27 M3D_TRIANGLES = 3,
28 M3D_QUADS = 4
29 };
31 /* matrix mode */
32 enum {
33 M3D_MODELVIEW,
34 M3D_PROJECTION
35 };
37 struct m3d_image {
38 int xsz, ysz;
39 unsigned char *pixels;
40 };
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 void m3d_set_buffers(struct m3d_image *cbuf, uint16_t *zbuf);
47 void m3d_clear(unsigned int bmask);
49 void m3d_enable(int bit);
50 void m3d_disable(int bit);
52 /* matrix stack */
53 void m3d_matrix_mode(int mode);
54 void m3d_load_identity(void);
55 void m3d_load_matrix(const float *m);
56 void m3d_mult_matrix(const float *m);
57 void m3d_translate(float x, float y, float z);
58 void m3d_rotate(float angle, float x, float y, float z);
59 void m3d_scale(float x, float y, float z);
60 void m3d_frustum(float left, float right, float bottom, float top, float nr, float fr);
61 void m3d_perspective(float vfov, float aspect, float znear, float zfar);
63 /* drawing */
64 void m3d_draw(int prim, const float *varr, int vcount);
65 void m3d_draw_indexed(int prim, const float *varr, const int *idxarr, int icount);
67 /* TODO immediate mode */
69 #ifdef __cplusplus
70 }
71 #endif
73 #endif /* MIN3D_H_ */