Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

D3d_fx.cpp File Reference

#include <Windows.h>
#include <stdio.h>
#include <DDraw.h>
#include <D3D.h>
#include "D3DDrv7x.h"
#include "DCommon.h"
#include "Render.h"
#include "Scene.h"
#include "D3D_FX.h"
#include "D3D_Main.h"
#include "D3D_Err.h"

Go to the source code of this file.

Functions

void D3DSetTexHandle (D3DTEXTUREHANDLE TexHandle)
void D3DSetTexture (int32 Stage, LPDIRECTDRAWSURFACE7 Texture)
void D3DBilinearFilter (D3DTEXTUREFILTER Min, D3DTEXTUREFILTER Mag)
void D3DTexturedPolyOld (void *Pnts, int32 NumPoints)
void D3DTexturedPoly (void *Pnts, int32 NumPoints)
void D3DViewport (int32 x, int32 y, int32 width, int32 height)
void D3DDepthRange (float zNear, float zFar)
void D3DBlendFunc (D3DBLEND SFunc, D3DBLEND DFunc)
void D3DBlendEnable (BOOL Enable)
void D3DTexWrap (DWORD Stage, BOOL Wrap)
void D3DZWriteEnable (BOOL Enable)
void D3DZFunc (D3DCMPFUNC Func)
void D3DZEnable (BOOL Enable)
void D3DPolygonMode (D3DFILLMODE Mode)

Variables

D3DTEXTUREHANDLE OldTexHandle = NULL
LPDIRECTDRAWSURFACE7 OldTexture [8]
D3DBLEND OldSFunc = D3DBLEND_ONE
D3DBLEND OldDFunc = D3DBLEND_ONE
BOOL OldBlend = FALSE
BOOL OldWrap = FALSE


Function Documentation

void D3DBilinearFilter D3DTEXTUREFILTER  Min,
D3DTEXTUREFILTER  Mag
 

Definition at line 90 of file D3D7xDrv/D3d_fx.cpp.

00091 {
00092         AppInfo.lpD3DDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
00093         AppInfo.lpD3DDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_LINEAR);
00094 
00095         if (AppInfo.CanDoMultiTexture)
00096         {
00097                 AppInfo.lpD3DDevice->SetTextureStageState(1, D3DTSS_MINFILTER, D3DTFN_LINEAR);
00098                 AppInfo.lpD3DDevice->SetTextureStageState(1, D3DTSS_MAGFILTER, D3DTFG_LINEAR);
00099         }
00100 }

void D3DBlendEnable BOOL  Enable  ) 
 

Definition at line 254 of file D3D7xDrv/D3d_fx.cpp.

00255 {
00256         if (OldBlend == Enable)
00257                 return;
00258 
00259         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, Enable);
00260 
00261         OldBlend = Enable;
00262 }

void D3DBlendFunc D3DBLEND  SFunc,
D3DBLEND  DFunc
 

Definition at line 235 of file D3D7xDrv/D3d_fx.cpp.

00236 {
00237         if (SFunc != OldSFunc)
00238         {
00239                 AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, SFunc);
00240                 OldSFunc = SFunc;
00241         }
00242         if (DFunc != OldDFunc)
00243         {
00244                 AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, DFunc);
00245                 OldDFunc = DFunc;
00246         }
00247 
00248 }

void D3DDepthRange float  zNear,
float  zFar
 

Definition at line 197 of file D3D7xDrv/D3d_fx.cpp.

00198 {
00199 /*   07/16/2000 Wendell Buckner
00200 /*    Convert to Directx7...         
00201     D3DVIEWPORT2 vport;*/
00202         D3DVIEWPORT7 vport;
00203 
00204 //03/01/2002 Wendell Buckner    
00205 //This wasn't commented in the original code but it was in my genesis 1.0 converted code...
00206 //not sure I should do this.
00207 //  vport.dwSize = sizeof(D3DVIEWPORT2);
00208 
00209 /*   07/16/2000 Wendell Buckner
00210 /*    Convert to Directx7...     
00211     AppInfo.lpD3DViewport->GetViewport2(&vport);*/
00212         AppInfo.lpD3DDevice->GetViewport(&vport);
00213 
00214 //03/01/2002 Wendell Buckner    
00215 //This wasn't commented in the original code but it was in my genesis 1.0 converted code...
00216 //not sure I should do this.
00217 //  vport.dvMinZ = (D3DVALUE)(((-1.0) * (zFar + zNear)) / (zFar - zNear));
00218 //  vport.dvMaxZ = (D3DVALUE)(((-1.0) * (zFar + zNear - 2.0)) / (zFar - zNear));
00219     vport.dvMinZ = zNear; 
00220     vport.dvMaxZ = zFar;  
00221 
00222 
00223 /*   07/16/2000 Wendell Buckner
00224 /*    Convert to Directx7...     
00225         AppInfo.lpD3DViewport->SetViewport2(&vport);*/
00226     AppInfo.lpD3DDevice->SetViewport(&vport);
00227     
00228 }

