rayzor

view src/min3d.h @ 6:a68dbf80d547

finally showing something ... :)
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 07 Apr 2014 06:04:11 +0300
parents 5fcf72837b69
children 70e332156d02
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 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 /* matrix stack */
57 void m3d_matrix_mode(int mode);
58 void m3d_push_matrix(void);
59 void m3d_pop_matrix(void);
60 void m3d_load_identity(void);
61 void m3d_load_matrix(const float *m);
62 void m3d_mult_matrix(const float *m);
63 void m3d_translate(float x, float y, float z);
64 void m3d_rotate(float angle, float x, float y, float z);
65 void m3d_scale(float x, float y, float z);
66 void m3d_frustum(float left, float right, float bottom, float top, float nr, float fr);
67 void m3d_perspective(float vfov, float aspect, float znear, float zfar);
69 /* drawing */
70 void m3d_vertex_array(const float *varr);
71 void m3d_normal_array(const float *narr);
72 void m3d_color_array(const float *carr);
73 void m3d_texcoord_array(const float *tcarr);
75 void m3d_draw(int prim, int vcount);
76 void m3d_draw_indexed(int prim, const int *idxarr, int icount);
78 /* immediate mode interface */
79 void m3d_begin(int prim);
80 void m3d_end(void);
81 void m3d_vertex(float x, float y, float z);
82 void m3d_normal(float x, float y, float z);
83 void m3d_color(float x, float y, float z);
84 void m3d_texcoord(float x, float y);
86 #ifdef __cplusplus
87 }
88 #endif
90 #endif /* MIN3D_H_ */