wrote most of the 3d pipeline stuff
[dosdemo] / src / 3dgfx.h
1 #ifndef THREEDGFX_H_
2 #define THREEDGFX_H_
3
4 struct g3d_vertex {
5         float x, y, z, w;
6         float nx, ny, nz;
7         float u, v;
8         unsigned char r, g, b;
9 };
10
11 enum {
12         G3D_POINTS = 1,
13         G3D_LINES = 2,
14         G3D_TRIANGLES = 3,
15         G3D_QUADS = 4
16 };
17
18 /* g3d_enable/g3d_disable bits */
19 enum {
20         G3D_CULL_FACE = 1,
21         G3D_DEPTH_TEST = 2,     /* XXX not implemented */
22         G3D_LIGHTING = 4,
23         G3D_TEXTURE = 8,
24
25         G3D_ALL = 0x7fffffff
26 };
27
28 /* 2nd arg to g3d_draw: which space are input verts in. skips parts of the pipeline */
29 enum {
30         G3D_LOCAL_SPACE, /* this being 0 makes a nice default arg. */
31         G3D_VIEW_SPACE,  /* ignore modelview matrix */
32         G3D_CLIP_SPACE,  /* ignore projection matrix */
33         G3D_SCREEN_SPACE,/* 2D verts, don't divide by w */
34         G3D_PIXEL_SPACE  /* in pixel units, ignore viewport */
35 };
36
37 /* matrix stacks */
38 enum {
39         G3D_MODELVIEW,
40         G3D_PROJECTION,
41
42         G3D_NUM_MATRICES
43 };
44
45 void g3d_init(void);
46
47 void g3d_framebuffer(int width, int height, void *pixels);
48
49 void g3d_enable(unsigned int opt);
50 void g3d_disable(unsigned int opt);
51 void g3d_setopt(unsigned int opt, unsigned int mask);
52 unsigned int g3d_getopt(unsigned int mask);
53
54 void g3d_set_matrix(int which, const float *m); /* null ptr for identity */
55 void g3d_mult_matrix(int which, const float *m);
56 void g3d_push_matrix(int which);
57 void g3d_pop_matrix(int which);
58
59 void g3d_translate(int which, float x, float y, float z);
60 void g3d_rotate(int which, float angle, float x, float y, float z);
61 void g3d_scale(int which, float x, float y, float z);
62 void g3d_ortho(int which, float left, float right, float bottom, float top, float znear, float zfar);
63 void g3d_frustum(int which, float left, float right, float bottom, float top, float znear, float zfar);
64 void g3d_perspective(int which, float vfov, float aspect, float znear, float zfar);
65
66 void g3d_draw(int prim, int space, const struct g3d_vertex *varr, int varr_size);
67
68 #endif  /* THREEDGFX_H_ */