1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
/*
* PARSEC - Miscellaneous Drawing Code
*
* $Author: uberlinuxguy $ - $Date: 2004/09/15 12:25:22 $
*
* Orginally written by:
* Copyright (c) Markus Hadwiger <msh@parsec.org> 1999
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// C library
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// compilation flags/debug support
#include "config.h"
#include "debug.h"
// general definitions
#include "general.h"
#include "objstruc.h"
// global externals
#include "globals.h"
// subsystem headers
#include "vid_defs.h"
// drawing subsystem
#include "d_misc.h"
// local module header
#include "do_misc.h"
// proprietary module headers
#include "e_color.h"
#include "ro_api.h"
#include "ro_supp.h"
// draw square with single color ----------------------------------------------
//
int D_DrawSquare( ugrid_t xko, ugrid_t yko, visual_t col, dword siz )
{
// configure rasterizer
dword itertype = iter_rgb;
dword raststate = rast_chromakeyoff;
dword rastmask = rast_mask_zbuffer | rast_mask_texclamp |
rast_mask_mipmap | rast_mask_texfilter;
RO_InitRasterizerState( itertype, raststate, rastmask );
// set color
colrgba_s colrgba;
VisualToRGBA( &colrgba, col );
glColor3ub( (GLubyte)colrgba.R, (GLubyte)colrgba.G, (GLubyte)colrgba.B );
RO_PointSize( (GLfloat)siz );
GLshort vertices[] = {xko, yko};
RO_ClientState(VTXARRAY_VERTICES);
RO_ArrayMakeCurrent(VTXPTRS_NONE, NULL);
glVertexPointer(2, GL_SHORT, 0, vertices);
glDrawArrays(GL_POINTS, 0, 1);
// set rasterizer state to default
RO_DefaultRasterizerState();
return 1;
}
// draw square of homogeneous color taking the z-buffer into account ----------
//
int D_DrawSquareZ( ugrid_t xko, ugrid_t yko, visual_t col, dword siz, dword zvalue )
{
if ( (int)xko < 0 )
return 0;
if ( (int)yko < 0 )
return 0;
// save zcmp and zwrite state
int zcmpstate = RO_DepthCmpEnabled();
int zwritestate = RO_DepthWriteEnabled();
// configure rasterizer
dword itertype = iter_rgba | iter_alphablend;
dword raststate = rast_zbuffer | rast_chromakeyoff;
dword rastmask = rast_mask_texwrap | rast_mask_mipmap |
rast_mask_texfilter;
RO_InitRasterizerState( itertype, raststate, rastmask );
// set color
colrgba_s colrgba;
VisualToRGBA( &colrgba, col );
glColor3ub( (GLubyte)colrgba.R, (GLubyte)colrgba.G, (GLubyte)colrgba.B );
RO_PointSize( siz );
GLshort vertices[] = {xko, yko, 0}; // TODO: zvalue
RO_ClientState(VTXARRAY_VERTICES);
RO_ArrayMakeCurrent(VTXPTRS_NONE, NULL);
glVertexPointer(3, GL_SHORT, 0, vertices);
glDrawArrays(GL_POINTS, 0, 1);
// set rasterizer state to default
RO_DefaultRasterizerState();
// restore zcmp and zwrite state
if ( !zcmpstate || !zwritestate )
RO_DisableDepthBuffer( !zcmpstate, !zwritestate );
return 1;
}
// draw radar object ----------------------------------------------------------
//
void D_DrawRadarObj( ugrid_t xko, ugrid_t yko, visual_t col )
{
// configure rasterizer
dword itertype = iter_rgb;
dword raststate = rast_chromakeyoff;
dword rastmask = rast_mask_zbuffer | rast_mask_texclamp |
rast_mask_mipmap | rast_mask_texfilter;
RO_InitRasterizerState( itertype, raststate, rastmask );
// set color
colrgba_s colrgba;
VisualToRGBA( &colrgba, col );
glColor3ub( (GLubyte)colrgba.R, (GLubyte)colrgba.G, (GLubyte)colrgba.B );
RO_PointSize( 2.0f );
GLshort vertices[] = {xko, yko};
RO_ClientState(VTXARRAY_VERTICES);
RO_ArrayMakeCurrent(VTXPTRS_NONE, NULL);
glVertexPointer(2, GL_SHORT, 0, vertices);
glDrawArrays(GL_POINTS, 0, 1);
// set rasterizer state to default
RO_DefaultRasterizerState();
}
// draw horizontal bar --------------------------------------------------------
//
void D_DrawHorzBar( ugrid_t xko, ugrid_t yko, visual_t col, dword leng )
{
// configure rasterizer
dword itertype = iter_rgb;
dword raststate = rast_chromakeyoff;
dword rastmask = rast_mask_zbuffer | rast_mask_texclamp |
rast_mask_mipmap | rast_mask_texfilter;
RO_InitRasterizerState( itertype, raststate, rastmask );
// set color
colrgba_s colrgba;
VisualToRGBA( &colrgba, col );
glColor3ub( (GLubyte)colrgba.R, (GLubyte)colrgba.G, (GLubyte)colrgba.B );
GLshort vertices[] = {xko, yko, xko + leng, yko};
RO_ClientState(VTXARRAY_VERTICES);
RO_ArrayMakeCurrent(VTXPTRS_NONE, NULL);
glVertexPointer(2, GL_SHORT, 0, vertices);
glDrawArrays(GL_LINES, 0, 2);
// set rasterizer state to default
RO_DefaultRasterizerState();
}
// draw vertical bar ----------------------------------------------------------
//
void D_DrawVertBar( ugrid_t xko, ugrid_t yko, visual_t col, dword leng )
{
// configure rasterizer
dword itertype = iter_rgb;
dword raststate = rast_chromakeyoff;
dword rastmask = rast_mask_zbuffer | rast_mask_texclamp |
rast_mask_mipmap | rast_mask_texfilter;
RO_InitRasterizerState( itertype, raststate, rastmask );
// set color
colrgba_s colrgba;
VisualToRGBA( &colrgba, col );
glColor3ub( (GLubyte)colrgba.R, (GLubyte)colrgba.G, (GLubyte)colrgba.B );
GLshort vertices[] = {xko, yko, xko, yko + leng};
RO_ClientState(VTXARRAY_VERTICES);
RO_ArrayMakeCurrent(VTXPTRS_NONE, NULL);
glVertexPointer(2, GL_SHORT, 0, vertices);
glDrawArrays(GL_LINES, 0, 2);
// set rasterizer state to default
RO_DefaultRasterizerState();
}
// draw arbitrarily oriented line ---------------------------------------------
//
void D_DrawLine( ugrid_t xko1, ugrid_t yko1, ugrid_t xko2, ugrid_t yko2, visual_t col1, visual_t col2, dword mode )
{
// configure rasterizer
dword blendtype = ( mode & D_DRAWLINE_STYLE_ANTIALIASED ) ?
iter_alphablend : iter_overwrite;
dword itertype = iter_rgba | blendtype;
dword raststate = rast_chromakeyoff;
dword rastmask = rast_mask_zbuffer | rast_mask_texclamp |
rast_mask_mipmap | rast_mask_texfilter;
RO_InitRasterizerState( itertype, raststate, rastmask );
// set line antialiasing mode
if ( mode & D_DRAWLINE_STYLE_ANTIALIASED )
RO_LineSmooth( TRUE );
colrgba_s colrgba1, colrgba2;
VisualToRGBA( &colrgba1, col1 );
VisualToRGBA( &colrgba2, col2 );
GLshort vertices[] = {xko1, yko1, xko2, yko2};
GLubyte colors[] = {colrgba1.R, colrgba1.G, colrgba2.B, colrgba2.R, colrgba2.G, colrgba2.B};
RO_ClientState(VTXARRAY_VERTICES | VTXARRAY_COLORS);
RO_ArrayMakeCurrent(VTXPTRS_NONE, NULL);
glVertexPointer(2, GL_SHORT, 0, vertices);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
glDrawArrays(GL_LINES, 0, 2);
// set rasterizer state to default
if ( mode & D_DRAWLINE_STYLE_ANTIALIASED )
RO_LineSmooth( FALSE );
RO_DefaultRasterizerState();
}
// draw line strip (draws numvtxs - 1 lines) ----------------------------------
//
void D_DrawLineStrip( ugrid_t *vtxs, dword numvtxs, visual_t col, dword mode )
{
ASSERT( vtxs != NULL );
ASSERT( numvtxs > 1 );
// configure rasterizer
dword blendtype = ( mode & D_DRAWLINE_STYLE_ANTIALIASED ) ?
iter_alphablend : iter_overwrite;
dword itertype = iter_rgba | blendtype;
dword raststate = rast_chromakeyoff;
dword rastmask = rast_mask_zbuffer | rast_mask_texclamp |
rast_mask_mipmap | rast_mask_texfilter;
RO_InitRasterizerState( itertype, raststate, rastmask );
// set color
colrgba_s colrgba;
VisualToRGBA( &colrgba, col );
glColor3ub( (GLubyte)colrgba.R, (GLubyte)colrgba.G, (GLubyte)colrgba.B );
// set line antialiasing mode
if ( mode & D_DRAWLINE_STYLE_ANTIALIASED )
RO_LineSmooth( TRUE );
// draw line strip/loop
GLenum glmode = ( mode & D_DRAWLINE_STYLE_CLOSE_STRIP ) ?
GL_LINE_LOOP : GL_LINE_STRIP;
RO_ClientState(VTXARRAY_VERTICES);
RO_ArrayMakeCurrent(VTXPTRS_NONE, NULL);
glVertexPointer(2, GL_SHORT, 0, vtxs);
glDrawArrays(glmode, 0, numvtxs);
// set rasterizer state to default
if ( mode & D_DRAWLINE_STYLE_ANTIALIASED )
RO_LineSmooth( FALSE );
RO_DefaultRasterizerState();
}
|