2 * $Logfile: /Freespace2/code/Graphics/GrD3DInternal.h $
7 * Prototypes for the variables used internally by the Direct3D renderer
10 * Revision 1.1 2002/05/03 03:28:12 root
14 * 5 7/13/99 1:15p Dave
15 * 32 bit support. Whee!
17 * 4 7/09/99 9:51a Dave
18 * Added thick polyline code.
20 * 3 6/29/99 10:35a Dave
21 * Interface polygon bitmaps! Whee!
23 * 2 10/07/98 10:52a Dave
26 * 1 10/07/98 10:49a Dave
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.
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.
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!
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.
45 * 17 5/11/98 10:19a John
48 * 16 5/07/98 3:02p John
49 * Mpre texture cleanup. You can now reinit d3d without a crash.
51 * 15 5/07/98 9:54a John
52 * Added in palette flash functionallity.
54 * 14 5/06/98 11:21p John
55 * Fixed a bitmap bug with Direct3D. Started adding new caching code into
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.
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
68 * 11 5/05/98 10:37p John
69 * Added code to optionally use execute buffers.
71 * 10 5/04/98 3:36p John
72 * Got zbuffering working with Direct3D.
74 * 9 4/14/98 12:15p John
75 * Made 16-bpp movies work.
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.
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
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.
94 * 5 3/08/98 12:33p John
95 * Made d3d cleanup free textures. Made d3d always divide texture size by
98 * 4 3/07/98 8:29p John
99 * Put in some Direct3D features. Transparency on bitmaps. Made fonts &
100 * aabitmaps render nice.
102 * 3 2/17/98 7:28p John
103 * Got fonts and texturing working in Direct3D
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.
109 * 1 2/03/98 9:24p John
115 #ifndef _GRD3DINTERNAL_H
116 #define _GRD3DINTERNAL_H
119 #include <windowsx.h>
121 #define D3D_OVERLOADS
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)
130 #include "grinternal.h"
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;
142 extern LPDIRECT3DVIEWPORT2 lpViewport;
143 extern LPDIRECTDRAWPALETTE lpPalette;
145 extern DDPIXELFORMAT AlphaTextureFormat;
146 extern DDPIXELFORMAT NonAlphaTextureFormat;
147 extern DDPIXELFORMAT ScreenFormat;
149 extern D3DDEVICEDESC D3DHWDevDesc, D3DHELDevDesc;
150 extern LPD3DDEVICEDESC lpDevDesc;
151 extern DDCAPS DD_driver_caps;
152 extern DDCAPS DD_hel_caps;
154 extern int D3D_texture_divider;
156 extern int D3D_32bit;
158 extern char* d3d_error_string(HRESULT error);
160 void d3d_tcache_init(int use_sections);
161 void d3d_tcache_cleanup();
162 void d3d_tcache_flush();
163 void d3d_tcache_frame();
165 // Flushes any pending operations
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);
170 // Functions in GrD3DRender.cpp stuffed into gr_screen structure
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);
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);
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 );
213 #endif //_GRD3DINTERNAL_H