2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
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
10 * $Logfile: /Freespace2/code/Graphics/GrD3DInternal.h $
15 * Prototypes for the variables used internally by the Direct3D renderer
18 * Revision 1.3 2004/09/20 01:31:44 theoddone33
21 * Revision 1.2 2002/06/09 04:41:13 relnev
22 * added copyright header
24 * Revision 1.1.1.1 2002/05/03 03:28:12 root
28 * 5 7/13/99 1:15p Dave
29 * 32 bit support. Whee!
31 * 4 7/09/99 9:51a Dave
32 * Added thick polyline code.
34 * 3 6/29/99 10:35a Dave
35 * Interface polygon bitmaps! Whee!
37 * 2 10/07/98 10:52a Dave
40 * 1 10/07/98 10:49a Dave
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.
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.
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!
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.
59 * 17 5/11/98 10:19a John
62 * 16 5/07/98 3:02p John
63 * Mpre texture cleanup. You can now reinit d3d without a crash.
65 * 15 5/07/98 9:54a John
66 * Added in palette flash functionallity.
68 * 14 5/06/98 11:21p John
69 * Fixed a bitmap bug with Direct3D. Started adding new caching code into
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.
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
82 * 11 5/05/98 10:37p John
83 * Added code to optionally use execute buffers.
85 * 10 5/04/98 3:36p John
86 * Got zbuffering working with Direct3D.
88 * 9 4/14/98 12:15p John
89 * Made 16-bpp movies work.
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.
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
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.
108 * 5 3/08/98 12:33p John
109 * Made d3d cleanup free textures. Made d3d always divide texture size by
112 * 4 3/07/98 8:29p John
113 * Put in some Direct3D features. Transparency on bitmaps. Made fonts &
114 * aabitmaps render nice.
116 * 3 2/17/98 7:28p John
117 * Got fonts and texturing working in Direct3D
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.
123 * 1 2/03/98 9:24p John
129 #ifndef _GRD3DINTERNAL_H
130 #define _GRD3DINTERNAL_H
133 #include <windowsx.h>
135 #define D3D_OVERLOADS
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)
144 #include "grinternal.h"
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;
156 extern LPDIRECT3DVIEWPORT2 lpViewport;
157 extern LPDIRECTDRAWPALETTE lpPalette;
159 extern DDPIXELFORMAT AlphaTextureFormat;
160 extern DDPIXELFORMAT NonAlphaTextureFormat;
161 extern DDPIXELFORMAT ScreenFormat;
163 extern D3DDEVICEDESC D3DHWDevDesc, D3DHELDevDesc;
164 extern LPD3DDEVICEDESC lpDevDesc;
165 extern DDCAPS DD_driver_caps;
166 extern DDCAPS DD_hel_caps;
168 extern int D3D_texture_divider;
170 extern int D3D_32bit;
172 extern char* d3d_error_string(HRESULT error);
174 void d3d_tcache_init(int use_sections);
175 void d3d_tcache_cleanup();
176 void d3d_tcache_flush();
177 void d3d_tcache_frame();
179 // Flushes any pending operations
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);
184 // Functions in GrD3DRender.cpp stuffed into gr_screen structure
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);
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);
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);
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 );
228 #endif //_GRD3DINTERNAL_H