started writing some 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_WORLD_SPACE, /* ignore world matrix */
32         G3D_VIEW_SPACE,  /* ignore view matrix */
33         G3D_CLIP_SPACE,  /* ignore projection matrix */
34         G3D_SCREEN_SPACE,/* 2D verts, don't divide by w */
35         G3D_PIXEL_SPACE  /* in pixel units, ignore viewport */
36 };
37
38 /* matrix stacks */
39 enum {
40         G3D_WORLD,
41         G3D_VIEW,
42         G3D_PROJECTION,
43
44         G3D_NUM_MATRICES
45 };
46
47 void g3d_init(void);
48
49 void g3d_framebuffer(int width, int height, void *pixels);
50
51 void g3d_enable(unsigned int opt);
52 void g3d_disable(unsigned int opt);
53 void g3d_setopt(unsigned int opt, unsigned int mask);
54 unsigned int g3d_getopt(unsigned int mask);
55
56 void g3d_set_matrix(int which, const float *m); /* null ptr for identity */
57 void g3d_mult_matrix(int which, const float *m);
58 void g3d_push_matrix(int which);
59 void g3d_pop_matrix(int which);
60
61 void g3d_translate(float x, float y, float z);
62 void g3d_rotate(float angle, float x, float y, float z);
63 void g3d_scale(float x, float y, float z);
64 void g3d_ortho(float left, float right, float bottom, float top, float znear, float zfar);
65 void g3d_frustum(float left, float right, float bottom, float top, float znear, float zfar);
66 void g3d_perspective(float vfov, float aspect, float znear, float zfar);
67
68 void g3d_draw(int prim, int space, const struct g3d_vertex *varr, int num);
69
70 #endif  /* THREEDGFX_H_ */