void D3DPolygonMode D3DFILLMODE  Mode  ) 
 

Definition at line 302 of file D3D7xDrv/D3d_fx.cpp.

00303 {
00304         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_FILLMODE, D3DFILL_SOLID);
00305 }

void D3DSetTexHandle D3DTEXTUREHANDLE  TexHandle  ) 
 

Definition at line 53 of file D3D7xDrv/D3d_fx.cpp.

00054 {
00055         if (TexHandle == OldTexHandle)
00056                 return;
00057 
00058         OldTexHandle = TexHandle;
00059 
00060 /* 02/28/2001 Wendell Buckner
00061    These render states are unsupported d3d 7.0
00062         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_TEXTUREHANDLE, TexHandle);*/
00063 }

void D3DSetTexture int32  Stage,
LPDIRECTDRAWSURFACE7  Texture
 

Definition at line 77 of file D3D7xDrv/D3d_fx.cpp.

00079 {
00080         if (Texture == OldTexture[Stage])
00081                 return;
00082 
00083         OldTexture[Stage] = Texture;
00084 
00085         AppInfo.lpD3DDevice->SetTexture(Stage, Texture);
00086 }

void D3DTexturedPoly void *  Pnts,
int32  NumPoints
 

Definition at line 126 of file D3D7xDrv/D3d_fx.cpp.

00127 {
00128 /* 02/28/2001 Wendell Buckner
00129    The flags at the end of DrawPrimitive are no longer supported in  d3d 7.0, use the combination of flags in 
00130    the renderstate call */
00131         HRESULT Hr;
00132 
00133 /*      02/08/2002 Wendell Buckner
00134     Optimization from GeForce_Optimization2.doc
00135     9.  Do not duplicate render state commands.  Worse is useless renderstates.  Do not set a renderstate unless it is needed. 
00136         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_CLIPPING,FALSE);
00137         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_LIGHTING,FALSE);
00138         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_EXTENTS,FALSE);
00139         AppInfo.lpD3DDevice->DrawPrimitive(     D3DPT_TRIANGLEFAN, 
00140                                                                                 //D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX2, 
00141                                                                                 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX2, 
00142                                                                                 Pnts, 
00143                                                                                 NumPoints, 
00144                                                                                 D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP);
00145                                                                                 //D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTCLIP);*/
00146         Hr = AppInfo.lpD3DDevice->DrawPrimitive(        D3DPT_TRIANGLEFAN, 
00147                                                                                 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX2, 
00148                                                                                 Pnts, 
00149                                                                                 NumPoints, 
00150                                                                                 NULL);
00151 
00152         if( Hr != DD_OK ) D3DMain_Log("D3DTexturedPoly failed...\n\n");
00153 }       

void D3DTexturedPolyOld void *  Pnts,
int32  NumPoints
 

Definition at line 105 of file D3D7xDrv/D3d_fx.cpp.

00106 {
00107 /* 02/28/2001 Wendell Buckner
00108    The flags at the end of DrawPrimitive are no longer supported in  d3d 7.0, use the combination of flags in 
00109    the renderstate call */
00110         HRESULT Hr;
00111 
00112 /*      02/08/2002 Wendell Buckner
00113     Optimization from GeForce_Optimization2.doc
00114     9.  Do not duplicate render state commands.  Worse is useless renderstates.  Do not set a renderstate unless it is needed. 
00115         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_CLIPPING,FALSE);
00116         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_LIGHTING,FALSE);
00117         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_EXTENTS,FALSE);                                                        
00118         AppInfo.lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX, Pnts, NumPoints, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP);*/
00119         Hr = AppInfo.lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_TLVERTEX, Pnts, NumPoints, NULL);
00120         if( Hr != DD_OK ) D3DMain_Log("D3DTExturedPolOld failed...\n\n");
00121 }       

void D3DTexWrap DWORD  Stage,
BOOL  Wrap
 

