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