📄 rstate.c
字号:
if (psContext->sTState.dwRSFlags & TSTATE_RSFLAGS_ALPHATEST)
{
DWORD dwAlphaCmpCtl;
/*
Is the Alpha-compare mode not ALWAYS?
*/
dwAlphaCmpCtl = psContext->sTState.dwAlphaTest &
(~MBX1_TSPOBJ_ALPHACMPCLRMASK);
if (dwAlphaCmpCtl ^ MBX1_TSPOBJ_ACMPMODEALWAYS)
{
/*
Registry flag to disable all-forms of alpha-test not set?
*/
if (!(psContext->sRegData.dwFlags & D3DMREG_DISABLE_ALTEST))
{
/*
Alpha-blending disabled, and opaque alpha-testing not disabled
in registry?
*/
if (
(!(psContext->sRegData.dwFlags & D3DMREG_DISABLE_ALTEST_OPAQUE)) ||
(!(psContext->sTState.dwRSFlags & TSTATE_RSFLAGS_ALPHABLEND))
)
{
/*
Woo-hoo! Flag that we require alpha-testing!
*/
psContext->dwFlags |= D3DM_CONTEXT_SWFLAGS_ALPHATESTENABLED;
}
}
}
}
/*
Update the HW object type required
*/
SetupObjectType(psContext);
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : ProcessLightingColourSources
PURPOSE : Updates the fixed-function TNL lighting colour sources to use
PARAMETERS : psContext - Current D3D context.
RETURNS : void
</function>
------------------------------------------------------------------------------*/
void ProcessLightingColourSources(LPD3DM_CONTEXT psContext)
{
PTRANSIENT_STATE psTState;
PSWTNLSTATE psSWTNLState;
DWORD i;
DWORD dwFFComponents;
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
dwFFComponents = (psContext->psVertexSource) ? psContext->psVertexSource->sVSIFDef.dwFFComponents : 0;
#else
if(psContext->psVertexSource)
{
dwFFComponents = (psContext->psVertexSource->dwFVFFlags & D3DMFVF_DIFFUSE) ? FFVTXCOMPONENT_TYPE_DIFFUSE : 0;
dwFFComponents |= (psContext->psVertexSource->dwFVFFlags & D3DMFVF_SPECULAR) ? FFVTXCOMPONENT_TYPE_SPECULAR : 0;
}
#endif
psTState = &psContext->sTState;
psSWTNLState = &psTState->sSWTNLState;
/* Update the lighting sources to use */
for (i = 0; i < TNLCOLSRCTYPE_COUNT; i++)
{
D3DMMATERIALCOLORSOURCE eColourSource;
/*
Individual colour-source selection enabled?
*/
if (!(psTState->dwRSFlags & TSTATE_RSFLAGS_COLORVERTEX))
{
/*
No. Use the material.
*/
eColourSource = D3DMMCS_MATERIAL;
}
else
{
/*
Use the requested colour-source
*/
eColourSource = psSWTNLState->psD3DColourSourceSel[i];
/*
If the vertex-diffuse colour is selected for this colour-source,
and the vertex has not diffuse-colour, fall-back to the material.
*/
if (
(!(dwFFComponents & FFVTXCOMPONENT_TYPE_DIFFUSE)) &&
(eColourSource == D3DMMCS_COLOR1)
)
{
eColourSource = D3DMMCS_MATERIAL;
}
/*
If the vertex-specular colour is selected for this colour-source,
and the vertex has not specular-colour, fall-back to the material.
*/
if (
(!(dwFFComponents & FFVTXCOMPONENT_TYPE_SPECULAR)) &&
(eColourSource == D3DMMCS_COLOR2)
)
{
eColourSource = D3DMMCS_MATERIAL;
}
}
/*
Set the source-colour to use
*/
psSWTNLState->sColourSourcesReq[i] = eColourSource;
}
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_RS_NOP
PURPOSE:
PARAMETERS: In: psContext - Context who's state is to be modified
In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_NOP(LPD3DM_CONTEXT psContext,DWORD dwData)
{
D3DM_DPF((DPF_ENTRY, "->D3DM_RS_NOP"));
D3DM_DPF((DPF_STATE, "D3DM_RS_NOP: Data = 0x%08X", dwData));
D3DM_DPF((DPF_EXIT, "<-D3DM_RS_NOP"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_RS_TexturePerspective
PURPOSE:
PARAMETERS: In: psContext - Context who's state is to be modified
In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_TexturePerspective(LPD3DM_CONTEXT psContext,DWORD dwData)
{
DBGLPSTR pszTexturePerspDesc;
D3DM_DPF((DPF_ENTRY, "->D3DM_RS_TexturePerspective"));
if(dwData)
{
psContext->dwTAPrimCtl &= ~MBX1_TAPRIM_NONPERSPCORRECT;
DBGSETSTR(pszTexturePerspDesc,"Enable");
}
else
{
psContext->dwTAPrimCtl |= MBX1_TAPRIM_NONPERSPCORRECT;
DBGSETSTR(pszTexturePerspDesc,"Disable");
}
D3DM_DPF((DPF_STATE," D3DM_RS_TexturePerspective: Data = %d (%hs)", dwData, pszTexturePerspDesc));
D3DM_DPF((DPF_EXIT, "<-D3DM_RS_TexturePerspective"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_RS_FillMode
PURPOSE:
PARAMETERS: In: psContext - Context who's state is to be modified
In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_FillMode(LPD3DM_CONTEXT psContext,DWORD dwData)
{
PRIM_FILLMODE eNewPrimFillMode;
DBGLPSTR pszFillModeDesc;
D3DM_DPF((DPF_ENTRY, "->D3DM_RS_FillMode"));
/*
Record the new D3D fill-mode
*/
psContext->sTState.dwD3DfillMode = dwData;
/*
Update the primitive setup-function fill-mode selector
*/
switch(dwData)
{
case D3DMFILL_POINT:
{
eNewPrimFillMode = PRIM_FILLMODE_POINT;
DBGSETSTR(pszFillModeDesc,"Point");
break;
}
case D3DMFILL_WIREFRAME:
{
eNewPrimFillMode = PRIM_FILLMODE_WIREFRAME;
DBGSETSTR(pszFillModeDesc, "WireFrame");
break;
}
case D3DMFILL_SOLID:
{
eNewPrimFillMode = PRIM_FILLMODE_SOLID;
DBGSETSTR(pszFillModeDesc,"Solid");
break;
}
default:
{
D3DM_DPF((DPF_WARN,"D3DM_RS_FillMode: Unknown D3D fill-mode %d", dwData));
DBGSETSTR(pszFillModeDesc,"Unknown - Setting \"Solid\"");
eNewPrimFillMode = PRIM_FILLMODE_SOLID;
}
}
psContext->ePrimFillMode = eNewPrimFillMode;
D3DM_DPF((DPF_STATE,"D3DM_RS_FillMode: Data = %d (%hs)", dwData, pszFillModeDesc));
D3DM_DPF((DPF_EXIT, "<-D3DM_RS_FillMode"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_RS_ShadeMode
PURPOSE:
PARAMETERS: In: psContext - Context who's state is to be modified
In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_ShadeMode(LPD3DM_CONTEXT psContext,DWORD dwData)
{
DWORD dwISPTSPCtl;
DBGLPSTR pszShadeModeDesc;
D3DM_DPF((DPF_ENTRY, "->D3DM_RS_ShadeMode"));
/* Disable gouraud shading if flat-shading is selected, otherwise we can only do gouraud */
dwISPTSPCtl = psContext->sHWState.sTACtl3DState.dwISPTSPCtl;
if(dwData == D3DMSHADE_FLAT)
{
dwISPTSPCtl &= ~MBX1_ISPTSPCTL_GOURAUD;
psContext->sTState.dwRSFlags |= TSTATE_RSFLAGS_FLAT_SHADING;
DBGSETSTR(pszShadeModeDesc, "Flat");
}
else
{
dwISPTSPCtl |= MBX1_ISPTSPCTL_GOURAUD;
psContext->sTState.dwRSFlags &= ~TSTATE_RSFLAGS_FLAT_SHADING;
DBGSETSTR(pszShadeModeDesc,"Gourad");
}
psContext->sHWState.sTACtl3DState.dwISPTSPCtl = dwISPTSPCtl;
/* Update state-control flags */
psContext->sHWStateCtl.dwTACtl3DStateChanged |= MBX1_TASTATEPRES_ISPCTL;
D3DM_DPF((DPF_STATE,"D3DM_RS_ShadeMode: Data = %d (%hs)", dwData, pszShadeModeDesc));
D3DM_DPF((DPF_EXIT, "<-D3DM_RS_ShadeMode"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_RS_ZEnable
PURPOSE:
PARAMETERS: In: psContext - Context who's state is to be modified
In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_ZEnable(LPD3DM_CONTEXT psContext,DWORD dwData)
{
DWORD dwRSFlags;
DBGLPSTR pszZEnableDesc;
D3DM_DPF((DPF_ENTRY, "->D3DM_RS_ZEnable"));
/* Override the depth mode if requested */
if(psContext->sRegData.dwFlags & D3DMREG_RHW_RENDERING)
{
dwData = D3DMZB_USEW;
}
/*
Update the Z/W-buffering enable flags
*/
dwRSFlags = psContext->sTState.dwRSFlags;
dwRSFlags &= ~(TSTATE_RSFLAGS_WENABLE | TSTATE_RSFLAGS_ZENABLE);
DBGSETSTR(pszZEnableDesc, "Disable");
switch(dwData)
{
case D3DMZB_TRUE:
{
/* Flag that Z buffer is enabled */
dwRSFlags |= TSTATE_RSFLAGS_ZENABLE;
DBGSETSTR(pszZEnableDesc, "Use Z");
break;
}
case D3DMZB_USEW:
{
/* Flag that W buffer is enabled */
dwRSFlags |= TSTATE_RSFLAGS_WENABLE;
DBGSETSTR(pszZEnableDesc, "Use W");
break;
}
}
psContext->sTState.dwRSFlags = dwRSFlags;
/*
Update the depth-related HW state
*/
ProcessDepthState(psContext);
D3DM_DPF((DPF_STATE,"D3DM_RS_ZEnable: Data = %d (%hs)", dwData, pszZEnableDesc));
D3DM_DPF((DPF_EXIT, "<-D3DM_RS_ZEnable"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_RS_ZWriteEnable
PURPOSE:
PARAMETERS: In: psContext - Context who's state is to be modified
In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_ZWriteEnable(LPD3DM_CONTEXT psContext,DWORD dwData)
{
DWORD dwRSFlags;
DWORD dwHWDepthCtl;
DBGLPSTR pszZWriteEnableDesc;
D3DM_DPF((DPF_ENTRY, "->D3DM_RS_ZWriteEnable"));
/* Record the renderstate state and update the HW depth-control */
dwRSFlags = psContext->sTState.dwRSFlags;
dwHWDepthCtl = psContext->sTState.dwDepthCtl;
if(dwData)
{
dwRSFlags |= TSTATE_RSFLAGS_ZWRITE;
dwHWDepthCtl &= ~MBX1_ISPTSPCTL_DWDISABLE;
DBGSETSTR(pszZWriteEnableDesc, "Enable");
}
else
{
dwRSFlags &= ~TSTATE_RSFLAGS_ZWRITE;
dwHWDepthCtl |= MBX1_ISPTSPCTL_DWDISABLE;
DBGSETSTR(pszZWriteEnableDesc, "Disable");
}
psContext->sTState.dwRSFlags = dwRSFlags;
psContext->sTState.dwDepthCtl = dwHWDepthCtl;
/* Update the depth-related HW state */
ProcessDepthState(psContext);
D3DM_DPF((DPF_STATE,"D3DM_RS_ZWriteEnable: Data = %d", dwData, pszZWriteEnableDesc));
D3DM_DPF((DPF_EXIT, "<-D3DM_RS_ZWriteEnable"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_RS_ZFunc
PURPOSE:
PARAMETERS: In: psContext - Context who's state is to be modified
In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_ZFunc(LPD3DM_CONTEXT psContext,DWORD dwData)
{
DWORD dwDepthCtl;
DBGLPSTR pszZFuncDesc;
D3DM_DPF((DPF_ENTRY, "->D3DM_RS_ZFunc"));
/* Store the new D3D depth-compare mode */
psContext->sTState.dwD3DDepthFunc = dwData;
/* Setup the new HW depth-compare mode */
dwDepthCtl = psContext->sTState.dwDepthCtl;
dwDepthCtl &= MBX1_ISPTSPCTL_DCMPMODECLRMASK;
switch (dwData)
{
case D3DMCMP_NEVER:
{
dwDepthCtl |= MBX1_ISPTSPCTL_DCMPMODENEVER;
DBGSETSTR(pszZFuncDesc, "Never");
break;
}
case D3DMCMP_LESS:
{
dwDepthCtl |= MBX1_ISPTSPCTL_DCMPMODELT;
DBGSETSTR(pszZFuncDesc, "Less");
break;
}
case D3DMCMP_EQUAL:
{
dwDepthCtl |= MBX1_ISPTSPCTL_DCMPMODEEQ;
DBGSETSTR(pszZFuncDesc, "Equal");
break;
}
case D3DMCMP_LESSEQUAL:
{
dwDepthCtl |= MBX1_ISPTSPCTL_DCMPMODELE;
DBGSETSTR(pszZFuncDesc, "Less or Equal");
break;
}
case D3DMCMP_GREATER:
{
dwDepthCtl |= MBX1_ISPTSPCTL_DCMPMODEGT;
DBGSETSTR(pszZFuncDesc, "Greater");
break;
}
case D3DMCMP_NOTEQUAL:
{
dwDepthCtl |= MBX1_ISPTSPCTL_DCMPMODENE;
DBGSETSTR(pszZFuncDesc, "Not Equal");
break;
}
case D3DMCMP_GREATEREQUAL:
{
dwDepthCtl |= MBX1_ISPTSPCTL_DCMPMODEGE;
DBGSETSTR(pszZFuncDesc, "Greater or Equal");
break;
}
case D3DMCMP_ALWAYS:
{
dwDepthCtl |= MBX1_ISPTSPCTL_DCMPMODEALWAYS;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -