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