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