]> icculus.org git repositories - taylor/freespace2.git/blob - include/2d.h
added copyright header
[taylor/freespace2.git] / include / 2d.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell 
5  * or otherwise commercially exploit the source or things you created based on
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/Graphics/2d.h $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Header file for 2d primitives.
16  *
17  * $Log$
18  * Revision 1.2  2002/06/09 04:41:12  relnev
19  * added copyright header
20  *
21  * Revision 1.1.1.1  2002/05/03 03:28:12  root
22  * Initial import.
23  *
24  * 
25  * 16    8/30/99 5:01p Dave
26  * Made d3d do less state changing in the nebula. Use new chat server for
27  * PXO.
28  * 
29  * 15    8/16/99 9:45a Jefff
30  * changes to cursor management to allow a 2nd temporary cursor
31  * 
32  * 14    7/15/99 3:07p Dave
33  * 32 bit detection support. Mouse coord commandline.
34  * 
35  * 13    7/14/99 9:42a Dave
36  * Put in clear_color debug function. Put in base for 3dnow stuff / P3
37  * stuff
38  * 
39  * 12    7/09/99 9:51a Dave
40  * Added thick polyline code.
41  * 
42  * 11    6/29/99 10:35a Dave
43  * Interface polygon bitmaps! Whee!
44  * 
45  * 10    2/03/99 11:44a Dave
46  * Fixed d3d transparent textures.
47  * 
48  * 9     1/30/99 5:08p Dave
49  * More new hi-res stuff.Support for nice D3D textures.
50  * 
51  * 8     1/24/99 11:36p Dave
52  * First full rev of beam weapons. Very customizable. Removed some bogus
53  * Int3()'s in low level net code.
54  * 
55  * 7     12/21/98 5:02p Dave
56  * Modified all hud elements to be multi-resolution friendly.
57  * 
58  * 6     12/18/98 1:49a Dave
59  * Fixed Fred initialization problem resulting from hi-res mode changes.
60  * 
61  * 5     12/18/98 1:13a Dave
62  * Rough 1024x768 support for Direct3D. Proper detection and usage through
63  * the launcher.
64  * 
65  * 4     12/06/98 2:36p Dave
66  * Drastically improved nebula fogging.
67  * 
68  * 3     11/11/98 5:37p Dave
69  * Checkin for multiplayer testing.
70  * 
71  * 2     10/07/98 10:52a Dave
72  * Initial checkin.
73  * 
74  * 1     10/07/98 10:48a Dave
75  * 
76  * 75    5/20/98 9:45p John
77  * added code so the places in code that change half the palette don't
78  * have to clear the screen.
79  * 
80  * 74    5/06/98 5:30p John
81  * Removed unused cfilearchiver.  Removed/replaced some unused/little used
82  * graphics functions, namely gradient_h and _v and pixel_sp.   Put in new
83  * DirectX header files and libs that fixed the Direct3D alpha blending
84  * problems.
85  * 
86  * 73    4/14/98 12:15p John
87  * Made 16-bpp movies work.
88  * 
89  * 72    4/10/98 5:20p John
90  * Changed RGB in lighting structure to be ubytes.  Removed old
91  * not-necessary 24 bpp software stuff.
92  * 
93  * 71    3/25/98 8:07p John
94  * Restructured software rendering into two modules; One for windowed
95  * debug mode and one for DirectX fullscreen.   
96  * 
97  * 70    3/24/98 8:31a John
98  * Added function to set gamma
99  * 
100  * 69    3/17/98 5:55p John
101  * Added code to dump Glide frames.   Moved Allender's  "hack" code out of
102  * Freespace.cpp into the proper place, graphics lib.
103  * 
104  * 68    3/12/98 5:36p John
105  * Took out any unused shaders.  Made shader code take rgbc instead of
106  * matrix and vector since noone used it like a matrix and it would have
107  * been impossible to do in hardware.   Made Glide implement a basic
108  * shader for online help.  
109  * 
110  * 67    3/10/98 4:18p John
111  * Cleaned up graphics lib.  Took out most unused gr functions.   Made D3D
112  * & Glide have popups and print screen.  Took out all >8bpp software
113  * support.  Made Fred zbuffer.  Made zbuffer allocate dynamically to
114  * support Fred.  Made zbuffering key off of functions rather than one
115  * global variable.
116  * 
117  * 66    2/07/98 7:50p John
118  * Added code so that we can use the old blending type of alphacolors if
119  * we want to.  Made the stars use them.
120  * 
121  * 65    1/08/98 1:54p John
122  * Added code to fix palette problems when Alt+Tabbing
123  * 
124  * 64    12/30/97 6:46p John
125  * Added first rev of palette fade in out functions
126  * 
127  * 63    12/03/97 10:47a John
128  * added functions to save/restore entire screens.
129  * 
130  * 62    12/02/97 3:59p John
131  * Added first rev of thruster glow, along with variable levels of
132  * translucency, which retquired some restructing of palman.
133  * 
134  * 61    11/20/97 9:51a John
135  * added code to force screen to 16-bit even if rendering 8.
136  * 
137  * 60    11/03/97 10:08p Hoffoss
138  * Changed gr_get_string_size to utilize an optional length specifier, if
139  * you want to use non-null terminated strings.
140  * 
141  * 59    10/19/97 12:55p John
142  * new code to lock / unlock surfaces for smooth directx integration.
143  * 
144  * 58    10/03/97 10:02a John
145  * added better comments for lines.
146  * 
147  * 57    10/03/97 9:10a John
148  * added better antialiased line drawer
149  * 
150  * 56    9/23/97 10:45a John
151  * made so you can tell bitblt code to rle a bitmap by passing flag to
152  * gr_set_bitmap
153  * 
154  * 55    9/07/97 10:01p Lawrance
155  * add in support for animating mouse pointer
156  * 
157  * 54    8/04/97 4:47p John
158  * added gr_aascaler.
159  * 
160  * 53    7/16/97 3:07p John
161  * 
162  * 52    7/10/97 2:06p John
163  * added code to specify alphablending type for bitmaps.
164  * 
165  * 51    6/25/97 2:35p John
166  * added some functions to use the windows font for Fred.
167  * 
168  * 50    6/17/97 7:04p John
169  * added d3d support for gradients.
170  * fixed some color bugs by adding screen signatures instead of watching
171  * flags and palette changes.
172  * 
173  * 49    6/17/97 12:03p John
174  * Moved color/alphacolor functions into their own module.  Made all color
175  * functions be part of the low-level graphics drivers, not just the
176  * grsoft.
177  * 
178  * 48    6/13/97 5:35p John
179  * added some antialiased bitmaps and lines
180  * 
181  * 47    6/11/97 5:49p John
182  * Changed palette code to only recalculate alphacolors when needed, not
183  * when palette changes.
184  * 
185  * 46    6/11/97 4:11p John
186  * addec function to get font height
187  * 
188  * 45    6/11/97 1:12p John
189  * Started fixing all the text colors in the game.
190  * 
191  * 44    6/09/97 9:24a John
192  * Changed the way fonts are set.
193  * 
194  * 43    6/06/97 4:41p John
195  * Fixed alpha colors to be smoothly integrated into gr_set_color_fast
196  * code.
197  * 
198  * 42    6/05/97 4:53p John
199  * First rev of new antialiased font stuff.
200  * 
201  * 41    5/29/97 3:09p John
202  * Took out debug menu.  
203  * Made software scaler draw larger bitmaps.
204  * Optimized Direct3D some.
205  * 
206  * 40    5/14/97 10:53a John
207  * fixed some discrepencies between d3d and software palette setting.
208  * 
209  * 39    5/12/97 3:09p John
210  * fixed a stupid macro bug.
211  * 
212  * 38    5/12/97 12:27p John
213  * Restructured Graphics Library to add support for multiple renderers.
214  * 
215  * 37    4/28/97 4:46p John
216  * 
217  * 36    4/23/97 5:26p John
218  * First rev of new debug console stuff.
219  * 
220  * 35    3/12/97 2:51p John
221  * Added some test code for tmapper.  
222  * 
223  * 34    3/12/97 9:25a John
224  * fixed a bug with zbuffering.  Reenabled it by default.
225  * 
226  * 33    3/04/97 3:36p John
227  * took out old debug "h' key.   Made zbuffer flag bit bit field so you
228  * can turn on/off each value.   Fixed a bug with turret rotation where
229  * different handedness turrets wouldn't work.   Fixed a bug with two
230  * large ships within each other's radius not rendering correctly.
231  * 
232  * 32    1/27/97 9:08a John
233  * Added code to turn zbuffering on/off in call to g3_start_frame
234  * 
235  * 31    1/09/97 11:35a John
236  * Added some 2d functions to get/put screen images.
237  * 
238  * 30    1/07/97 2:01p John
239  * Fairly fast zbuffering for object sorting.
240  * 
241  * 29    1/06/97 2:44p John
242  * Added in slow (but correct) zbuffering
243  * 
244  * 28    12/11/96 12:41p John
245  * Added new code to draw 3d laser using 2d ellipses.
246  * 
247  * 27    12/10/96 10:37a John
248  * Restructured texture mapper to remove some overhead from each scanline
249  * setup.  This gave about a 30% improvement drawing trans01.pof, which is
250  * a really complex model.  In the process, I cleaned up the scanline
251  * functions and separated them into different modules for each pixel
252  * depth.   
253  * 
254  * 26    11/21/96 11:21a John
255  * Made gr_get_string_size handle multi line text.
256  * Took out gr_get_multiline_string_size
257  * 
258  * 25    11/20/96 10:01a Hoffoss
259  * A few minor improvements.
260  * 
261  * 24    11/18/96 4:35p Allender
262  * new 16bpp gradient functions
263  * 
264  * 23    11/18/96 12:36p John
265  * Added code to dump screen to a PCX file.
266  * 
267  * 22    11/18/96 11:40a John
268  * Added faster gr_set_color method.
269  * 
270  * 21    11/15/96 3:34p Allender
271  * added bpp variable to the shader structure
272  * 
273  * 20    11/13/96 6:47p John
274  * Added gr_flip function.
275  * 
276  * 19    11/13/96 10:10a John
277  * Increases MAX_WIDTH & HEIGHT for Jasen's massive 1600x1200 display.
278  * 
279  * 18    10/30/96 10:36a Lawrance
280  * added gr_diamond function
281  * 
282  * 17    10/26/96 2:56p John
283  * Got gradient code working.
284  * 
285  * 16    10/26/96 1:40p John
286  * Added some now primitives to the 2d library and
287  * cleaned up some old ones.
288  *
289  * $NoKeywords: $
290  */
291
292 #ifndef _GRAPHICS_H
293 #define _GRAPHICS_H
294
295 /* ========================= pixel plotters =========================
296 In the 2d/texture mapper, bitmaps to be drawn will be passed by number.
297 The 2d function will call a bmpman function to get the bitmap into whatever
298 format it needs.  Then it will render.   The only pixels that will ever 
299 get drawn go thru the 2d/texture mapper libraries only.   This will make
300 supporting accelerators and psx easier.   Colors will always be set with
301 the color set functions.
302
303 gr_surface_flip()       switch onscreen, offscreen
304
305 gr_set_clip(x,y,w,h)    // sets the clipping region
306 gr_reset_clip(x,y,w,h)  // sets the clipping region
307 gr_set_color --? 8bpp, 15bpp?
308 gr_set_font(int fontnum)
309 // see GR_ALPHABLEND defines for values for alphablend_mode
310 // see GR_BITBLT_MODE defines for bitblt_mode.
311 // Alpha = scaler for intensity
312 gr_set_bitmap( int bitmap_num, int alphblend_mode, int bitblt_mode, float alpha )       
313 gr_set_shader( int value )  0=normal -256=darken, 256=brighten
314 gr_set_palette( ubyte * palette ) 
315
316 gr_clear()      // clears entire clipping region
317 gr_bitmap(x,y)
318 gr_bitmap_ex(x,y,w,h,sx,sy)
319 gr_rect(x,y,w,h)
320 gr_shade(x,y,w,h)
321 gr_string(x,y,char * text)
322 gr_line(x1,y1,x2,y2)
323
324  
325 */
326
327 #include "pstypes.h"
328 #include "tmapper.h"
329
330 // This is a structure used by the shader to keep track
331 // of the values you want to use in the shade primitive.
332 typedef struct shader {
333         uint    screen_sig;                                     // current mode this is in
334         float   r,g,b,c;                                                // factors and constant
335         ubyte   lookup[256];
336 } shader;
337
338 #define AC_TYPE_NONE            0               // Not an alphacolor
339 #define AC_TYPE_HUD             1               // Doesn't change hue depending on background.  Used for HUD stuff.
340 #define AC_TYPE_BLEND   2               // Changes hue depending on background.  Used for stars, etc.
341
342 // NEVER REFERENCE THESE VALUES OUTSIDE OF THE GRAPHICS LIBRARY!!!
343 // If you need to get the rgb values of a "color" struct call
344 // gr_get_colors after calling gr_set_colors_fast.
345 typedef struct color {
346         uint            screen_sig;
347         ubyte           red;
348         ubyte           green;
349         ubyte           blue;
350         ubyte           alpha;
351         ubyte           ac_type;                                                        // The type of alphacolor.  See AC_TYPE_??? defines
352         int             is_alphacolor;
353         ubyte           raw8;
354         int             alphacolor;
355         int             magic;          
356 } color;
357
358 #define GR_ALPHABLEND_NONE                      0               // no blending
359 #define GR_ALPHABLEND_FILTER            1               // 50/50 mix of foreground, background, using intensity as alpha
360
361 #define GR_BITBLT_MODE_NORMAL           0               // Normal bitblting
362 #define GR_BITBLT_MODE_RLE                      1               // RLE would be faster
363
364 // fog modes
365 #define GR_FOGMODE_NONE                         0               // set this to turn off fog
366 #define GR_FOGMODE_FOG                          1               // linear fog
367
368 typedef struct screen {
369         uint    signature;                      // changes when mode or palette or width or height changes
370         int     max_w, max_h;           // Width and height
371         int     res;                                    // GR_640 or GR_1024
372         int     mode;                                   // What mode gr_init was called with.
373         float   aspect;                         // Aspect ratio
374         int     rowsize;                                // What you need to add to go to next row (includes bytes_per_pixel)
375         int     bits_per_pixel; // How many bits per pixel it is. (7,8,15,16,24,32)
376         int     bytes_per_pixel;        // How many bytes per pixel (1,2,3,4)
377         int     offset_x, offset_y;             // The offsets into the screen
378         int     clip_width, clip_height;
379
380         float fog_near, fog_far;
381
382         // the clip_l,r,t,b are used internally.  left and top are
383         // actually always 0, but it's nice to have the code work with
384         // arbitrary clipping regions.
385         int             clip_left, clip_right, clip_top, clip_bottom;   
386
387         int             current_alphablend_mode;                // See GR_ALPHABLEND defines above
388         int             current_bitblt_mode;                            // See GR_BITBLT_MODE defines above
389         int             current_fog_mode;                                       // See GR_FOGMODE_* defines above
390         int             current_bitmap;
391         int             current_bitmap_sx;                              // bitmap x section
392         int             current_bitmap_sy;                              // bitmap y section
393         color           current_color;
394         color           current_fog_color;                              // current fog color
395         color           current_clear_color;                            // current clear color
396         shader  current_shader;
397         float           current_alpha;
398         void            *offscreen_buffer;                              // NEVER ACCESS!  This+rowsize*y = screen offset
399         void            *offscreen_buffer_base;                 // Pointer to lowest address of offscreen buffer
400
401         //switch onscreen, offscreen
402         void (*gf_flip)();
403         void (*gf_flip_window)(uint _hdc, int x, int y, int w, int h );
404
405         // Sets the current palette
406         void (*gf_set_palette)(ubyte * new_pal, int restrict_alphacolor = 0);
407
408         // Fade the screen in/out
409         void (*gf_fade_in)(int instantaneous);
410         void (*gf_fade_out)(int instantaneous);
411
412         // Flash the screen
413         void (*gf_flash)( int r, int g, int b );
414
415         // sets the clipping region
416         void (*gf_set_clip)(int x, int y, int w, int h);
417
418         // resets the clipping region to entire screen
419         void (*gf_reset_clip)();
420
421         void (*gf_set_color)( int r, int g, int b );
422         void (*gf_get_color)( int * r, int * g, int * b );
423         void (*gf_init_color)( color * dst, int r, int g, int b );
424
425         void (*gf_init_alphacolor)( color * dst, int r, int g, int b, int alpha, int type=AC_TYPE_HUD );
426         void (*gf_set_color_fast)( color * dst );
427
428         void (*gf_set_font)(int fontnum);
429
430         // Sets the current bitmap
431         void (*gf_set_bitmap)( int bitmap_num, int alphablend=GR_ALPHABLEND_NONE, int bitbltmode=GR_BITBLT_MODE_NORMAL, float alpha=1.0f, int sx = -1, int sy = -1 );
432
433         // Call this to create a shader.   
434         // This function takes a while, so don't call it once a frame!
435         // r,g,b, and c should be between -1.0 and 1.0f
436
437         // The matrix is used as follows:
438         // Dest(r) = Src(r)*r + Src(g)*r + Src(b)*r + c;
439         // Dest(g) = Src(r)*g + Src(g)*g + Src(b)*g + c;
440         // Dest(b) = Src(r)*b + Src(g)*b + Src(b)*b + c;
441         // For instance, to convert to greyscale, use
442         // .3 .3 .3  0
443         // To turn everything green, use:
444         //  0 .3  0  0
445         void (*gf_create_shader)(shader * shade, float r, float g, float b, float c );
446
447         // Initialize the "shader" by calling gr_create_shader()
448         // Passing a NULL makes a shader that turns everything black.
449         void (*gf_set_shader)( shader * shade );
450
451         // clears entire clipping region to current color
452         void (*gf_clear)();
453
454         // void (*gf_bitmap)(int x,int y);
455         // void (*gf_bitmap_ex)(int x,int y,int w,int h,int sx,int sy);
456
457         void (*gf_aabitmap)(int x, int y);
458         void (*gf_aabitmap_ex)(int x, int y, int w, int h, int sx, int sy);
459
460         void (*gf_rect)(int x, int y, int w, int h);
461         void (*gf_shade)(int x, int y, int w, int h);
462         void (*gf_string)(int x, int y, char * text);
463
464         // Draw a gradient line... x1,y1 is bright, x2,y2 is transparent.
465         void (*gf_gradient)(int x1, int y1, int x2, int y2);
466  
467         void (*gf_circle)(int x, int y, int r);
468
469         // Integer line. Used to draw a fast but pixely line.  
470         void (*gf_line)(int x1, int y1, int x2, int y2);
471
472         // Draws an antialiased line is the current color is an 
473         // alphacolor, otherwise just draws a fast line.  This
474         // gets called internally by g3_draw_line.   This assumes
475         // the vertex's are already clipped, so call g3_draw_line
476         // not this if you have two 3d points.
477         void (*gf_aaline)(vertex *v1, vertex *v2);
478
479         void (*gf_pixel)( int x, int y );
480
481         // Scales current bitmap between va and vb with clipping
482         void (*gf_scaler)(vertex *va, vertex *vb );
483
484         // Scales current bitmap between va and vb with clipping, draws an aabitmap
485         void (*gf_aascaler)(vertex *va, vertex *vb );
486
487         // Texture maps the current bitmap.  See TMAP_FLAG_?? defines for flag values
488         void (*gf_tmapper)(int nv, vertex *verts[], uint flags );
489
490         // dumps the current screen to a file
491         void (*gf_print_screen)(char * filename);
492
493         // Call once before rendering anything.
494         void (*gf_start_frame)();
495
496         // Call after rendering is over.
497         void (*gf_stop_frame)();
498
499         // Retrieves the zbuffer mode.
500         int (*gf_zbuffer_get)();
501
502         // Sets mode.  Returns previous mode.
503         int (*gf_zbuffer_set)(int mode);
504
505         // Clears the zbuffer.  If use_zbuffer is FALSE, then zbuffering mode is ignored and zbuffer is always off.
506         void (*gf_zbuffer_clear)(int use_zbuffer);
507         
508         // Saves screen. Returns an id you pass to restore and free.
509         int (*gf_save_screen)();
510         
511         // Resets clip region and copies entire saved screen to the screen.
512         void (*gf_restore_screen)(int id);
513
514         // Frees up a saved screen.
515         void (*gf_free_screen)(int id);
516
517         // CODE FOR DUMPING FRAMES TO A FILE
518         // Begin frame dumping
519         void (*gf_dump_frame_start)( int first_frame_number, int nframes_between_dumps );
520
521         // Dump the current frame to file
522         void (*gf_dump_frame)();
523
524         // Dump the current frame to file
525         void (*gf_dump_frame_stop)();
526
527         // Sets the gamma
528         void (*gf_set_gamma)(float gamma);
529
530         // Lock/unlock the screen
531         // Returns non-zero if sucessful (memory pointer)
532         uint (*gf_lock)();
533         void (*gf_unlock)();
534
535         // grab a region of the screen. assumes data is large enough
536         void (*gf_get_region)(int front, int w, int h, ubyte *data);
537
538         // set fog attributes
539         void (*gf_fog_set)(int fog_mode, int r, int g, int b, float fog_near = -1.0f, float fog_far = -1.0f);   
540
541         // get the current pixel color in the framebuffer 
542         void (*gf_get_pixel)(int x, int y, int *r, int *g, int *b);
543
544         // poly culling
545         void (*gf_set_cull)(int cull);
546
547         // cross fade
548         void (*gf_cross_fade)(int bmap1, int bmap2, int x1, int y1, int x2, int y2, float pct);
549
550         // filtering
551         void (*gf_filter_set)(int filter);
552
553         // set a texture into cache. for sectioned bitmaps, pass in sx and sy to set that particular section of the bitmap
554         int (*gf_tcache_set)(int bitmap_id, int bitmap_type, float *u_scale, float *v_scale, int fail_on_full = 0, int sx = -1, int sy = -1, int force = 0);    
555
556         // set the color to be used when clearing the background
557         void (*gf_set_clear_color)(int r, int g, int b);
558 } screen;
559
560 // cpu types
561 extern int Gr_amd3d;
562 extern int Gr_katmai;
563 extern int Gr_cpu;      
564 extern int Gr_mmx;
565
566 // handy macro
567 #define GR_MAYBE_CLEAR_RES(bmap)                do  { int bmw = -1; int bmh = -1; if(bmap != -1){ bm_get_info( bmap, &bmw, &bmh); if((bmw != gr_screen.max_w) || (bmh != gr_screen.max_h)){gr_clear();} } else {gr_clear();} } while(0);
568
569 //Window's interface to set up graphics:
570 //--------------------------------------
571 // Call this at application startup
572
573 #define GR_SOFTWARE                                     (100)           // Software renderer using standard Win32 functions in a window.
574 #define GR_DIRECTDRAW                           (101)           // Software renderer using DirectDraw fullscreen.
575 #define GR_DIRECT3D                                     (102)           // Use Direct3d hardware renderer
576 #define GR_GLIDE                                                (103)           // Use Glide hardware renderer
577 #define GR_OPENGL                                               (104)           // Use OpenGl hardware renderer
578
579 // resolution constants   - always keep resolutions in ascending order and starting from 0  
580 #define GR_NUM_RESOLUTIONS                      2
581 #define GR_640                                                  0               // 640 x 480
582 #define GR_1024                                         1               // 1024 x 768
583
584 extern int gr_init(int res, int mode, int depth = 16, int fred_x = -1, int fred_y = -1 );
585
586 // Call this when your app ends.
587 extern void gr_close();
588
589 extern screen gr_screen;
590
591 #define GR_ZBUFF_NONE   0
592 #define GR_ZBUFF_WRITE  (1<<0)
593 #define GR_ZBUFF_READ   (1<<1)
594 #define GR_ZBUFF_FULL   (GR_ZBUFF_WRITE|GR_ZBUFF_READ)
595
596 // Returns -1 if couldn't init font, otherwise returns the
597 // font id number.  If you call this twice with the same typeface,
598 // it will return the same font number both times.  This font is
599 // then set to be the current font, and default font if none is 
600 // yet specified.
601 int gr_init_font( char * typeface );
602
603 // Does formatted printing.  This calls gr_string after formatting,
604 // so if you don't need to format the string, then call gr_string
605 // directly.
606 extern void _cdecl gr_printf( int x, int y, char * format, ... );
607
608 // Returns the size of the string in pixels in w and h
609 extern void gr_get_string_size( int *w, int *h, char * text, int len = 9999 );
610
611 // Returns the height of the current font
612 extern int gr_get_font_height();
613
614 extern void gr_set_palette(char *name, ubyte *palette, int restrict_to_128 = 0);
615
616 // These two functions use a Windows mono font.  Only for use
617 // in the editor, please.
618 void gr_get_string_size_win(int *w, int *h, char *text);
619 void gr_string_win(int x, int y, char *s );
620
621 // set the mouse pointer to a specific bitmap, used for animating cursors
622 #define GR_CURSOR_LOCK          1
623 #define GR_CURSOR_UNLOCK        2
624 void gr_set_cursor_bitmap(int n, int lock = 0);
625 int gr_get_cursor_bitmap();
626 extern int Web_cursor_bitmap;
627
628 // Called by OS when application gets/looses focus
629 extern void gr_activate(int active);
630
631 #define GR_CALL(x)                      (*x)
632
633 // These macros make the function indirection look like the
634 // old Descent-style gr_xxx calls.
635
636 #define gr_print_screen         GR_CALL(gr_screen.gf_print_screen)
637
638 #define gr_flip                         GR_CALL(gr_screen.gf_flip)
639 #define gr_flip_window          GR_CALL(gr_screen.gf_flip_window)
640
641 #define gr_set_clip                     GR_CALL(gr_screen.gf_set_clip)
642 #define gr_reset_clip           GR_CALL(gr_screen.gf_reset_clip)
643 #define gr_set_font                     GR_CALL(gr_screen.gf_set_font)
644
645 #define gr_init_color           GR_CALL(gr_screen.gf_init_color)
646 #define gr_init_alphacolor      GR_CALL(gr_screen.gf_init_alphacolor)
647 #define gr_set_color                    GR_CALL(gr_screen.gf_set_color)
648 #define gr_get_color                    GR_CALL(gr_screen.gf_get_color)
649 #define gr_set_color_fast       GR_CALL(gr_screen.gf_set_color_fast)
650
651 #define gr_set_bitmap           GR_CALL(gr_screen.gf_set_bitmap)
652
653 #define gr_create_shader        GR_CALL(gr_screen.gf_create_shader)
654 #define gr_set_shader           GR_CALL(gr_screen.gf_set_shader)
655 #define gr_clear                                GR_CALL(gr_screen.gf_clear)
656 // #define gr_bitmap                            GR_CALL(gr_screen.gf_bitmap)
657 // #define gr_bitmap_ex                 GR_CALL(gr_screen.gf_bitmap_ex)
658 #define gr_aabitmap                     GR_CALL(gr_screen.gf_aabitmap)
659 #define gr_aabitmap_ex          GR_CALL(gr_screen.gf_aabitmap_ex)
660 #define gr_rect                         GR_CALL(gr_screen.gf_rect)
661 #define gr_shade                                GR_CALL(gr_screen.gf_shade)
662 #define gr_string                               GR_CALL(gr_screen.gf_string)
663
664 #define gr_circle                               GR_CALL(gr_screen.gf_circle)
665
666 #define gr_line                         GR_CALL(gr_screen.gf_line)
667 #define gr_aaline                               GR_CALL(gr_screen.gf_aaline)
668 #define gr_pixel                                GR_CALL(gr_screen.gf_pixel)
669 #define gr_scaler                               GR_CALL(gr_screen.gf_scaler)
670 #define gr_aascaler                     GR_CALL(gr_screen.gf_aascaler)
671 #define gr_tmapper                      GR_CALL(gr_screen.gf_tmapper)
672
673 #define gr_gradient                     GR_CALL(gr_screen.gf_gradient)
674
675
676 #define gr_fade_in                      GR_CALL(gr_screen.gf_fade_in)
677 #define gr_fade_out                     GR_CALL(gr_screen.gf_fade_out)
678 #define gr_flash                                GR_CALL(gr_screen.gf_flash)
679
680 #define gr_zbuffer_get          GR_CALL(gr_screen.gf_zbuffer_get)
681 #define gr_zbuffer_set          GR_CALL(gr_screen.gf_zbuffer_set)
682 #define gr_zbuffer_clear        GR_CALL(gr_screen.gf_zbuffer_clear)
683
684 #define gr_save_screen          GR_CALL(gr_screen.gf_save_screen)
685 #define gr_restore_screen       GR_CALL(gr_screen.gf_restore_screen)
686 #define gr_free_screen          GR_CALL(gr_screen.gf_free_screen)
687
688 #define gr_dump_frame_start     GR_CALL(gr_screen.gf_dump_frame_start)
689 #define gr_dump_frame_stop              GR_CALL(gr_screen.gf_dump_frame_stop)
690 #define gr_dump_frame                   GR_CALL(gr_screen.gf_dump_frame)
691
692 #define gr_set_gamma                    GR_CALL(gr_screen.gf_set_gamma)
693
694 #define gr_lock                         GR_CALL(gr_screen.gf_lock)
695 #define gr_unlock                               GR_CALL(gr_screen.gf_unlock)
696
697 #define gr_get_region           GR_CALL(gr_screen.gf_get_region)
698
699 #define gr_fog_set                      GR_CALL(gr_screen.gf_fog_set)
700
701 #define gr_get_pixel                    GR_CALL(gr_screen.gf_get_pixel)
702
703 #define gr_set_cull                     GR_CALL(gr_screen.gf_set_cull)
704
705 #define gr_cross_fade           GR_CALL(gr_screen.gf_cross_fade)
706
707 #define gr_filter_set           GR_CALL(gr_screen.gf_filter_set)
708
709 #define gr_tcache_set           GR_CALL(gr_screen.gf_tcache_set)
710
711 #define gr_set_clear_color      GR_CALL(gr_screen.gf_set_clear_color)
712
713 // new bitmap functions
714 extern int Gr_bitmap_poly;
715 void gr_bitmap(int x, int y);
716 void gr_bitmap_ex(int x, int y, int w, int h, int sx, int sy);
717
718 // special function for drawing polylines. this function is specifically intended for
719 // polylines where each section is no more than 90 degrees away from a previous section.
720 // Moreover, it is _really_ intended for use with 45 degree angles. 
721 void gr_pline_special(vector **pts, int num_pts, int thickness);
722
723 #endif
724