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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
/*
* PARSEC - Bitmap 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_bmap.h"
// subsystem linkage info
#include "linkinfo.h"
// local module header
#include "do_bmap.h"
// proprietary module headers
#include "con_aux.h"
#include "ro_api.h"
#include "ro_supp.h"
//char* GlobalColXlat;
//char* BrightxMap;
// put bitmap without clipping; check transparency ----------------------------
//
void D_PutTrBitmap( char *bitmap, dword width, dword height, ugrid_t putx, ugrid_t puty )
{
ASSERT( bitmap != NULL );
GLTexInfo texinfo;
texinfo.texmap = NULL;
texinfo.data = bitmap;
texinfo.width = width;
texinfo.height = height;
texinfo.format = TEXFMT_RGBA_8888;
// ensure filtering is turned off
int filtmode = AUX_DISABLE_POLYGON_FILTERING;
AUX_DISABLE_POLYGON_FILTERING = 1;
// this also fills in texinfo.coscale
RO_SelectTexelSource2( &texinfo );
// restore filter state
AUX_DISABLE_POLYGON_FILTERING = filtmode;
// configure rasterizer
dword itertype = iter_texonly | iter_alphablend;
dword raststate = rast_nozbuffer | rast_chromakeyon | rast_mask_texwrap;
dword rastmask = rast_nomask;
RO_InitRasterizerState( itertype, raststate, rastmask );
RO_TextureCombineState( texcomb_decal );
// draw rectangle (z=none, color=none)
RO_Render2DRectangle( putx, puty,
width * texinfo.coscale, height * texinfo.coscale,
width, height, 0, NULL );
// set rasterizer state to default
RO_DefaultRasterizerState();
}
// put bitmap without clipping; check transparency; use color map -------------
//
void D_PutTrMapBitmap( char *bitmap, char *maps, dword width, dword height, ugrid_t putx, ugrid_t puty, dword color )
{
//TODO:
}
// put bitmap and clip against screen extents ---------------------------------
//
void D_PutClipBitmap( char *bitmap, dword width, dword height, sgrid_t putx, sgrid_t puty )
{
ASSERT( bitmap != NULL );
dword dstw = width;
dword dsth = height;
//FIXME:
/*
for ( int bindx = 0; ; bindx++ )
if ( BitmapInfo[ bindx ].bitmappointer == bitmap )
break;
if ( bindx == BM_BIGPLANET1 ) {
bindx = BM_MEDPLANET1;
width /= 2;
height /= 2;
}
bitmap = BitmapInfo[ bindx ].loadeddata;
*/
GLTexInfo texinfo;
texinfo.texmap = NULL;
texinfo.data = bitmap;
texinfo.width = width;
texinfo.height = height;
texinfo.format = TEXFMT_RGBA_8888;
// this also fills in texinfo.coscale
RO_SelectTexelSource2( &texinfo );
// configure rasterizer
dword itertype = iter_texonly | iter_overwrite;
dword raststate = rast_chromakeyoff | rast_mask_texwrap;
dword rastmask = rast_mask_zbuffer;
RO_InitRasterizerState( itertype, raststate, rastmask );
RO_TextureCombineState( texcomb_decal );
// draw rectangle (z=none, color=none)
RO_Render2DRectangle( putx, puty,
width * texinfo.coscale, height * texinfo.coscale,
dstw, dsth, 0, NULL );
// set rasterizer state to default
RO_DefaultRasterizerState();
}
// put transparent bitmap and clip against screen extents ---------------------
//
void D_PutTrClipBitmap( char *bitmap, dword width, dword height, sgrid_t putx, sgrid_t puty )
{
ASSERT( bitmap != NULL );
GLTexInfo texinfo;
texinfo.texmap = NULL;
texinfo.data = bitmap;
texinfo.width = width;
texinfo.height = height;
texinfo.format = TEXFMT_RGBA_8888;
// this also fills in texinfo.coscale
RO_SelectTexelSource2( &texinfo );
// configure rasterizer
dword itertype = iter_texonly | iter_alphablend;
dword raststate = rast_nozbuffer | rast_chromakeyon | rast_mask_texwrap;
dword rastmask = rast_nomask;
RO_InitRasterizerState( itertype, raststate, rastmask );
RO_TextureCombineState( texcomb_decal );
// draw rectangle (z=none, color=none)
RO_Render2DRectangle( putx, puty,
width * texinfo.coscale, height * texinfo.coscale,
width, height, 0, NULL );
// set rasterizer state to default
RO_DefaultRasterizerState();
}
// ----------------------------------------------------------------------------
//
static int no_depth_buffer = 0;
// put clipped and scaled transparent bitmap (check/alter z-buffer) -----------
//
void D_PutSTCBitmapZ( char *bitmap, dword srcw, dword srch, dword dstw, dword dsth, sgrid_t putx, sgrid_t puty, dword zvalue )
{
ASSERT( bitmap != NULL );
// vertical culling
if ( puty + (int)dsth <= 0 )
return;
if ( puty >= Screen_Height )
return;
// horizontal culling
if ( putx + (int)dstw <= 0 )
return;
if ( putx >= Screen_Width )
return;
// --
GLTexInfo texinfo;
texinfo.texmap = NULL;
texinfo.data = bitmap;
texinfo.width = srcw;
texinfo.height = srch;
texinfo.format = TEXFMT_RGBA_8888;
// this also fills in texinfo.coscale
RO_SelectTexelSource2( &texinfo );
// save zcmp and zwrite state
int zcmpstate = RO_DepthCmpEnabled();
int zwritestate = RO_DepthWriteEnabled();
// determine if depth buffer should be turned on
dword rastzctrl = no_depth_buffer ? rast_nozbuffer : rast_zbuffer;
// configure rasterizer
dword itertype = iter_texconsta | iter_overwrite; // iter_alphablend;
dword raststate = rastzctrl | rast_chromakeyon | rast_mask_texwrap;
dword rastmask = rast_nomask;
RO_InitRasterizerState( itertype, raststate, rastmask );
RO_TextureCombineState( texcomb_decal );
// set constant (rgba)
if ( bitmap == BitmapInfo[ BM_LIGHTNING1 ].bitmappointer ) {
glColor4ub( 0xff, 0xff, 0xff, 0xff );
} else if ( bitmap == BitmapInfo[ BM_SHIELD1 ].bitmappointer ) {
glColor4ub( 0xff, 0xff, 0xff, 0xe8 );
} else if ( bitmap == BitmapInfo[ BM_SHIELD2 ].bitmappointer ) {
glColor4ub( 0xff, 0xff, 0xff, 0xe8 );
} else if ( bitmap == BitmapInfo[ BM_FIREBALL3 ].bitmappointer ) {
glColor4ub( 0xff, 0xff, 0xff, 0xc0 );
} else {
glColor4ub( 0xff, 0xff, 0xff, 0x90 );
}
RO_AlphaFunc( GL_GREATER, 0.0f );
RO_AlphaTest( TRUE );
// draw rectangle (z=zvalue, color=none)
RO_Render2DRectangle( putx, puty,
srcw * texinfo.coscale, srch * texinfo.coscale,
dstw, dsth, zvalue, NULL );
RO_AlphaTest( FALSE );
// set rasterizer state to default
RO_DefaultRasterizerState();
// restore zcmp and zwrite state
if ( no_depth_buffer ) {
if ( zcmpstate || zwritestate )
RO_EnableDepthBuffer( zcmpstate, zwritestate );
} else {
if ( !zcmpstate || !zwritestate )
RO_DisableDepthBuffer( !zcmpstate, !zwritestate );
}
}
// put clipped and scaled transparent bitmap ----------------------------------
//
void D_PutSTCBitmap( char *bitmap, dword srcw, dword srch, dword dstw, dword dsth, sgrid_t putx, sgrid_t puty )
{
no_depth_buffer = 1;
D_PutSTCBitmapZ( bitmap, srcw, srch, dstw, dsth, putx, puty, 0 );
no_depth_buffer = 0;
}
// draw translucent rectangle -------------------------------------------------
//
void D_DrawTrRect( ugrid_t putx, ugrid_t puty, dword width, dword height, dword brightx )
{
// configure rasterizer
dword itertype = iter_rgba | iter_alphablend;
dword raststate = rast_chromakeyoff;
dword rastmask = rast_mask_zbuffer | rast_mask_texclamp |
rast_mask_mipmap | rast_mask_texfilter;
RO_InitRasterizerState( itertype, raststate, rastmask );
//NOTE:
// parameter brightx is not used anymore. instead, the
// global PanelBackColor determines RGBA.
glColor4ub( PanelBackColor.R, PanelBackColor.G, PanelBackColor.B, PanelBackColor.A );
GLshort vertices[] = {
putx, puty,
putx, puty + height,
putx + width, puty,
putx + width, puty + height,
};
RO_ClientState(VTXARRAY_VERTICES);
RO_ArrayMakeCurrent(VTXPTRS_NONE, NULL);
glVertexPointer(2, GL_SHORT, 0, vertices);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
// set rasterizer state to default
RO_DefaultRasterizerState();
}
|