Definition at line 266 of file D3D7xDrv/D3d_fx.cpp.

00267 {
00268         if (OldWrap == Wrap)
00269                 return;
00270 
00271         OldWrap = Wrap;
00272 
00273         if (Wrap)
00274         {
00275                 AppInfo.lpD3DDevice->SetTextureStageState(Stage, D3DTSS_ADDRESS, D3DTADDRESS_WRAP);
00276                 AppInfo.lpD3DDevice->SetTextureStageState(Stage, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
00277                 AppInfo.lpD3DDevice->SetTextureStageState(Stage, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
00278         }
00279         else
00280         {
00281                 AppInfo.lpD3DDevice->SetTextureStageState(Stage, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP);
00282                 AppInfo.lpD3DDevice->SetTextureStageState(Stage, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
00283                 AppInfo.lpD3DDevice->SetTextureStageState(Stage, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
00284         }
00285 }

void D3DViewport int32  x,
int32  y,
int32  width,
int32  height
 

Definition at line 158 of file D3D7xDrv/D3d_fx.cpp.

00159 {
00160 /*   07/16/2000 Wendell Buckner
00161 /*    Convert to Directx7...    
00162         D3DVIEWPORT2 vport;         */ 
00163         D3DVIEWPORT7 vport;
00164 
00165 //03/01/2002 Wendell Buckner    
00166 //This wasn't commented in the original code but it was in my genesis 1.0 converted code...
00167 //not sure I should do this.
00168 //      return;
00169 //
00170 //  vport.dwSize = sizeof(D3DVIEWPORT2);
00171 
00172 /*   07/16/2000 Wendell Buckner
00173 /*    Convert to Directx7...    
00174     AppInfo.lpD3DViewport->GetViewport2(&vport); */
00175     AppInfo.lpD3DDevice->GetViewport(&vport);
00176 
00177     vport.dwX = x;
00178     vport.dwY = AppInfo.OldHeight - (y + height);
00179     vport.dwWidth = width;
00180     vport.dwHeight = height;
00181 
00182 /*  07/16/2000 Wendell Buckner
00183     Convert to Directx7...    
00184     vport.dvClipX = -1.0f;
00185     vport.dvClipY = 1.0f;
00186     vport.dvClipWidth = (float)width /2.0f;
00187     vport.dvClipHeight = (float)height/2.0f;*/
00188 
00189 /*   07/16/2000 Wendell Buckner
00190 /*    Convert to Directx7...        
00191     AppInfo.lpD3DViewport->SetViewport2(&vport); */
00192         AppInfo.lpD3DDevice->SetViewport(&vport);
00193 }

void D3DZEnable BOOL  Enable  ) 
 

Definition at line 297 of file D3D7xDrv/D3d_fx.cpp.

00298 {
00299         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, Enable);
00300 }

void D3DZFunc D3DCMPFUNC  Func  ) 
 

Definition at line 292 of file D3D7xDrv/D3d_fx.cpp.

00293 {
00294         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, Func);
00295 }

void D3DZWriteEnable BOOL  Enable  ) 
 

Definition at line 287 of file D3D7xDrv/D3d_fx.cpp.

00288 {
00289         AppInfo.lpD3DDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, Enable);
00290 }


Variable Documentation

BOOL OldBlend = FALSE [static]
 

Definition at line 250 of file D3D7xDrv/D3d_fx.cpp.

Referenced by D3DBlendEnable().

D3DBLEND OldDFunc = D3DBLEND_ONE [static]
 

Definition at line 231 of file D3D7xDrv/D3d_fx.cpp.

Referenced by D3DBlendFunc().

D3DBLEND OldSFunc = D3DBLEND_ONE [static]
 

Definition at line 230 of file D3D7xDrv/D3d_fx.cpp.

Referenced by D3DBlendFunc().

D3DTEXTUREHANDLE OldTexHandle = NULL [static]
 

Definition at line 49 of file D3D7xDrv/D3d_fx.cpp.

Referenced by D3DSetTexHandle().

LPDIRECTDRAWSURFACE7 OldTexture[8] [static]
 

Definition at line 68 of file D3D7xDrv/D3d_fx.cpp.

Referenced by D3DSetTexture().

BOOL OldWrap = FALSE [static]
 

Definition at line 264 of file D3D7xDrv/D3d_fx.cpp.

Referenced by D3DTexWrap().


Generated on Tue Sep 30 12:37:14 2003 for GTestAndEngine by doxygen 1.3.2