setting up to improve the rasterizer
[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_TEXTURE = 8,
26
27         G3D_ALL = 0x7fffffff
28 };
29
30 /* arg to g3d_front_face */
31 enum { G3D_CCW, G3D_CW };
32
33 /* arg to g3d_polygon_mode */
34 enum {
35         G3D_WIRE,
36         G3D_FLAT
37 };
38
39 /* matrix stacks */
40 enum {
41         G3D_MODELVIEW,
42         G3D_PROJECTION,
43
44         G3D_NUM_MATRICES
45 };
46
47 int g3d_init(void);
48 void g3d_destroy(void);
49
50 void g3d_framebuffer(int width, int height, void *pixels);
51
52 void g3d_enable(unsigned int opt);
53 void g3d_disable(unsigned int opt);
54 void g3d_setopt(unsigned int opt, unsigned int mask);
55 unsigned int g3d_getopt(unsigned int mask);
56
57 void g3d_front_face(unsigned int order);
58 void g3d_polygon_mode(int pmode);
59
60 void g3d_matrix_mode(int mmode);
61
62 void g3d_load_identity(void);
63 void g3d_load_matrix(const float *m);
64 void g3d_mult_matrix(const float *m);
65 void g3d_push_matrix(void);
66 void g3d_pop_matrix(void);
67
68 void g3d_translate(float x, float y, float z);
69 void g3d_rotate(float angle, float x, float y, float z);
70 void g3d_scale(float x, float y, float z);
71 void g3d_ortho(float left, float right, float bottom, float top, float znear, float zfar);
72 void g3d_frustum(float left, float right, float bottom, float top, float znear, float zfar);
73 void g3d_perspective(float vfov, float aspect, float znear, float zfar);
74
75 const float *g3d_get_matrix(int which, float *m);
76
77 void g3d_draw(int prim, const struct g3d_vertex *varr, int varr_size);
78 void g3d_draw_indexed(int prim, const struct g3d_vertex *varr, int varr_size,
79                 const int16_t *iarr, int iarr_size);
80
81 #endif  /* THREEDGFX_H_ */