rayzor

view src/min3d.h @ 9:70e332156d02

moving along
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 10 Apr 2014 02:31:31 +0300
parents a68dbf80d547
children 79609d482762
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_mult_matrix(const float *m);
65 void m3d_translate(float x, float y, float z);
66 void m3d_rotate(float angle, float x, float y, float z);
67 void m3d_scale(float x, float y, float z);
68 void m3d_frustum(float left, float right, float bottom, float top, float nr, float fr);
69 void m3d_perspective(float vfov, float aspect, float znear, float zfar);
71 /* drawing */
72 void m3d_vertex_array(const float *varr);
73 void m3d_normal_array(const float *narr);
74 void m3d_color_array(const float *carr);
75 void m3d_texcoord_array(const float *tcarr);
77 void m3d_draw(int prim, int vcount);
78 void m3d_draw_indexed(int prim, const unsigned int *idxarr, int icount);
80 /* immediate mode interface */
81 void m3d_begin(int prim);
82 void m3d_end(void);
83 void m3d_vertex(float x, float y, float z);
84 void m3d_normal(float x, float y, float z);
85 void m3d_color(float x, float y, float z);
86 void m3d_texcoord(float x, float y);
88 #ifdef __cplusplus
89 }
90 #endif
92 #endif /* MIN3D_H_ */