]> icculus.org git repositories - taylor/freespace2.git/blob - include/grd3dinternal.h
Initial revision
[taylor/freespace2.git] / include / grd3dinternal.h
1 /*
2  * $Logfile: /Freespace2/code/Graphics/GrD3DInternal.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Prototypes for the variables used internally by the Direct3D renderer
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:12  root
11  * Initial revision
12  *
13  * 
14  * 5     7/13/99 1:15p Dave
15  * 32 bit support. Whee!
16  * 
17  * 4     7/09/99 9:51a Dave
18  * Added thick polyline code.
19  * 
20  * 3     6/29/99 10:35a Dave
21  * Interface polygon bitmaps! Whee!
22  * 
23  * 2     10/07/98 10:52a Dave
24  * Initial checkin.
25  * 
26  * 1     10/07/98 10:49a Dave
27  * 
28  * 21    5/23/98 4:14p John
29  * Added code to preload textures to video card for AGP.   Added in code
30  * to page in some bitmaps that weren't getting paged in at level start.
31  * 
32  * 20    5/20/98 9:45p John
33  * added code so the places in code that change half the palette don't
34  * have to clear the screen.
35  * 
36  * 19    5/12/98 10:34a John
37  * Added d3d_shade functionality.  Added d3d_flush function, since the
38  * shader seems to get reorganzed behind the overlay text stuff!
39  * 
40  * 18    5/12/98 8:18a John
41  * Put in code to use a different texture format for alpha textures and
42  * normal textures.   Turned off filtering for aabitmaps.  Took out
43  * destblend=invsrccolor alpha mode that doesn't work on riva128. 
44  * 
45  * 17    5/11/98 10:19a John
46  * Added caps checking
47  * 
48  * 16    5/07/98 3:02p John
49  * Mpre texture cleanup.   You can now reinit d3d without a crash.
50  * 
51  * 15    5/07/98 9:54a John
52  * Added in palette flash functionallity.
53  * 
54  * 14    5/06/98 11:21p John
55  * Fixed a bitmap bug with Direct3D.  Started adding new caching code into
56  * D3D.
57  * 
58  * 13    5/06/98 8:41p John
59  * Fixed some font clipping bugs.   Moved texture handle set code for d3d
60  * into the texture module.
61  * 
62  * 12    5/06/98 5:30p John
63  * Removed unused cfilearchiver.  Removed/replaced some unused/little used
64  * graphics functions, namely gradient_h and _v and pixel_sp.   Put in new
65  * DirectX header files and libs that fixed the Direct3D alpha blending
66  * problems.
67  * 
68  * 11    5/05/98 10:37p John
69  * Added code to optionally use execute buffers.
70  * 
71  * 10    5/04/98 3:36p John
72  * Got zbuffering working with Direct3D.
73  * 
74  * 9     4/14/98 12:15p John
75  * Made 16-bpp movies work.
76  * 
77  * 8     3/12/98 5:36p John
78  * Took out any unused shaders.  Made shader code take rgbc instead of
79  * matrix and vector since noone used it like a matrix and it would have
80  * been impossible to do in hardware.   Made Glide implement a basic
81  * shader for online help.  
82  * 
83  * 7     3/10/98 4:18p John
84  * Cleaned up graphics lib.  Took out most unused gr functions.   Made D3D
85  * & Glide have popups and print screen.  Took out all >8bpp software
86  * support.  Made Fred zbuffer.  Made zbuffer allocate dynamically to
87  * support Fred.  Made zbuffering key off of functions rather than one
88  * global variable.
89  * 
90  * 6     3/09/98 6:06p John
91  * Restructured font stuff to avoid duplicate code in Direct3D and Glide.
92  * Restructured Glide to avoid redundent state setting.
93  * 
94  * 5     3/08/98 12:33p John
95  * Made d3d cleanup free textures.  Made d3d always divide texture size by
96  * 2 for now.
97  * 
98  * 4     3/07/98 8:29p John
99  * Put in some Direct3D features.  Transparency on bitmaps.  Made fonts &
100  * aabitmaps render nice.
101  * 
102  * 3     2/17/98 7:28p John
103  * Got fonts and texturing working in Direct3D
104  * 
105  * 2     2/07/98 7:50p John
106  * Added code so that we can use the old blending type of alphacolors if
107  * we want to.  Made the stars use them.
108  * 
109  * 1     2/03/98 9:24p John
110  *
111  * $NoKeywords: $
112  */
113
114
115 #ifndef _GRD3DINTERNAL_H
116 #define _GRD3DINTERNAL_H
117
118 #include <windows.h>
119 #include <windowsx.h>
120
121 #define D3D_OVERLOADS
122 #include "vddraw.h"
123
124 // To remove an otherwise well-lodged compiler error
125 // 4201 nonstandard extension used : nameless struct/union (happens a lot in Windows include headers)
126 #pragma warning(disable: 4201)
127
128 #include "vd3d.h"
129 #include "2d.h"
130 #include "grinternal.h"
131
132
133 extern LPDIRECTDRAW                     lpDD1;
134 extern LPDIRECTDRAW2                    lpDD;
135 extern LPDIRECT3D2                      lpD3D;
136 extern LPDIRECT3DDEVICE         lpD3DDeviceEB; 
137 extern LPDIRECT3DDEVICE2        lpD3DDevice; 
138 extern LPDIRECTDRAWSURFACE      lpBackBuffer;
139 extern LPDIRECTDRAWSURFACE      lpFrontBuffer;
140 extern LPDIRECTDRAWSURFACE      lpZBuffer;
141
142 extern LPDIRECT3DVIEWPORT2      lpViewport;
143 extern LPDIRECTDRAWPALETTE      lpPalette;
144
145 extern DDPIXELFORMAT                    AlphaTextureFormat;
146 extern DDPIXELFORMAT                    NonAlphaTextureFormat;
147 extern DDPIXELFORMAT                    ScreenFormat;
148
149 extern D3DDEVICEDESC D3DHWDevDesc, D3DHELDevDesc;
150 extern LPD3DDEVICEDESC lpDevDesc;
151 extern DDCAPS DD_driver_caps;
152 extern DDCAPS DD_hel_caps;
153
154 extern int D3D_texture_divider;
155
156 extern int D3D_32bit;
157
158 extern char* d3d_error_string(HRESULT error);
159
160 void d3d_tcache_init(int use_sections);
161 void d3d_tcache_cleanup();
162 void d3d_tcache_flush();
163 void d3d_tcache_frame();
164
165 // Flushes any pending operations
166 void d3d_flush();
167
168 int d3d_tcache_set(int bitmap_id, int bitmap_type, float *u_ratio, float *v_ratio, int fail_on_full=0, int sx = -1, int sy = -1, int force = 0);
169
170 // Functions in GrD3DRender.cpp stuffed into gr_screen structure
171
172 void gr_d3d_flash(int r, int g, int b);
173 void gr_d3d_zbuffer_clear(int mode);
174 int gr_d3d_zbuffer_get();
175 int gr_d3d_zbuffer_set(int mode);
176 void gr_d3d_tmapper( int nverts, vertex **verts, uint flags );
177 void gr_d3d_scaler(vertex *va, vertex *vb );
178 void gr_d3d_aascaler(vertex *va, vertex *vb );
179 void gr_d3d_pixel(int x, int y);
180 void gr_d3d_clear();
181 void gr_d3d_set_clip(int x,int y,int w,int h);
182 void gr_d3d_reset_clip();
183 void gr_d3d_init_color(color *c, int r, int g, int b);
184 void gr_d3d_init_alphacolor( color *clr, int r, int g, int b, int alpha, int type );
185 void gr_d3d_set_color( int r, int g, int b );
186 void gr_d3d_get_color( int * r, int * g, int * b );
187 void gr_d3d_set_color_fast(color *dst);
188 void gr_d3d_set_bitmap( int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha, int sx=-1, int sy=-1 );
189 void gr_d3d_bitmap_ex(int x,int y,int w,int h,int sx,int sy);
190 void gr_d3d_bitmap(int x, int y);
191 void gr_d3d_aabitmap_ex(int x,int y,int w,int h,int sx,int sy);
192 void gr_d3d_aabitmap(int x, int y);
193 void gr_d3d_rect(int x,int y,int w,int h);
194 void gr_d3d_create_shader(shader * shade, float r, float g, float b, float c );
195 void gr_d3d_set_shader( shader * shade );
196 void gr_d3d_shade(int x,int y,int w,int h);
197 void gr_d3d_create_font_bitmap();
198 void gr_d3d_char(int x,int y,int letter);
199 void gr_d3d_string( int sx, int sy, char *s );
200 void gr_d3d_circle( int xc, int yc, int d );
201 void gr_d3d_line(int x1,int y1,int x2,int y2);
202 void gr_d3d_aaline(vertex *v1, vertex *v2);
203 void gr_d3d_gradient(int x1,int y1,int x2,int y2);
204 void gr_d3d_set_palette(ubyte *new_palette, int restrict_alphacolor);
205 void gr_d3d_diamond(int x, int y, int width, int height);
206 void gr_d3d_print_screen(char *filename);
207
208
209 // Functions used to render.  Calls either DrawPrim or Execute buffer code
210 HRESULT d3d_SetRenderState( D3DRENDERSTATETYPE dwRenderStateType,  DWORD dwRenderState );
211 HRESULT d3d_DrawPrimitive( D3DPRIMITIVETYPE dptPrimitiveType, D3DVERTEXTYPE dvtVertexType, LPVOID lpvVertices, DWORD dwVertexCount, DWORD dwFlags );
212
213 #endif //_GRD3DINTERNAL_H
214