]> icculus.org git repositories - taylor/freespace2.git/blob - include/grinternal.h
Initial revision
[taylor/freespace2.git] / include / grinternal.h
1 /*
2  * $Logfile: /Freespace2/code/Graphics/GrInternal.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Include file for our Graphics directory
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:12  root
11  * Initial revision
12  *
13  * 
14  * 7     6/29/99 10:35a Dave
15  * Interface polygon bitmaps! Whee!
16  * 
17  * 6     1/15/99 11:29a Neilk
18  * Fixed D3D screen/texture pixel formatting problem. 
19  * 
20  * 5     1/14/99 12:48a Dave
21  * Todo list bug fixes. Made a pass at putting briefing icons back into
22  * FRED. Sort of works :(
23  * 
24  * 4     12/02/98 5:47p Dave
25  * Put in interface xstr code. Converted barracks screen to new format.
26  * 
27  * 3     12/01/98 10:32a Johnson
28  * Fixed direct3d font problems. Fixed sun bitmap problem. Fixed direct3d
29  * starfield problem.
30  * 
31  * 2     10/07/98 10:53a Dave
32  * Initial checkin.
33  * 
34  * 1     10/07/98 10:49a Dave
35  * 
36  * 23    5/06/98 11:21p John
37  * Fixed a bitmap bug with Direct3D.  Started adding new caching code into
38  * D3D.
39  * 
40  * 22    4/08/98 4:09p John
41  * Fixed some potential bugs with high bit set in screen piointer.
42  * 
43  * 21    3/25/98 8:07p John
44  * Restructured software rendering into two modules; One for windowed
45  * debug mode and one for DirectX fullscreen.   
46  * 
47  * 20    3/24/98 3:58p John
48  * Put in (hopefully) final gamma setting code.
49  * 
50  * 19    3/10/98 4:18p John
51  * Cleaned up graphics lib.  Took out most unused gr functions.   Made D3D
52  * & Glide have popups and print screen.  Took out all >8bpp software
53  * support.  Made Fred zbuffer.  Made zbuffer allocate dynamically to
54  * support Fred.  Made zbuffering key off of functions rather than one
55  * global variable.
56  * 
57  * 18    2/07/98 7:50p John
58  * Added code so that we can use the old blending type of alphacolors if
59  * we want to.  Made the stars use them.
60  * 
61  * 17    1/26/98 5:12p John
62  * Added in code for Pentium Pro specific optimizations. Speed up
63  * zbuffered correct tmapper about 35%.   Speed up non-zbuffered scalers
64  * by about 25%.
65  * 
66  * 16    11/30/97 3:57p John
67  * Made fixed 32-bpp translucency.  Made BmpMan always map translucent
68  * color into 255 even if you aren't supposed to remap and make it's
69  * palette black.
70  * 
71  * 15    11/30/97 12:18p John
72  * added more 24 & 32-bpp primitives
73  * 
74  * 14    11/29/97 2:06p John
75  * added mode 16-bpp support
76  * 
77  * 13    11/14/97 12:30p John
78  * Fixed some DirectX bugs.  Moved the 8-16 xlat tables into Graphics
79  * libs.  Made 16-bpp DirectX modes know what bitmap format they're in.
80  * 
81  * 12    11/03/97 10:08p Hoffoss
82  * Changed gr_get_string_size to utilize an optional length specifier, if
83  * you want to use non-null terminated strings.
84  * 
85  * 11    10/19/97 12:55p John
86  * new code to lock / unlock surfaces for smooth directx integration.
87  * 
88  * 10    10/14/97 4:50p John
89  * more 16 bpp stuff.
90  * 
91  * 9     10/14/97 8:08a John
92  * added a bunch more 16 bit support
93  * 
94  * 8     7/18/97 12:40p John
95  * cached alphacolors to disk.  Also made cfopen be able to delete a file
96  * by passing NULL for mode.
97  * 
98  * 7     6/17/97 12:03p John
99  * Moved color/alphacolor functions into their own module.  Made all color
100  * functions be part of the low-level graphics drivers, not just the
101  * grsoft.
102  * 
103  * 6     6/12/97 5:04p John
104  * Initial rev of Glide support
105  * 
106  * 5     6/11/97 5:49p John
107  * Changed palette code to only recalculate alphacolors when needed, not
108  * when palette changes.
109  * 
110  * 4     6/06/97 4:41p John
111  * Fixed alpha colors to be smoothly integrated into gr_set_color_fast
112  * code.
113  * 
114  * 3     6/06/97 2:40p John
115  * Made all the radar dim in/out
116  * 
117  * 2     5/14/97 4:38p John
118  * Fixed print_screen bug.
119  * 
120  * 1     5/12/97 12:13p John
121  *
122  * $NoKeywords: $
123  */
124
125 #ifndef _GRINTERNAL_H
126 #define _GRINTERNAL_H
127
128 #include "font.h"
129 #include "2d.h"
130 #include "grzbuffer.h"
131
132 extern int Gr_cursor;
133
134 #define GR_SCREEN_PTR(type,x,y) ((type *)(uint(gr_screen.offscreen_buffer) + uint(((x)+gr_screen.offset_x)*sizeof(type)) + uint(((y)+gr_screen.offset_y)*gr_screen.rowsize)))
135 #define GR_SCREEN_PTR_SIZE(bpp,x,y) ((uint)(uint(gr_screen.offscreen_buffer) + uint(((x)+gr_screen.offset_x)*(bpp)) + uint(((y)+gr_screen.offset_y)*gr_screen.rowsize)))
136
137 extern ubyte Gr_original_palette[768];          // The palette 
138 extern ubyte Gr_current_palette[768];
139
140 typedef struct alphacolor {
141         int     used;
142         int     r,g,b,alpha;
143         int     type;                                           // See AC_TYPE_??? define
144         color   *clr;
145         /*
146         union {
147                 ubyte           lookup[16][256];                // For 8-bpp rendering modes
148         } table;
149         */
150 } alphacolor;
151
152 // for backwards fred aabitmap compatibility
153 typedef struct alphacolor_old {
154         int     used;
155         int     r,g,b,alpha;
156         int     type;                                           // See AC_TYPE_??? define
157         color   *clr;   
158         union {
159                 ubyte           lookup[16][256];                // For 8-bpp rendering modes
160         } table;        
161 } alphacolor_old;
162
163 extern alphacolor * Current_alphacolor;
164 void gr_init_alphacolors();
165
166 extern char Gr_current_palette_name[128];
167
168 typedef struct color_gun {
169         int     bits;
170         int     shift;
171         int     scale;
172         int     mask;
173 } color_gun;
174
175 // screen format
176 extern color_gun Gr_red, Gr_green, Gr_blue, Gr_alpha;
177
178 // texture format
179 extern color_gun Gr_t_red, Gr_t_green, Gr_t_blue, Gr_t_alpha;
180
181 // alpha texture format
182 extern color_gun Gr_ta_red, Gr_ta_green, Gr_ta_blue, Gr_ta_alpha;
183
184 // CURRENT FORMAT - note - this is what bmpman uses when fiddling with pixels/colors. so be sure its properly set to one
185 // of the above values
186 extern color_gun *Gr_current_red, *Gr_current_green, *Gr_current_blue, *Gr_current_alpha;
187
188
189 // Translate the 768 byte 'src' palette into 
190 // the current screen format's palette.
191 // The size of the dst array is assumed to be gr_screen.bpp
192 // bytes per element.
193 void gr_xlat_palette( void *dst, bitmap *bmp );
194
195 // CPU identification variables
196 extern int Gr_cpu;                      // What type of CPU.  5=Pentium, 6=Ppro/PII
197 extern int Gr_mmx;                      // MMX capabilities?  0=No, 1=Yes
198
199 extern float Gr_gamma;
200 extern int Gr_gamma_int;                                // int(Gr_gamma*100)
201 extern int Gr_gamma_lookup[256];
202
203 #define TCACHE_TYPE_AABITMAP                            0               // HUD bitmap.  All Alpha.
204 #define TCACHE_TYPE_NORMAL                                      1               // Normal bitmap. Alpha = 0.
205 #define TCACHE_TYPE_XPARENT                             2               // Bitmap with 0,255,0 = transparent.  Alpha=0 if transparent, 1 if not.
206 #define TCACHE_TYPE_NONDARKENING                        3               // Bitmap with 255,255,255 = non-darkening.  Alpha=1 if non-darkening, 0 if not.
207 #define TCACHE_TYPE_BITMAP_SECTION              4               // section of a bitmap
208
209 #endif
210