]> icculus.org git repositories - btb/d2x.git/blob - include/gr.h
fix win32 GL_NV_register_combiners build stuff (d1x r1.39, r1.7)
[btb/d2x.git] / include / gr.h
1 /* $Id: gr.h,v 1.27 2004-05-22 09:21:22 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Definitions for graphics lib.
18  *
19  * Old Log:
20  * Revision 1.7  1995/09/13  08:39:44  allender
21  * added prototype for gr_bitblt_cockpit
22  *
23  * Revision 1.6  1995/08/23  18:47:01  allender
24  * fixed compiler warnings on mcc
25  *
26  * Revision 1.5  1995/08/14  15:51:01  allender
27  * added #define for transparency color
28  *
29  * Revision 1.4  1995/06/13  13:03:55  allender
30  * added graphics mode
31  *
32  * Revision 1.3  1995/04/18  09:50:16  allender
33  * *** empty log message ***
34  *
35  * Revision 1.2  1995/04/07  07:32:33  allender
36  * *** empty log message ***
37  *
38  * Revision 1.1  1995/03/09  09:04:16  allender
39  * Initial revision
40  *
41  *
42  * --- PC RCS information ---
43  * Revision 1.45  1994/11/18  22:50:21  john
44  * Changed shorts to ints in parameters.
45  *
46  * Revision 1.44  1994/11/13  13:04:07  john
47  * Added paged out bit in bitmap structure.  Commented out the
48  * poly code that is never used.
49  *
50  * Revision 1.43  1994/11/09  23:04:56  mike
51  * Add avg_color field.
52  *
53  * Revision 1.42  1994/10/27  00:53:35  john
54  * Added RLE Flag to bitmap structere.
55  *
56  * Revision 1.41  1994/10/26  23:55:52  john
57  * Took out roller; Took out inverse table.
58  *
59  * Revision 1.40  1994/08/11  17:59:12  mike
60  * Assembler merge functions written for 3 rotations of bitmaps.
61  *
62  * Revision 1.39  1994/08/10  12:24:56  matt
63  * Added support for colors fonts & kerned fonts
64  * Made our own font file format
65  *
66  * Revision 1.38  1994/07/27  18:30:18  john
67  * Took away the blending table.
68  *
69  * Revision 1.37  1994/06/16  15:25:06  mike
70  * Add flag BM_FLAG_NO_LIGHTING.
71  *
72  * Revision 1.36  1994/05/31  10:01:22  john
73  * *** empty log message ***
74  *
75  * Revision 1.35  1994/05/31  07:53:34  john
76  * *** empty log message ***
77  *
78  * Revision 1.34  1994/05/14  17:19:41  matt
79  * Added externs
80  *
81  * Revision 1.33  1994/05/12  17:33:09  john
82  * Added circle code.
83  *
84  * Revision 1.32  1994/05/06  12:50:16  john
85  * Added supertransparency; neatend things up; took out warnings.
86  *
87  * Revision 1.31  1994/05/04  10:06:06  john
88  * Added flag for bitmap super-transparency.
89  *
90  * Revision 1.30  1994/05/03  19:38:56  john
91  * *** empty log message ***
92  *
93  * Revision 1.29  1994/04/22  11:16:05  john
94  * *** empty log message ***
95  *
96  * Revision 1.28  1994/04/08  16:59:32  john
97  * Add fading poly's; Made palette fade 32 instead of 16.
98  *
99  * Revision 1.27  1994/03/16  17:29:52  john
100  * *** empty log message ***
101  *
102  * Revision 1.26  1994/03/16  17:20:51  john
103  * Added slow palette searching options.
104  *
105  * Revision 1.25  1994/03/14  17:59:20  john
106  * Added function to check bitmap's transparency.
107  *
108  * Revision 1.24  1994/03/14  16:56:26  john
109  * Changed grs_bitmap structure to include bm_flags.
110  *
111  * Revision 1.23  1994/02/18  15:32:30  john
112  * *** empty log message ***
113  *
114  * Revision 1.22  1994/01/25  11:40:48  john
115  * Added gr_check_mode function.
116  *
117  * Revision 1.21  1994/01/12  13:45:24  john
118  * Added scaler.
119  *
120  * Revision 1.20  1993/12/21  19:58:24  john
121  * added selector stuff
122  *
123  * Revision 1.19  1993/12/21  11:40:40  john
124  * *** empty log message ***
125  *
126  * Revision 1.18  1993/12/09  15:02:08  john
127  * Changed palette stuff majorly
128  *
129  * Revision 1.17  1993/12/07  12:32:05  john
130  * moved bmd_palette to gr_palette
131  *
132  * Revision 1.16  1993/11/28  12:08:06  mike
133  * Change prototype for rotate_bitmap.
134  *
135  * Revision 1.15  1993/11/18  14:22:51  mike
136  * Add prototype for rotate_bitmap.
137  *
138  * Revision 1.14  1993/11/17  19:00:59  mike
139  * Add prototype for test_rotate_bitmap
140  *
141  * Revision 1.13  1993/11/16  11:28:58  john
142  * *** empty log message ***
143  *
144  * Revision 1.12  1993/10/26  13:17:43  john
145  * *** empty log message ***
146  *
147  * Revision 1.11  1993/10/15  16:23:37  john
148  * y
149  *
150  * Revision 1.10  1993/09/28  15:32:33  john
151  * added def for save/restore vidmode
152  *
153  * Revision 1.9  1993/09/28  12:51:46  matt
154  * Added aspect ratio to grs_screen structure
155  *
156  * Revision 1.8  1993/09/26  22:45:12  matt
157  * Changed prototypes for line functions to take fixes, not ints.
158  *
159  * Revision 1.7  1993/09/26  18:58:16  john
160  * fadein/out stuff
161  *
162  * Revision 1.6  1993/09/14  16:26:44  matt
163  * Changed gr_change_mode() to be gr_set_mode()
164  *
165  * Revision 1.4  1993/09/14  13:08:45  john
166  * added gr_change_mode
167  *
168  * Revision 1.3  1993/09/08  13:56:03  matt
169  * Put 'if' block around body of file; added bitmap type BM_RGB15
170  *
171  * Revision 1.2  1993/09/08  13:02:14  john
172  * Changed structure definitions a bit.
173  *
174  * Revision 1.1  1993/09/08  11:25:15  john
175  * Initial revision
176  *
177  *
178  */
179
180 #ifndef _GR_H
181 #define _GR_H
182
183 #include "pstypes.h"
184 #include "fix.h"
185
186 #if defined(MACINTOSH) || defined(MACDATA)
187 #error native mac data currently not supported
188 #define SWAP_0_255              // swap black and white
189 #define TRANSPARENCY_COLOR  0   // palette entry of transparency color -- 0 on the mac
190 #define TRANSPARENCY_COLOR_STR  "0"
191 #else /* defined(MACINTOSH) || defined(MACDATA) */
192 /* #undef  SWAP_0_255 */        // no swapping for PC people
193 #define TRANSPARENCY_COLOR  255 // palette entry of transparency color -- 255 on the PC
194 #define TRANSPARENCY_COLOR_STR  "255"
195 #endif /* defined(MACINTOSH) || defined(MACDATA) */
196
197 #define GR_FADE_LEVELS 34
198 #define GR_ACTUAL_FADE_LEVELS 32
199
200 #define GWIDTH  grd_curcanv->cv_bitmap.bm_w
201 #define GHEIGHT grd_curcanv->cv_bitmap.bm_h
202 #define SWIDTH  (grd_curscreen->sc_w)
203 #define SHEIGHT (grd_curscreen->sc_h)
204
205 #define MAX_BMP_SIZE(width, height) (4 + ((width) + 2) * (height))
206
207 extern int Gr_scanline_darkening_level;
208
209 typedef struct _grs_point {
210         fix x,y;
211 } grs_point;
212
213 //these are control characters that have special meaning in the font code
214
215 #define CC_COLOR        1   //next char is new foreground color
216 #define CC_LSPACING     2   //next char specifies line spacing
217 #define CC_UNDERLINE    3   //next char is underlined
218
219 //now have string versions of these control characters (can concat inside a string)
220
221 #define CC_COLOR_S      "\x1"   //next char is new foreground color
222 #define CC_LSPACING_S   "\x2"   //next char specifies line spacing
223 #define CC_UNDERLINE_S  "\x3"   //next char is underlined
224
225 #define BM_LINEAR   0
226 #define BM_MODEX    1
227 #define BM_SVGA     2
228 #define BM_RGB15    3   //5 bits each r,g,b stored at 16 bits
229 #define BM_SVGA15   4
230 #ifdef OGL
231 #define BM_OGL      5
232 #endif /* def OGL */
233
234 //@@// Define these modes for Gameplay too, since the game was developed under
235 //@@// DOS, we will adapt these modes to other systems thru rendering.
236 //@@#define SM_ORIGINAL         -1
237 //@@#define SM_320x200C     0
238 //@@#define SM_320x200U     1
239 //@@#define SM_320x240U     2
240 //@@#define SM_360x200U     3
241 //@@#define SM_360x240U     4
242 //@@#define SM_376x282U     5
243 //@@#define SM_320x400U     6
244 //@@#define SM_320x480U     7
245 //@@#define SM_360x400U     8
246 //@@#define SM_360x480U     9
247 //@@#define SM_360x360U     10
248 //@@#define SM_376x308U     11
249 //@@#define SM_376x564U     12
250 //@@#define SM_640x400V     13
251 //@@#define SM_640x480V     14
252 //@@#define SM_800x600V     15
253 //@@#define SM_1024x768V    16
254 //@@#define SM_640x480V15   17
255 //@@#define SM_800x600V15   18
256
257 #define SM(w,h) ((((u_int32_t)w)<<16)+(((u_int32_t)h)&0xFFFF))
258 #define SM_W(m) (m>>16)
259 #define SM_H(m) (m&0xFFFF)
260
261
262 #define BM_FLAG_TRANSPARENT         1
263 #define BM_FLAG_SUPER_TRANSPARENT   2
264 #define BM_FLAG_NO_LIGHTING         4
265 #define BM_FLAG_RLE                 8   // A run-length encoded bitmap.
266 #define BM_FLAG_PAGED_OUT           16  // This bitmap's data is paged out.
267 #define BM_FLAG_RLE_BIG             32  // for bitmaps that RLE to > 255 per row (i.e. cockpits)
268
269 typedef struct _grs_bitmap {
270         short   bm_x,bm_y;  // Offset from parent's origin
271         short   bm_w,bm_h;  // width,height
272         sbyte   bm_type;    // 0=Linear, 1=ModeX, 2=SVGA
273         sbyte   bm_flags;   // bit 0 on means it has transparency.
274                             // bit 1 on means it has supertransparency
275                             // bit 2 on means it doesn't get passed through lighting.
276         short   bm_rowsize; // unsigned char offset to next row
277         unsigned char *     bm_data;    // ptr to pixel data...
278                                         //   Linear = *parent+(rowsize*y+x)
279                                         //   ModeX = *parent+(rowsize*y+x/4)
280                                         //   SVGA = *parent+(rowsize*y+x)
281         unsigned short      bm_handle;  //for application.  initialized to 0
282         ubyte   avg_color;  //  Average color of all pixels in texture map.
283         sbyte   unused;     // to 4-byte align.
284 #ifdef OGL
285         struct _ogl_texture *gltexture;
286         struct _grs_bitmap  *bm_parent;
287 #endif /* def OGL */
288 } grs_bitmap;
289
290 //font structure
291 typedef struct _grs_font {
292         short       ft_w;           // Width in pixels
293         short       ft_h;           // Height in pixels
294         short       ft_flags;       // Proportional?
295         short       ft_baseline;    //
296         ubyte       ft_minchar;     // First char defined by this font
297         ubyte       ft_maxchar;     // Last char defined by this font
298         short       ft_bytewidth;   // Width in unsigned chars
299         ubyte     * ft_data;        // Ptr to raw data.
300         ubyte    ** ft_chars;       // Ptrs to data for each char (required for prop font)
301         short     * ft_widths;      // Array of widths (required for prop font)
302         ubyte     * ft_kerndata;    // Array of kerning triplet data
303 #ifdef OGL
304         // These fields do not participate in disk i/o!
305         grs_bitmap *ft_bitmaps;
306         grs_bitmap ft_parent_bitmap;
307 #endif /* def OGL */
308 } __pack__ grs_font;
309
310 #define GRS_FONT_SIZE 28    // how much space it takes up on disk
311
312 typedef struct _grs_canvas {
313         grs_bitmap  cv_bitmap;      // the bitmap for this canvas
314         short       cv_color;       // current color
315         short       cv_drawmode;    // fill,XOR,etc.
316         grs_font *  cv_font;        // the currently selected font
317         short       cv_font_fg_color;   // current font foreground color (-1==Invisible)
318         short       cv_font_bg_color;   // current font background color (-1==Invisible)
319 } grs_canvas;
320
321 //shortcuts
322 #define cv_w cv_bitmap.bm_w
323 #define cv_h cv_bitmap.bm_h
324
325 typedef struct _grs_screen {    // This is a video screen
326         grs_canvas  sc_canvas;  // Represents the entire screen
327         int     sc_mode;        // Video mode number
328         short   sc_w, sc_h;     // Actual Width and Height
329         fix     sc_aspect;      //aspect ratio (w/h) for this screen
330 } grs_screen;
331
332
333 //=========================================================================
334 // System functions:
335 // setup and set mode. this creates a grs_screen structure and sets
336 // grd_curscreen to point to it.  grs_curcanv points to this screen's
337 // canvas.  Saves the current VGA state and screen mode.
338
339 int gr_init(void);
340
341 // This function sets up the main screen.  It should be called whenever
342 // the video mode changes.
343 int gr_init_screen(int mode, int w, int h, int x, int y, int rowsize, ubyte *data);
344
345 int gr_check_mode(u_int32_t mode);
346 int gr_set_mode(u_int32_t mode);
347
348
349 // These 4 functions actuall change screen colors.
350
351 extern void gr_pal_fade_out(unsigned char * pal);
352 extern void gr_pal_fade_in(unsigned char * pal);
353 extern void gr_pal_clear(void);
354 extern void gr_pal_setblock( int start, int number, unsigned char * pal );
355 extern void gr_pal_getblock( int start, int number, unsigned char * pal );
356
357
358 extern unsigned char *gr_video_memory;
359                                                     // All graphic modules will define this value.
360
361 //shut down the 2d.  Restore the screen mode.
362 void gr_close(void);
363
364 //=========================================================================
365 // Canvas functions:
366
367 // Makes a new canvas. allocates memory for the canvas and its bitmap,
368 // including the raw pixel buffer.
369
370 grs_canvas *gr_create_canvas(int w, int h);
371 #if defined(POLY_ACC)
372 grs_canvas *gr_create_canvas2(int w, int h, int type);
373 #endif /* def POLY_ACC */
374
375 // Creates a canvas that is part of another canvas.  this can be used to make
376 // a window on the screen.  the canvas structure is malloc'd; the address of
377 // the raw pixel data is inherited from the parent canvas.
378
379 grs_canvas *gr_create_sub_canvas(grs_canvas *canv,int x,int y,int w, int h);
380
381 // Initialize the specified canvas. the raw pixel data buffer is passed as
382 // a parameter. no memory allocation is performed.
383
384 void gr_init_canvas(grs_canvas *canv,unsigned char *pixdata,int pixtype, int w,int h);
385
386 // Initialize the specified sub canvas. no memory allocation is performed.
387
388 void gr_init_sub_canvas(grs_canvas *new,grs_canvas *src,int x,int y,int w, int h);
389
390 // Free up the canvas and its pixel data.
391
392 void gr_free_canvas(grs_canvas *canv);
393
394 // Free up the canvas. do not free the pixel data, which belongs to the
395 // parent canvas.
396
397 void gr_free_sub_canvas(grs_canvas *canv);
398
399 // Clear the current canvas to the specified color
400 void gr_clear_canvas(int color);
401
402 //=========================================================================
403 // Bitmap functions:
404
405 // Allocate a bitmap and its pixel data buffer.
406 grs_bitmap *gr_create_bitmap(int w,int h);
407
408 // Allocated a bitmap and makes its data be raw_data that is already somewhere.
409 grs_bitmap *gr_create_bitmap_raw(int w, int h, unsigned char * raw_data );
410
411 #if defined(POLY_ACC)
412 // Allocates a bitmap of a specific type. data is either NULL or raw data.
413 grs_bitmap *gr_create_bitmap2(int w, int h, int type, void *data );
414 #endif /* def POLY_ACC */
415
416 // Creates a bitmap which is part of another bitmap
417 grs_bitmap *gr_create_sub_bitmap(grs_bitmap *bm,int x,int y,int w, int h);
418
419 // Free the bitmap and its pixel data
420 void gr_free_bitmap(grs_bitmap *bm);
421
422 // Free the bitmap's data
423 void gr_free_bitmap_data (grs_bitmap *bm);
424 void gr_init_bitmap_data (grs_bitmap *bm);
425
426 // Free the bitmap, but not the pixel data buffer
427 void gr_free_sub_bitmap(grs_bitmap *bm);
428
429 void gr_bm_pixel( grs_bitmap * bm, int x, int y, unsigned char color );
430 void gr_bm_upixel( grs_bitmap * bm, int x, int y, unsigned char color );
431 void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
432 void gr_bm_ubitblt( int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
433 void gr_bm_ubitbltm(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
434
435 #ifdef MACINTOSH
436 void gr_bm_ubitblt_double(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap *src, grs_bitmap *dest);
437 void gr_linear_movsd_double(ubyte *src, ubyte *dest, int num_pixels);
438 #endif /* def MACINTOSH */
439
440 void gr_update_buffer( void * sbuf1, void * sbuf2, void * dbuf, int size );
441
442 void gr_set_transparent(grs_bitmap *pbm, int bTransparent);
443
444 //=========================================================================
445 // Color functions:
446
447 // When this function is called, the guns are set to gr_palette, and
448 // the palette stays the same until gr_close is called
449
450 void gr_use_palette_table(char * filename );
451 void gr_copy_palette(ubyte *gr_palette, ubyte *pal, int size);
452
453 //=========================================================================
454 // Drawing functions:
455
456 // For solid, XOR, or other fill modes.
457 int gr_set_drawmode(int mode);
458
459 // Sets the color in the current canvas.  should be a macro
460 // Use: gr_setcolor(int color);
461 void gr_setcolor(int color);
462
463 // Draw a polygon into the current canvas in the current color and drawmode.
464 // verts points to an ordered list of x,y pairs.  the polygon should be
465 // convex; a concave polygon will be handled in some reasonable manner,
466 // but not necessarily shaded as a concave polygon. It shouldn't hang.
467 // probably good solution is to shade from minx to maxx on each scan line.
468 // int should really be fix
469 int gr_poly(int nverts,int *verts);
470 int gr_upoly(int nverts,int *verts);
471
472
473 // Draws a point into the current canvas in the current color and drawmode.
474 void gr_pixel(int x,int y);
475 void gr_upixel(int x,int y);
476
477 // Gets a pixel;
478 unsigned char gr_gpixel( grs_bitmap * bitmap, int x, int y );
479 unsigned char gr_ugpixel( grs_bitmap * bitmap, int x, int y );
480
481 // Draws a line into the current canvas in the current color and drawmode.
482 int gr_line(fix x0,fix y0,fix x1,fix y1);
483 int gr_uline(fix x0,fix y0,fix x1,fix y1);
484
485 // Draws an anti-aliased line into the current canvas in the current color and drawmode.
486 int gr_aaline(fix x0,fix y0,fix x1,fix y1);
487 int gr_uaaline(fix x0,fix y0,fix x1,fix y1);
488
489 // Draw the bitmap into the current canvas at the specified location.
490 void gr_bitmap(int x,int y,grs_bitmap *bm);
491 void gr_ubitmap(int x,int y,grs_bitmap *bm);
492 void gr_bitmap_scale_to(grs_bitmap *src, grs_bitmap *dst);
493 void show_fullscr(grs_bitmap *bm);
494
495 // bitmap function with transparency
496 void gr_bitmapm( int x, int y, grs_bitmap *bm );
497 void gr_ubitmapm( int x, int y, grs_bitmap *bm );
498
499 // Draw a rectangle into the current canvas.
500 void gr_rect(int left,int top,int right,int bot);
501 void gr_urect(int left,int top,int right,int bot);
502
503 // Draw a filled circle
504 int gr_disk(fix x,fix y,fix r);
505 int gr_udisk(fix x,fix y,fix r);
506
507 // Draw an outline circle
508 int gr_circle(fix x,fix y,fix r);
509 int gr_ucircle(fix x,fix y,fix r);
510
511 // Draw an unfilled rectangle into the current canvas
512 void gr_box(int left,int top,int right,int bot);
513 void gr_ubox(int left,int top,int right,int bot);
514
515 void gr_scanline( int x1, int x2, int y );
516 void gr_uscanline( int x1, int x2, int y );
517
518
519 // Reads in a font file... current font set to this one.
520 grs_font * gr_init_font( char * fontfile );
521 void gr_close_font( grs_font * font );
522
523 //remap a font, re-reading its data & palette
524 void gr_remap_font( grs_font *font, char * fontname, char *font_data );
525
526 //remap (by re-reading) all the color fonts
527 void gr_remap_color_fonts();
528 void gr_remap_mono_fonts();
529
530 // Writes a string using current font. Returns the next column after last char.
531 void gr_set_fontcolor( int fg, int bg );
532 void gr_set_curfont( grs_font * new );
533 int gr_string(int x, int y, char *s );
534 int gr_ustring(int x, int y, char *s );
535 int gr_printf( int x, int y, char * format, ... );
536 int gr_uprintf( int x, int y, char * format, ... );
537 void gr_get_string_size(char *s, int *string_width, int *string_height, int *average_width );
538
539
540 //  From roller.c
541 void rotate_bitmap(grs_bitmap *bp, grs_point *vertbuf, int light_value);
542
543 // From scale.c
544 void scale_bitmap(grs_bitmap *bp, grs_point *vertbuf, int orientation );
545
546 //===========================================================================
547 // Global variables
548 extern grs_canvas *grd_curcanv;             //active canvas
549 extern grs_screen *grd_curscreen;           //active screen
550 extern unsigned char Test_bitmap_data[64*64];
551
552 //shortcut to look at current font
553 #define grd_curfont grd_curcanv->cv_font
554
555 extern int gr_renderstats;
556
557 extern unsigned int FixDivide( unsigned int x, unsigned int y );
558
559 extern void gr_show_canvas( grs_canvas *canv );
560 extern void gr_set_current_canvas( grs_canvas *canv );
561
562 //flags for fonts
563 #define FT_COLOR        1
564 #define FT_PROPORTIONAL 2
565 #define FT_KERNED       4
566
567 extern void gr_vesa_update( grs_bitmap * source1, grs_bitmap * dest, grs_bitmap * source2 );
568
569 // Special effects
570 extern void gr_snow_out(int num_dots);
571
572 extern void test_rotate_bitmap(void);
573 extern void rotate_bitmap(grs_bitmap *bp, grs_point *vertbuf, int light_value);
574
575 extern ubyte gr_palette[256*3];
576 extern ubyte gr_fade_table[256*GR_FADE_LEVELS];
577 extern ubyte gr_inverse_table[32*32*32];
578
579 extern ushort gr_palette_selector;
580 extern ushort gr_inverse_table_selector;
581 extern ushort gr_fade_table_selector;
582
583 // Remaps a bitmap into the current palette. If transparent_color is
584 // between 0 and 255 then all occurances of that color are mapped to
585 // whatever color the 2d uses for transparency. This is normally used
586 // right after a call to iff_read_bitmap like this:
587 //              iff_error = iff_read_bitmap(filename,new,BM_LINEAR,newpal);
588 //              if (iff_error != IFF_NO_ERROR) Error("Can't load IFF file <%s>, error=%d",filename,iff_error);
589 //              if ( iff_has_transparency )
590 //                      gr_remap_bitmap( new, newpal, iff_transparent_color );
591 //              else
592 //                      gr_remap_bitmap( new, newpal, -1 );
593 extern void gr_remap_bitmap( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color );
594
595 // Same as above, but searches using gr_find_closest_color which uses
596 // 18-bit accurracy instead of 15bit when translating colors.
597 extern void gr_remap_bitmap_good( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color );
598
599 extern void build_colormap_good( ubyte * palette, ubyte * colormap, int * freq );
600
601 extern void gr_palette_step_up( int r, int g, int b );
602
603 extern void gr_bitmap_check_transparency( grs_bitmap * bmp );
604
605 // Allocates a selector that has a base address at 'address' and length 'size'.
606 // Returns 0 if successful... BE SURE TO CHECK the return value since there
607 // is a limited number of selectors available!!!
608 extern int get_selector( void * address, int size, unsigned int * selector );
609
610 // Assigns a selector to a bitmap. Returns 0 if successful.  BE SURE TO CHECK
611 // this return value since there is a limited number of selectors!!!!!!!
612 extern int gr_bitmap_assign_selector( grs_bitmap * bmp );
613
614 //#define GR_GETCOLOR(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
615 //#define gr_getcolor(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
616 //#define BM_XRGB(r,g,b) (gr_inverse_table[( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )])
617
618 #define BM_RGB(r,g,b) ( (((r)&31)<<10) | (((g)&31)<<5) | ((b)&31) )
619 #define BM_XRGB(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
620 #define GR_GETCOLOR(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
621 #define gr_getcolor(r,g,b) gr_find_closest_color( (r)*2,(g)*2,(b)*2 )
622
623 // Given: r,g,b, each in range of 0-63, return the color index that
624 // best matches the input.
625 int gr_find_closest_color( int r, int g, int b );
626 int gr_find_closest_color_15bpp( int rgb );
627
628 extern void gr_merge_textures( ubyte * lower, ubyte * upper, ubyte * dest );
629 extern void gr_merge_textures_1( ubyte * lower, ubyte * upper, ubyte * dest );
630 extern void gr_merge_textures_2( ubyte * lower, ubyte * upper, ubyte * dest );
631 extern void gr_merge_textures_3( ubyte * lower, ubyte * upper, ubyte * dest );
632
633 extern void gr_update(void);
634
635 /*
636  * currently SDL and OGL are the only things that supports toggling
637  * fullscreen.  otherwise add other checks to the #if -MPM
638  */
639 #if (defined(SDL_VIDEO) || defined(OGL))
640 #define GR_SUPPORTS_FULLSCREEN_TOGGLE
641
642 /*
643  * must return 0 if windowed, 1 if fullscreen
644  */
645 int gr_check_fullscreen(void);
646
647 /*
648  * returns state after toggling (ie, same as if you had called
649  * check_fullscreen immediatly after)
650  */
651 int gr_toggle_fullscreen(void);
652
653 #endif /* defined(SDL_VIDEO) || defined(OGL)) */
654
655 /* currently only OGL can toggle in the menus, because its screen data
656  * is not used (and stays in the same place).  whereas software modes,
657  * toggling fullscreen would very likely make the data buffer point to
658  * a different location, and all the subbitmaps of it would have
659  * invalid addresses in them. */
660 #ifdef OGL
661 #define GR_SUPPORTS_FULLSCREEN_MENU_TOGGLE
662 #endif
663 int gr_toggle_fullscreen_menu(void);//returns state after toggling (ie, same as if you had called check_fullscreen immediatly after)
664
665 #endif /* def _GR_H */