]> icculus.org git repositories - divverent/darkplaces.git/blob - gl_poly.h
forgot to remove these
[divverent/darkplaces.git] / gl_poly.h
1
2 extern int R_SetSkyBox(char* sky);
3 extern cvar_t r_skyquality;
4
5 #define TPOLYTYPE_ALPHA 0
6 #define TPOLYTYPE_ADD 1
7
8 extern void transpolyclear(void);
9 extern void transpolyrender(void);
10 extern void transpolybegin(int texnum, int glowtexnum, int fogtexnum, int transpolytype);
11 extern void transpolyend(void);
12 extern void transpolyparticle(vec3_t org, vec3_t right, vec3_t up, vec_t scale, unsigned short texnum, unsigned short transpolytype, int ir, int ig, int ib, float alphaf, float s1, float t1, float s2, float t2);
13
14 extern void wallpolyclear(void);
15 extern void wallpolyrender1(void);
16 extern void wallpolyrender2(void);
17
18 extern void skypolyclear(void);
19 extern void skypolyrender(void);
20 extern void skypolybegin(void);
21 extern void skypolyvert(float x, float y, float z);
22 extern void skypolyend(void);
23
24 #define MAX_TRANSPOLYS 65536
25 #define MAX_TRANSVERTS (MAX_TRANSPOLYS*4)
26 #define MAX_WALLPOLYS 65536
27 #define MAX_WALLVERTS (MAX_WALLPOLYS*3)
28 #define MAX_SKYPOLYS 2048
29 #define MAX_SKYVERTS (MAX_SKYPOLYS*4)
30
31 typedef struct
32 {
33         vec_t s, t;
34         byte r,g,b,a;
35         vec3_t v;
36 }
37 transvert_t;
38
39 typedef struct
40 {
41 //      vec_t mindistance, maxdistance; // closest and farthest distance along v_forward
42 //      vec_t distance; // distance to center
43 //      vec3_t n; // normal
44 //      vec_t ndist; // distance from origin along that normal
45         unsigned short texnum;
46         unsigned short glowtexnum;
47         unsigned short fogtexnum;
48         unsigned short firstvert;
49         unsigned short verts;
50         unsigned short transpolytype;
51 }
52 transpoly_t;
53
54 // note: must match format of glpoly_t vertices due to a memcpy used in RSurf_DrawWall
55 typedef struct
56 {
57         vec_t vert[VERTEXSIZE]; // xyz st uv
58 }
59 wallvert_t;
60
61 typedef struct
62 {
63         byte r,g,b,a;
64 }
65 wallvertcolor_t;
66
67 typedef struct
68 {
69         unsigned short texnum, lighttexnum, glowtexnum;
70         unsigned short firstvert;
71         unsigned short numverts;
72         unsigned short lit; // doesn't need to be an unsigned short, but to keep the structure consistent...
73 }
74 wallpoly_t;
75
76 typedef struct
77 {
78         float tex[2];
79         float tex2[2];
80         float v[4]; // 4th item is only for padding
81 }
82 skyvert_t;
83
84 typedef struct
85 {
86         unsigned short firstvert;
87         unsigned short verts;
88 }
89 skypoly_t;
90
91 extern transvert_t *transvert;
92 extern transpoly_t *transpoly;
93 extern int *transpolyindex;
94 extern int *transvertindex;
95 extern transpoly_t **transpolylist;
96 extern wallvert_t *wallvert;
97 extern wallvertcolor_t *wallvertcolor;
98 extern wallpoly_t *wallpoly;
99 extern skyvert_t *skyvert;
100 extern skypoly_t *skypoly;
101
102 extern int currenttranspoly;
103 extern int currenttransvert;
104 extern int currentwallpoly;
105 extern int currentwallvert;
106 extern int currentskypoly;
107 extern int currentskyvert;
108
109 #define transpolybegin(ttexnum, tglowtexnum, tfogtexnum, ttranspolytype)\
110 {\
111         if (currenttranspoly < MAX_TRANSPOLYS && currenttransvert < MAX_TRANSVERTS)\
112         {\
113                 transpoly[currenttranspoly].texnum = (unsigned short) (ttexnum);\
114                 transpoly[currenttranspoly].glowtexnum = (unsigned short) (tglowtexnum);\
115                 transpoly[currenttranspoly].fogtexnum = (unsigned short) (tfogtexnum);\
116                 transpoly[currenttranspoly].transpolytype = (unsigned short) (ttranspolytype);\
117                 transpoly[currenttranspoly].firstvert = currenttransvert;\
118                 transpoly[currenttranspoly].verts = 0;\
119         }\
120 }
121
122 #define transpolyvert(vx,vy,vz,vs,vt,vr,vg,vb,va) \
123 {\
124         if (currenttranspoly < MAX_TRANSPOLYS && currenttransvert < MAX_TRANSVERTS)\
125         {\
126                 transvert[currenttransvert].s = (vs);\
127                 transvert[currenttransvert].t = (vt);\
128                 if (lighthalf)\
129                 {\
130                         transvert[currenttransvert].r = (byte) (bound(0, (int) (vr) >> 1, 255));\
131                         transvert[currenttransvert].g = (byte) (bound(0, (int) (vg) >> 1, 255));\
132                         transvert[currenttransvert].b = (byte) (bound(0, (int) (vb) >> 1, 255));\
133                 }\
134                 else\
135                 {\
136                         transvert[currenttransvert].r = (byte) (bound(0, (int) (vr), 255));\
137                         transvert[currenttransvert].g = (byte) (bound(0, (int) (vg), 255));\
138                         transvert[currenttransvert].b = (byte) (bound(0, (int) (vb), 255));\
139                 }\
140                 transvert[currenttransvert].a = (byte) (bound(0, (int) (va), 255));\
141                 transvert[currenttransvert].v[0] = (vx);\
142                 transvert[currenttransvert].v[1] = (vy);\
143                 transvert[currenttransvert].v[2] = (vz);\
144                 currenttransvert++;\
145                 transpoly[currenttranspoly].verts++;\
146         }\
147 }
148
149 #define transpolyvertub(vx,vy,vz,vs,vt,vr,vg,vb,va) \
150 {\
151         if (currenttranspoly < MAX_TRANSPOLYS && currenttransvert < MAX_TRANSVERTS)\
152         {\
153                 transvert[currenttransvert].s = (vs);\
154                 transvert[currenttransvert].t = (vt);\
155                 if (lighthalf)\
156                 {\
157                         transvert[currenttransvert].r = (vr) >> 1;\
158                         transvert[currenttransvert].g = (vg) >> 1;\
159                         transvert[currenttransvert].b = (vb) >> 1;\
160                 }\
161                 else\
162                 {\
163                         transvert[currenttransvert].r = (vr);\
164                         transvert[currenttransvert].g = (vg);\
165                         transvert[currenttransvert].b = (vb);\
166                 }\
167                 transvert[currenttransvert].a = (va);\
168                 transvert[currenttransvert].v[0] = (vx);\
169                 transvert[currenttransvert].v[1] = (vy);\
170                 transvert[currenttransvert].v[2] = (vz);\
171                 currenttransvert++;\
172                 transpoly[currenttranspoly].verts++;\
173         }\
174 }