bmodel rotation physics now work
[xonotic/darkplaces.git] / gl_poly.h
1
2 extern float fog_density, fog_red, fog_green, fog_blue;
3
4 #define TPOLYTYPE_ALPHA 0
5 #define TPOLYTYPE_ADD 1
6
7 extern void transpolyclear();
8 extern void transpolyrender();
9 extern void transpolybegin(int texnum, int glowtexnum, int fogtexnum, int transpolytype);
10 extern void transpolyend();
11
12 extern void wallpolyclear();
13 extern void wallpolyrender();
14
15 extern void skypolyclear();
16 extern void skypolyrender();
17 extern void skypolybegin();
18 extern void skypolyvert(float x, float y, float z);
19 extern void skypolyend();
20
21 #define MAX_TRANSPOLYS 8192
22 #define MAX_TRANSVERTS (MAX_TRANSPOLYS*4)
23 #define MAX_WALLPOLYS 65536
24 #define MAX_WALLVERTS (MAX_WALLPOLYS*3)
25 #define MAX_SKYPOLYS 2048
26 #define MAX_SKYVERTS (MAX_SKYPOLYS*4)
27
28 typedef struct
29 {
30         vec_t s, t;
31         byte r,g,b,a;
32         vec3_t v;
33 } transvert_t;
34
35 typedef struct
36 {
37 //      vec_t mindistance, maxdistance; // closest and farthest distance along v_forward
38 //      vec_t distance; // distance to center
39 //      vec3_t n; // normal
40 //      vec_t ndist; // distance from origin along that normal
41         unsigned short texnum;
42         unsigned short glowtexnum;
43         unsigned short fogtexnum;
44         unsigned short firstvert;
45         unsigned short verts;
46         unsigned short transpolytype;
47 } transpoly_t;
48
49 typedef struct
50 {
51         vec3_t vert;
52         vec_t s, t, u, v;
53         byte r,g,b,a;
54 } wallvert_t;
55
56 typedef struct
57 {
58         unsigned short texnum, lighttexnum, glowtexnum;
59         unsigned short firstvert;
60         unsigned short numverts;
61         unsigned short lit; // doesn't need to be an unsigned short, but to keep the structure consistent...
62 } wallpoly_t;
63
64 typedef struct
65 {
66         vec3_t v;
67 } skyvert_t;
68
69 typedef struct
70 {
71         unsigned short firstvert;
72         unsigned short verts;
73 } skypoly_t;
74
75 extern transvert_t *transvert;
76 extern transpoly_t *transpoly;
77 extern unsigned short *transpolyindex;
78 extern wallvert_t *wallvert;
79 extern wallpoly_t *wallpoly;
80 extern skyvert_t *skyvert;
81 extern skypoly_t *skypoly;
82
83 extern unsigned short currenttranspoly;
84 extern unsigned short currenttransvert;
85 extern unsigned short currentwallpoly;
86 extern unsigned short currentwallvert;
87 extern unsigned short currentskypoly;
88 extern unsigned short currentskyvert;
89
90 #define transpolybegin(ttexnum, tglowtexnum, tfogtexnum, ttranspolytype)\
91 {\
92         if (currenttranspoly < MAX_TRANSPOLYS && currenttransvert < MAX_TRANSVERTS)\
93         {\
94                 transpoly[currenttranspoly].texnum = (unsigned short) (ttexnum);\
95                 transpoly[currenttranspoly].glowtexnum = (unsigned short) (tglowtexnum);\
96                 transpoly[currenttranspoly].fogtexnum = (unsigned short) (tfogtexnum);\
97                 transpoly[currenttranspoly].transpolytype = (unsigned short) (ttranspolytype);\
98                 transpoly[currenttranspoly].firstvert = currenttransvert;\
99                 transpoly[currenttranspoly].verts = 0;\
100         }\
101 }
102
103 #define transpolyvert(vx,vy,vz,vs,vt,vr,vg,vb,va) \
104 {\
105         if (currenttranspoly < MAX_TRANSPOLYS && currenttransvert < MAX_TRANSVERTS)\
106         {\
107                 transvert[currenttransvert].s = (vs);\
108                 transvert[currenttransvert].t = (vt);\
109                 if (lighthalf)\
110                 {\
111                         transvert[currenttransvert].r = (byte) (bound(0, (int) (vr) >> 1, 255));\
112                         transvert[currenttransvert].g = (byte) (bound(0, (int) (vg) >> 1, 255));\
113                         transvert[currenttransvert].b = (byte) (bound(0, (int) (vb) >> 1, 255));\
114                 }\
115                 else\
116                 {\
117                         transvert[currenttransvert].r = (byte) (bound(0, (int) (vr), 255));\
118                         transvert[currenttransvert].g = (byte) (bound(0, (int) (vg), 255));\
119                         transvert[currenttransvert].b = (byte) (bound(0, (int) (vb), 255));\
120                 }\
121                 transvert[currenttransvert].a = (byte) (bound(0, (int) (va), 255));\
122                 transvert[currenttransvert].v[0] = (vx);\
123                 transvert[currenttransvert].v[1] = (vy);\
124                 transvert[currenttransvert].v[2] = (vz);\
125                 currenttransvert++;\
126                 transpoly[currenttranspoly].verts++;\
127         }\
128 }