rayzor
view src/min3d.h @ 20:6b11a3f8706e
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 15 Apr 2014 01:36:03 +0300 |
parents | 70e332156d02 |
children |
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 uint32_t *pixels;
40 };
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 int m3d_init(void);
47 void m3d_shutdown(void);
49 void m3d_set_buffers(struct m3d_image *cbuf, uint16_t *zbuf);
50 void m3d_clear_color(float r, float g, float b);
51 void m3d_clear(unsigned int bmask);
53 void m3d_enable(int bit);
54 void m3d_disable(int bit);
56 void m3d_viewport(int x, int y, int xsz, int ysz);
58 /* matrix stack */
59 void m3d_matrix_mode(int mode);
60 void m3d_push_matrix(void);
61 void m3d_pop_matrix(void);
62 void m3d_load_identity(void);
63 void m3d_load_matrix(const float *m);
64 void m3d_load_transpose_matrix(const float *m);
65 void m3d_mult_matrix(const float *m);
66 void m3d_mult_transpose_matrix(const float *m);
67 void m3d_translate(float x, float y, float z);
68 void m3d_rotate(float angle, float x, float y, float z);
69 void m3d_scale(float x, float y, float z);
70 void m3d_frustum(float left, float right, float bottom, float top, float nr, float fr);
71 void m3d_perspective(float vfov, float aspect, float znear, float zfar);
73 /* drawing */
74 void m3d_vertex_array(const float *varr);
75 void m3d_normal_array(const float *narr);
76 void m3d_color_array(const float *carr);
77 void m3d_texcoord_array(const float *tcarr);
79 void m3d_draw(int prim, int vcount);
80 void m3d_draw_indexed(int prim, const unsigned int *idxarr, int icount);
82 /* immediate mode interface */
83 void m3d_begin(int prim);
84 void m3d_end(void);
85 void m3d_vertex(float x, float y, float z);
86 void m3d_normal(float x, float y, float z);
87 void m3d_color(float x, float y, float z);
88 void m3d_texcoord(float x, float y);
90 #ifdef __cplusplus
91 }
92 #endif
94 #endif /* MIN3D_H_ */