split the polyfiller to a preprocessor-based template file, included
[dosdemo] / src / 3dgfx.h
1 #ifndef THREEDGFX_H_
2 #define THREEDGFX_H_
3
4 #include "inttypes.h"
5
6 struct g3d_vertex {
7         float x, y, z, w;
8         float nx, ny, nz;
9         float u, v;
10         unsigned char r, g, b;
11 };
12
13 enum {
14         G3D_POINTS = 1,
15         G3D_LINES = 2,
16         G3D_TRIANGLES = 3,
17         G3D_QUADS = 4
18 };
19
20 /* g3d_enable/g3d_disable bits */
21 enum {
22         G3D_CULL_FACE = 1,
23         G3D_DEPTH_TEST = 2,     /* XXX not implemented */
24         G3D_LIGHTING = 4,
25         G3D_LIGHT0 = 8,
26         G3D_LIGHT1 = 16,
27         G3D_LIGHT2 = 32,
28         G3D_LIGHT3 = 64,
29         G3D_TEXTURE = 128,
30
31         G3D_ALL = 0x7fffffff
32 };
33
34 /* arg to g3d_front_face */
35 enum { G3D_CCW, G3D_CW };
36
37 /* arg to g3d_polygon_mode */
38 enum {
39         G3D_WIRE,
40         G3D_FLAT,
41         G3D_GOURAUD,
42 };
43
44 /* matrix stacks */
45 enum {
46         G3D_MODELVIEW,
47         G3D_PROJECTION,
48
49         G3D_NUM_MATRICES
50 };
51
52 int g3d_init(void);
53 void g3d_destroy(void);
54
55 void g3d_framebuffer(int width, int height, void *pixels);
56
57 void g3d_enable(unsigned int opt);
58 void g3d_disable(unsigned int opt);
59 void g3d_setopt(unsigned int opt, unsigned int mask);
60 unsigned int g3d_getopt(unsigned int mask);
61
62 void g3d_front_face(unsigned int order);
63 void g3d_polygon_mode(int pmode);
64
65 void g3d_matrix_mode(int mmode);
66
67 void g3d_load_identity(void);
68 void g3d_load_matrix(const float *m);
69 void g3d_mult_matrix(const float *m);
70 void g3d_push_matrix(void);
71 void g3d_pop_matrix(void);
72
73 void g3d_translate(float x, float y, float z);
74 void g3d_rotate(float angle, float x, float y, float z);
75 void g3d_scale(float x, float y, float z);
76 void g3d_ortho(float left, float right, float bottom, float top, float znear, float zfar);
77 void g3d_frustum(float left, float right, float bottom, float top, float znear, float zfar);
78 void g3d_perspective(float vfov, float aspect, float znear, float zfar);
79
80 const float *g3d_get_matrix(int which, float *m);
81
82 void g3d_light_pos(int idx, float x, float y, float z);
83 void g3d_light_color(int idx, float r, float g, float b);
84
85 void g3d_light_ambient(float r, float g, float b);
86
87 void g3d_mtl_diffuse(float r, float g, float b);
88 void g3d_mtl_specular(float r, float g, float b);
89 void g3d_mtl_shininess(float shin);
90
91 void g3d_draw(int prim, const struct g3d_vertex *varr, int varr_size);
92 void g3d_draw_indexed(int prim, const struct g3d_vertex *varr, int varr_size,
93                 const int16_t *iarr, int iarr_size);
94
95 #endif  /* THREEDGFX_H_ */