Add rayman2 source files

This commit is contained in:
2024-09-18 02:33:44 +08:00
parent bcc093f8ed
commit fb036c54fd
14339 changed files with 2596224 additions and 0 deletions

View File

@@ -0,0 +1,976 @@
/**********************************************************************************************/
/* Name: BigFunc1*/
/* Goal: Draw a list of indexed triangles..*/
/* Code: Steve McCalla */
/* OPTIMIZED : Halfway - in order to keep this fast, please avoid sticking DD branches in here.*/
/* it would be really nice if we could get rid of a few copies too!*/
/**********************************************************************************************/
#ifdef __BigFunc1__From_Steve_Mac_Calla__
static void
BigFunc1 (ACP_tdxIndex xTriangleCounter)
{
int iIndex = xTriangleCounter;
for (; iIndex--; p_stCurrentTriangle ++, p_stCurrentTriangleUV ++) {
#ifdef PROFILING_STUFF
PRF_MDRV_vSetIndependantVariable( PRF_C_ulIdpDisplayedTriangle , 0 );
#endif
/* This function should be identical to calling this series of functions:*/
/*GLI_vComputeXYZ();*/
/*GLI_vSetSpecular();*/
/*GLI_TestBackfaceClockwise();*/
/*GLI_vComputeNormalUVW();*/
/*GLI_vDrawTriangle();*/
/*GLI_vCorrect3DFXBug1();*/
GLI_tdstAligned2DVector *p_ScreenPoint;
p_ScreenPoint = GLI_BIG_GLOBALS->GLI_ScreenPoint+p_stCurrentTriangle->a3_xIndex[0];
SetX(CurrentDestXYZ[0],p_ScreenPoint->xX);
SetY(CurrentDestXYZ[0],p_ScreenPoint->xY);
SetZ(CurrentDestXYZ[0],p_ScreenPoint->xOoZ);
SetPackedColor(CurrentDestXYZ[0],p_ScreenPoint->ulPackedColor );
p_ScreenPoint = GLI_BIG_GLOBALS->GLI_ScreenPoint+p_stCurrentTriangle->a3_xIndex[1];
SetX(CurrentDestXYZ[1],p_ScreenPoint->xX);
SetY(CurrentDestXYZ[1],p_ScreenPoint->xY);
SetZ(CurrentDestXYZ[1],p_ScreenPoint->xOoZ);
SetPackedColor(CurrentDestXYZ[1],p_ScreenPoint->ulPackedColor );
p_ScreenPoint = GLI_BIG_GLOBALS->GLI_ScreenPoint+p_stCurrentTriangle->a3_xIndex[2];
SetX(CurrentDestXYZ[2],p_ScreenPoint->xX);
SetY(CurrentDestXYZ[2],p_ScreenPoint->xY);
SetZ(CurrentDestXYZ[2],p_ScreenPoint->xOoZ);
SetPackedColor(CurrentDestXYZ[2],p_ScreenPoint->ulPackedColor );
if ( ( ( GetY(CurrentDestXYZ[2]) - GetY(CurrentDestXYZ[1]) ) * ( GetX(CurrentDestXYZ[0]) - GetX(CurrentDestXYZ[1]) ) ) - ( ( GetX(CurrentDestXYZ[2]) - GetX(CurrentDestXYZ[1]) )* ( GetY(CurrentDestXYZ[0]) - GetY(CurrentDestXYZ[1]) ) ) < 0.f )
continue;
/* After this function, no index from the element should be used...*/
SetPackedSpecular( CurrentDestXYZ[0], *((unsigned long *) GLI_BIG_GLOBALS->GLI_aDEF_stColorsRLIS + p_stCurrentTriangle->a3_xIndex[0]) );
SetPackedSpecular( CurrentDestXYZ[1], *((unsigned long *) GLI_BIG_GLOBALS->GLI_aDEF_stColorsRLIS + p_stCurrentTriangle->a3_xIndex[1]) );
SetPackedSpecular( CurrentDestXYZ[2], *((unsigned long *) GLI_BIG_GLOBALS->GLI_aDEF_stColorsRLIS + p_stCurrentTriangle->a3_xIndex[2]) );
d_stVirtualUV[0] = p_stCurrentElementIndexedTriangle -> d_stListOfElementUV + p_stCurrentTriangleUV -> a3_xIndex[0];
d_stVirtualUV[1] = p_stCurrentElementIndexedTriangle -> d_stListOfElementUV + p_stCurrentTriangleUV -> a3_xIndex[1];
d_stVirtualUV[2] = p_stCurrentElementIndexedTriangle -> d_stListOfElementUV + p_stCurrentTriangleUV -> a3_xIndex[2];
SetU_Cpy(CurrentDestXYZ[0],(d_stVirtualUV[0]) -> xU );
SetV_Cpy(CurrentDestXYZ[0],(d_stVirtualUV[0]) -> xV );
SetU_Cpy(CurrentDestXYZ[1],(d_stVirtualUV[1]) -> xU );
SetV_Cpy(CurrentDestXYZ[1],(d_stVirtualUV[1]) -> xV );
SetU_Cpy(CurrentDestXYZ[2],(d_stVirtualUV[2]) -> xU );
SetV_Cpy(CurrentDestXYZ[2],(d_stVirtualUV[2]) -> xV );
GLI_M_Correct3DFXBug1(CurrentDestXYZ[0]);
GLI_M_Correct3DFXBug1(CurrentDestXYZ[1]);
GLI_M_Correct3DFXBug1(CurrentDestXYZ[2]);
GLI_vDrawTriangle();
#ifdef PROFILING_STUFF
if( PRF_MDRV_lGetIndependantVariable( PRF_C_ulIdpDisplayedTriangle ) )
{
PRF_MDRV_vIncreaseVariable( PRF_C_ulVarFaces + PRF_MDRV_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvDisplayed, 1 );
PRF_MDRV_vSetIndependantVariable( PRF_C_ulIdpDisplayedFaces, 1 );
}
#endif
}
}
#endif
/* ------------------------------------------------------------------------------------------------*/
/* BACKFACE CULLING*/
/* ------------------------------------------------------------------------------------------------*/
GLI_FuncNodeBegin(GLI_TestBackfaceClockwise)
{
if ( ( ( GetY(CurrentDestXYZ[2]) - GetY(CurrentDestXYZ[1]) ) * ( GetX(CurrentDestXYZ[0]) - GetX(CurrentDestXYZ[1]) ) ) - ( ( GetX(CurrentDestXYZ[2]) - GetX(CurrentDestXYZ[1]) )* ( GetY(CurrentDestXYZ[0]) - GetY(CurrentDestXYZ[1]) ) ) < 0.f ) GLI_M_TriangleIsOut();
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin(GLI_TestBackfaceCounterClockwize)
{
if ( ( ( GetY(CurrentDestXYZ[2]) - GetY(CurrentDestXYZ[1]) ) * ( GetX(CurrentDestXYZ[0]) - GetX(CurrentDestXYZ[1]) ) ) - ( ( GetX(CurrentDestXYZ[2]) - GetX(CurrentDestXYZ[1]) )* ( GetY(CurrentDestXYZ[0]) - GetY(CurrentDestXYZ[1]) ) ) > 0.f ) GLI_M_TriangleIsOut();
GLI_M_CallNextFunc();
}
/* ------------------------------------------------------------------------------------------------*/
/* UVW Computing*/
/* ------------------------------------------------------------------------------------------------*/
GLI_FuncNodeBegin(GLI_vComputeMovingUVW)
{
SetU(CurrentDestXYZ[0],(d_stVirtualUV[0]) -> xU + fAddU);
SetV(CurrentDestXYZ[0],(d_stVirtualUV[0]) -> xV + fAddV);
SetU(CurrentDestXYZ[1],(d_stVirtualUV[1]) -> xU + fAddU);
SetV(CurrentDestXYZ[1],(d_stVirtualUV[1]) -> xV + fAddV);
SetU(CurrentDestXYZ[2],(d_stVirtualUV[2]) -> xU + fAddU);
SetV(CurrentDestXYZ[2],(d_stVirtualUV[2]) -> xV + fAddV);
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin(GLI_vComputeNormalUVW)
{
SetU_Cpy(CurrentDestXYZ[0],(d_stVirtualUV[0]) -> xU );
SetV_Cpy(CurrentDestXYZ[0],(d_stVirtualUV[0]) -> xV );
SetU_Cpy(CurrentDestXYZ[1],(d_stVirtualUV[1]) -> xU );
SetV_Cpy(CurrentDestXYZ[1],(d_stVirtualUV[1]) -> xV );
SetU_Cpy(CurrentDestXYZ[2],(d_stVirtualUV[2]) -> xU );
SetV_Cpy(CurrentDestXYZ[2],(d_stVirtualUV[2]) -> xV );
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin(GLI_vComputeMirrorUVW)
{
SetPackedColor(CurrentDestXYZ[0],0x3f3f3f3f );
SetPackedColor(CurrentDestXYZ[1],0x3f3f3f3f );
SetPackedColor(CurrentDestXYZ[2],0x3f3f3f3f );
SetU(CurrentDestXYZ[0],GetX(CurrentDestXYZ[0]) / 640.0f);
SetV(CurrentDestXYZ[0],GetY(CurrentDestXYZ[0]) / 512.0f);
SetU(CurrentDestXYZ[1],GetX(CurrentDestXYZ[1]) / 640.0f);
SetV(CurrentDestXYZ[1],GetY(CurrentDestXYZ[1]) / 512.0f);
SetU(CurrentDestXYZ[2],GetX(CurrentDestXYZ[2]) / 640.0f);
SetV(CurrentDestXYZ[2],GetY(CurrentDestXYZ[2]) / 512.0f);
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin( GLI_vAlignUForMirrorTexture )
{
SetU(CurrentDestXYZ[0],GetU(CurrentDestXYZ[0]) * .5f);
SetU(CurrentDestXYZ[1],GetU(CurrentDestXYZ[1]) * .5f);
SetU(CurrentDestXYZ[2],GetU(CurrentDestXYZ[2]) * .5f);
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin( GLI_vAlignVForMirrorTexture )
{
SetV(CurrentDestXYZ[0], (GetV(CurrentDestXYZ[0]) + 1.0f) * .5f);
SetV(CurrentDestXYZ[1], (GetV(CurrentDestXYZ[1]) + 1.0f) * .5f);
SetV(CurrentDestXYZ[2], (GetV(CurrentDestXYZ[2]) + 1.0f) * .5f);
GLI_M_CallNextFunc();
}
/* ------------------------------------------------------------------------------------------------*/
/* Set UV*/
/* ------------------------------------------------------------------------------------------------*/
/*VLCHROME*/
GLI_FuncNodeBegin(GLI_vSetChromeUVW)
{
d_stVirtualUV[0] = GLI_BIG_GLOBALS->GLI_aDEF_stEnvUV + p_stCurrentTriangle->a3_xIndex[0];
d_stVirtualUV[1] = GLI_BIG_GLOBALS->GLI_aDEF_stEnvUV + p_stCurrentTriangle->a3_xIndex[1];
d_stVirtualUV[2] = GLI_BIG_GLOBALS->GLI_aDEF_stEnvUV + p_stCurrentTriangle->a3_xIndex[2];
GLI_M_CallNextFunc();
}
/* Normal UV*/
GLI_FuncNodeBegin(GLI_vSetNormalUVW)
{
d_stVirtualUV[0] = p_stCurrentElementIndexedTriangle->d_stListOfElementUV + p_stCurrentTriangleUV->a3_xIndex[0];
d_stVirtualUV[1] = p_stCurrentElementIndexedTriangle->d_stListOfElementUV + p_stCurrentTriangleUV->a3_xIndex[1];
d_stVirtualUV[2] = p_stCurrentElementIndexedTriangle->d_stListOfElementUV + p_stCurrentTriangleUV->a3_xIndex[2];
GLI_M_CallNextFunc();
}
/* ------------------------------------------------------------------------------------------------*/
/* Z & MIRROR CULLING*/
/* ------------------------------------------------------------------------------------------------*/
GLI_FuncNodeBegin(GLI_FastZCull)
{
if (((*(unsigned long *)&GetZ(CurrentDestXYZ[0]) ) & (*(unsigned long *)&GetZ(CurrentDestXYZ[1]) ) & (*(unsigned long *)&GetZ(CurrentDestXYZ[2]) )) & 0x80000000 ) GLI_M_TriangleIsOut();
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin(GLI_FastMirrorCulling)
{
if ((*(unsigned long *)(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[0])) & (*(unsigned long *)(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[1])) & *(unsigned long *)(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[2]) & 0x80000000) GLI_M_TriangleIsOut();
GLI_M_CallNextFunc();
}
/* ------------------------------------------------------------------------------------------------*/
/* SCREEN CULLING*/
/* ------------------------------------------------------------------------------------------------*/
#define GLI_M_CullXMin() *(unsigned long *)&GetX(CurrentDestXYZ[0]) & *(unsigned long *)&GetX(CurrentDestXYZ[1]) & *(unsigned long *)&GetX(CurrentDestXYZ[2]) & 0x80000000
#define GLI_M_CullXMax() (*(long *)&GetX(CurrentDestXYZ[0]) > fX_CMP_Optimize) && (*(long *)&GetX(CurrentDestXYZ[1]) > fX_CMP_Optimize) && (*(long *)&GetX(CurrentDestXYZ[2]) > fX_CMP_Optimize)
#define GLI_M_CullYMin() *(unsigned long *)&GetY(CurrentDestXYZ[0]) & *(unsigned long *)&GetY(CurrentDestXYZ[1]) & *(unsigned long *)&GetY(CurrentDestXYZ[2]) & 0x80000000
#define GLI_M_CullYMax() (*(long *)&GetY(CurrentDestXYZ[0]) > fY_CMP_Optimize) && (*(long *)&GetY(CurrentDestXYZ[1]) > fY_CMP_Optimize) && (*(long *)&GetY(CurrentDestXYZ[2]) > fY_CMP_Optimize)
GLI_FuncNodeBegin(GLI_bCullingXMax_XMin)
{
if (GLI_M_CullXMin()) GLI_M_TriangleIsOut() ;
if (GLI_M_CullXMax()) GLI_M_TriangleIsOut() ;
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin(GLI_bCullingXMax)
{
if (GLI_M_CullXMax()) GLI_M_TriangleIsOut() ;
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin(GLI_bCullingXMin)
{
if (GLI_M_CullXMin()) GLI_M_TriangleIsOut() ;
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin(GLI_bCullingYMax_YMin)
{
if (GLI_M_CullYMin()) GLI_M_TriangleIsOut() ;
if (GLI_M_CullYMax()) GLI_M_TriangleIsOut() ;
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin(GLI_bCullingYMax)
{
if (GLI_M_CullYMax()) GLI_M_TriangleIsOut() ;
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin(GLI_bCullingYMin)
{
if (GLI_M_CullYMax()) GLI_M_TriangleIsOut() ;
GLI_M_CallNextFunc();
}
GLI_FuncNodeBegin(GLI_bCullingXYALL)
{
if (GLI_M_CullXMin()) GLI_M_TriangleIsOut() ;
if (GLI_M_CullYMin()) GLI_M_TriangleIsOut() ;
if (GLI_M_CullXMax()) GLI_M_TriangleIsOut() ;
if (GLI_M_CullYMax()) GLI_M_TriangleIsOut() ;
GLI_M_CallNextFunc();
}
/* ------------------------------------------------------------------------------------------------*/
/* First function*/
/* ------------------------------------------------------------------------------------------------*/
GLI_FuncNodeBegin(GLI_vComputeXYZ)
{
/* After this function, no index from the element should be used...*/
GLI_tdstAligned2DVector *p_ScreenPoint;
p_ScreenPoint = GLI_BIG_GLOBALS->GLI_ScreenPoint+p_stCurrentTriangle->a3_xIndex[0];
SetX(CurrentDestXYZ[0],p_ScreenPoint->xX);
SetY(CurrentDestXYZ[0],p_ScreenPoint->xY);
SetZ(CurrentDestXYZ[0],p_ScreenPoint->xOoZ);
SetPackedColor(CurrentDestXYZ[0],p_ScreenPoint->ulPackedColor );
p_ScreenPoint = GLI_BIG_GLOBALS->GLI_ScreenPoint+p_stCurrentTriangle->a3_xIndex[1];
SetX(CurrentDestXYZ[1],p_ScreenPoint->xX);
SetY(CurrentDestXYZ[1],p_ScreenPoint->xY);
SetZ(CurrentDestXYZ[1],p_ScreenPoint->xOoZ);
SetPackedColor(CurrentDestXYZ[1],p_ScreenPoint->ulPackedColor );
p_ScreenPoint = GLI_BIG_GLOBALS->GLI_ScreenPoint+p_stCurrentTriangle->a3_xIndex[2];
SetX(CurrentDestXYZ[2],p_ScreenPoint->xX);
SetY(CurrentDestXYZ[2],p_ScreenPoint->xY);
SetZ(CurrentDestXYZ[2],p_ScreenPoint->xOoZ);
SetPackedColor(CurrentDestXYZ[2],p_ScreenPoint->ulPackedColor );
/*d_stVirtualUV[0] = p_stCurrentElementIndexedTriangle -> d_stListOfElementUV + p_stCurrentTriangleUV -> a3_xIndex[0];*/
/*d_stVirtualUV[1] = p_stCurrentElementIndexedTriangle -> d_stListOfElementUV + p_stCurrentTriangleUV -> a3_xIndex[1];*/
/*d_stVirtualUV[2] = p_stCurrentElementIndexedTriangle -> d_stListOfElementUV + p_stCurrentTriangleUV -> a3_xIndex[2];*/
GLI_M_CallNextFunc();
}
/* ------------------------------------------------------------------------------------------------*/
/* second function : eventually set specular color*/
/* ------------------------------------------------------------------------------------------------*/
GLI_FuncNodeBegin(GLI_vSetSpecular)
{
/* After this function, no index from the element should be used...*/
SetPackedSpecular( CurrentDestXYZ[0], *((unsigned long *) GLI_BIG_GLOBALS->GLI_aDEF_stColorsRLIS + p_stCurrentTriangle->a3_xIndex[0]) );
SetPackedSpecular( CurrentDestXYZ[1], *((unsigned long *) GLI_BIG_GLOBALS->GLI_aDEF_stColorsRLIS + p_stCurrentTriangle->a3_xIndex[1]) );
SetPackedSpecular( CurrentDestXYZ[2], *((unsigned long *) GLI_BIG_GLOBALS->GLI_aDEF_stColorsRLIS + p_stCurrentTriangle->a3_xIndex[2]) );
GLI_M_CallNextFunc();
}
/* ------------------------------------------------------------------------------------------------*/
/* Z Clipping*/
/* ------------------------------------------------------------------------------------------------*/
#define GLI_M_BuildPointIO( Des, Index, Index2 )\
{\
p_stLocalZClipVertex1 = (GLI_BIG_GLOBALS -> GLI_TurnedScaledDisplecedPoint + p_stCurrentTriangle -> a3_xIndex[Index]);\
p_stLocalZClipVertex2 = (GLI_BIG_GLOBALS -> GLI_TurnedScaledDisplecedPoint + p_stCurrentTriangle -> a3_xIndex[Index2]);\
/*fZClipLocalCoef = ( GLI_C_xZClippingNear - p_stLocalZClipVertex1 -> xZ ) / (p_stLocalZClipVertex2 -> xZ - p_stLocalZClipVertex1 -> xZ);*/\
fZClipLocalCoef = ( GLI_BIG_GLOBALS->p_stCurrentCamera->xNear - p_stLocalZClipVertex1 -> xZ ) / (p_stLocalZClipVertex2 -> xZ - p_stLocalZClipVertex1 -> xZ);\
stLocalZClipVertex.xX = p_stLocalZClipVertex1 -> xX + (p_stLocalZClipVertex2 -> xX - p_stLocalZClipVertex1 -> xX) * fZClipLocalCoef;\
stLocalZClipVertex.xY = p_stLocalZClipVertex1 -> xY + (p_stLocalZClipVertex2 -> xY - p_stLocalZClipVertex1 -> xY) * fZClipLocalCoef;\
stLocalZClipVertex.xZ = GLI_BIG_GLOBALS -> fZClipping;\
GLI_MDRV_vSerialProjection( GLI_BIG_GLOBALS -> p_stCurrentCamera , 1 , &stLocalZClipVertex , &stLocalZProjVertex);\
SetX(LocalTab[Des],stLocalZProjVertex.xX); \
SetY(LocalTab[Des],stLocalZProjVertex.xY); \
SetZ(LocalTab[Des],stLocalZProjVertex.xOoZ); \
SetPackedColor(LocalTab[Des],GLI_ulInterpol2PackedColor(GetPackedColor(CurrentDestXYZ[Index]),GetPackedColor(CurrentDestXYZ[Index2]),fZClipLocalCoef)) ;\
SetPackedSpecular(LocalTab[Des],GLI_ulInterpol2PackedColor(GetPackedSpecular(CurrentDestXYZ[Index]),GetPackedSpecular(CurrentDestXYZ[Index2]),fZClipLocalCoef)) ;\
SetU(LocalTab[Des],(d_stVirtualUV[Index]) -> xU + ((d_stVirtualUV[Index2]) -> xU - (d_stVirtualUV[Index]) -> xU) * fZClipLocalCoef ); \
SetV(LocalTab[Des],(d_stVirtualUV[Index]) -> xV + ((d_stVirtualUV[Index2]) -> xV - (d_stVirtualUV[Index]) -> xV) * fZClipLocalCoef ); \
}
#define BLincheuZ( aws, bws, cws)\
{\
CurrentDestXYZ[0] = LocalTab[aws];\
CurrentDestXYZ[1] = LocalTab[bws];\
CurrentDestXYZ[2] = LocalTab[cws];\
d_stVirtualUV[0] = (ACP_tdst2DUVValues *)&GetU(LocalTab[aws]);\
d_stVirtualUV[1] = (ACP_tdst2DUVValues *)&GetU(LocalTab[bws]);\
d_stVirtualUV[2] = (ACP_tdst2DUVValues *)&GetU(LocalTab[cws]);\
GLI_M_RestoreCW()\
}
GLI_FuncNodeBegin(GLI_vZClipping)
{
if (((*(unsigned long *)&GetZ(CurrentDestXYZ[0]) ) | (*(unsigned long *)&GetZ(CurrentDestXYZ[1]) ) | (*(unsigned long *)&GetZ(CurrentDestXYZ[2]) )) & 0x80000000 )
{
GLI_tdstAligned3DVector stLocalZClipVertex,*p_stLocalZClipVertex1,*p_stLocalZClipVertex2;
GLI_tdstAligned2DVector stLocalZProjVertex;
float fZClipLocalCoef;
GLI_tdScreenVertx LocalTab[4];
unsigned long ZState,Zcounter,ZCounterLast,ZBuilder;
ACP_tdxIndex NewVertices ;
/* ZClipping*/
NewVertices = GLI_BIG_GLOBALS -> p_stObj -> xNbPoints;
ZState = ((*(unsigned long *)&GetZ(CurrentDestXYZ[2])) >> 31 ) ;
for ( ZBuilder = 0 , ZCounterLast = 2 , Zcounter = 0 ; Zcounter < 3 ; ZCounterLast = Zcounter , Zcounter ++ )
{
ZState = ((*(unsigned long *)&GetZ(CurrentDestXYZ[Zcounter])) >> 31) | (ZState<<1); /* Kepp the sign*/
switch ( ZState & 3 )
{
case 2: /*Come in*/
GLI_M_BuildPointIO( ZBuilder , Zcounter , ZCounterLast );
ZBuilder++;
case 0: /*Stay in*/
LocalTab[ZBuilder] = CurrentDestXYZ[Zcounter];
*(ACP_tdst2DUVValues *)&GetU(LocalTab[ZBuilder]) = *d_stVirtualUV[Zcounter];
ZBuilder++;
break;
case 1: /*Go out*/
GLI_M_BuildPointIO( ZBuilder , ZCounterLast , Zcounter );
ZBuilder++;
case 3: /*Stay out*/
break;
}
}
if (ZBuilder == 4)
{
BLincheuZ( 0, 2, 3);
GLI_M_CallNextFuncAndSave();
BLincheuZ( 0, 1, 2);
GLI_M_CallNextFunc();
} else
{
if (ZBuilder == 3)
{
BLincheuZ( 0, 1, 2);
GLI_M_CallNextFunc();
}
}
return;
}
GLI_M_CallNextFunc();
}
/* ------------------------------------------------------------------------------------------------*/
/* Mirror Clipping*/
/* ------------------------------------------------------------------------------------------------*/
#define GLI_M_BuildPointIOMirror( Index, Index2 )\
{\
p_stLocalZClipVertex1 = (GLI_BIG_GLOBALS -> GLI_TurnedScaledDisplecedPoint + p_stCurrentTriangle -> a3_xIndex[Index]);\
p_stLocalZClipVertex2 = (GLI_BIG_GLOBALS -> GLI_TurnedScaledDisplecedPoint + p_stCurrentTriangle -> a3_xIndex[Index2]);\
p_stLocalZClipVertex->xX = p_stLocalZClipVertex1 -> xX + (p_stLocalZClipVertex2 -> xX - p_stLocalZClipVertex1 -> xX) * fZClipLocalCoef;\
p_stLocalZClipVertex->xY = p_stLocalZClipVertex1 -> xY + (p_stLocalZClipVertex2 -> xY - p_stLocalZClipVertex1 -> xY) * fZClipLocalCoef;\
p_stLocalZClipVertex->xZ = p_stLocalZClipVertex1 -> xZ + (p_stLocalZClipVertex2 -> xZ - p_stLocalZClipVertex1 -> xZ) * fZClipLocalCoef;\
xLocalRestoreRefraction = MTH3D_M_xDotProductVector( (MTH3D_tdstVector *)p_stLocalZClipVertex , (MTH3D_tdstVector *)&GLI_BIG_GLOBALS->stWaterPlanNormale) - GLI_BIG_GLOBALS->xWaterPlaneDistance;\
p_stLocalZClipVertex->xX -= GLI_BIG_GLOBALS->stWaterPlanNormale.xX * xLocalRestoreRefraction;\
p_stLocalZClipVertex->xY -= GLI_BIG_GLOBALS->stWaterPlanNormale.xY * xLocalRestoreRefraction;\
p_stLocalZClipVertex->xZ -= GLI_BIG_GLOBALS->stWaterPlanNormale.xZ * xLocalRestoreRefraction;\
/* GLI_vInformWaterNoise(p_stLocalZClipVertex,GLI_BIG_GLOBALS);*/\
/* GLI_xSerialProjection ( GLI_BIG_GLOBALS -> p_stCurrentCamera , 1 , p_stLocalZClipVertex , p_stLocalZProjVertex);*/\
SetX(LocalTab[ZBuilder],p_stLocalZProjVertex->xX); \
SetY(LocalTab[ZBuilder],p_stLocalZProjVertex->xY); \
SetZ(LocalTab[ZBuilder],p_stLocalZProjVertex->xOoZ); \
/*fInvZ[ZBuilder] = 1.0f / GetZ(LocalTab[ZBuilder]);*/\
SetPackedColor(LocalTab[ZBuilder],GLI_ulInterpol2PackedColor(GetPackedColor(CurrentDestXYZ[Index]),GetPackedColor(CurrentDestXYZ[Index2]),fZClipLocalCoef * GetZ(CurrentDestXYZ[Index2]) / GetZ(LocalTab[ZBuilder]) )) ;\
SetPackedSpecular(LocalTab[ZBuilder],GLI_ulInterpol2PackedColor(GetPackedSpecular(CurrentDestXYZ[Index]),GetPackedSpecular(CurrentDestXYZ[Index2]),fZClipLocalCoef * GetZ(CurrentDestXYZ[Index2]) / GetZ(LocalTab[ZBuilder]) )) ;\
SetU(LocalTab[ZBuilder],(d_stVirtualUV[Index]) -> xU + ((d_stVirtualUV[Index2]) -> xU - (d_stVirtualUV[Index]) -> xU) * fZClipLocalCoef ); \
SetV(LocalTab[ZBuilder],(d_stVirtualUV[Index]) -> xV + ((d_stVirtualUV[Index2]) -> xV - (d_stVirtualUV[Index]) -> xV) * fZClipLocalCoef ); \
Index_LocalTab[ZBuilder++] = NewVertices++;\
p_stLocalZClipVertex++;\
p_stLocalZProjVertex++;\
}
#define BLincheuMirror( aws, bws, cws)\
{\
p_stCurrentTriangle -> a3_xIndex[0] = Index_LocalTab[aws];\
p_stCurrentTriangle -> a3_xIndex[1] = Index_LocalTab[bws];\
p_stCurrentTriangle -> a3_xIndex[2] = Index_LocalTab[cws];\
CurrentDestXYZ[0] = LocalTab[aws];\
CurrentDestXYZ[1] = LocalTab[bws];\
CurrentDestXYZ[2] = LocalTab[cws];\
GLI_M_RestoreCW();\
d_stVirtualUV[0] = (ACP_tdst2DUVValues *)&GetU(LocalTab[aws]);\
d_stVirtualUV[1] = (ACP_tdst2DUVValues *)&GetU(LocalTab[bws]);\
d_stVirtualUV[2] = (ACP_tdst2DUVValues *)&GetU(LocalTab[cws]);\
}
GLI_FuncNodeBegin(GLI_FastMirrorCLipping)
{
long K;
K = ((*(unsigned long *)(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[0])>>31) + (*(unsigned long *)(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[1])>>31) + (*(unsigned long *)(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[2])>>31));
if ((K != 3) && (K != 0))
{
GEO_tdstTripledIndex stNewCurrentTriangle;
GEO_tdstTripledIndex *p_stCurrentTriangleSave;
float xLocalRestoreRefraction;
GLI_tdstAligned3DVector *p_stLocalZClipVertex;
GLI_tdstAligned3DVector *p_stLocalZClipVertex1;
GLI_tdstAligned3DVector *p_stLocalZClipVertex2;
GLI_tdstAligned2DVector *p_stLocalZProjVertex;
float fZClipLocalCoef,LastWaterDepth,WaterDepth;
GLI_tdScreenVertx LocalTab[4];
ACP_tdxIndex Index_LocalTab[4],NewVertices ;
unsigned long ZState,Zcounter,ZCounterLast,ZBuilder;
NewVertices = GLI_BIG_GLOBALS-> p_stObj -> xNbPoints;
p_stCurrentTriangleSave = p_stCurrentTriangle ;
p_stLocalZClipVertex = GLI_BIG_GLOBALS -> GLI_TurnedScaledDisplecedPoint + NewVertices;
p_stLocalZProjVertex = GLI_BIG_GLOBALS -> GLI_ScreenPoint + NewVertices;
LastWaterDepth = *(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[2]);
ZState = (*(unsigned long *)&LastWaterDepth) >> 31 ;
for ( ZBuilder = 0 , ZCounterLast = 2 , Zcounter = 0 ; Zcounter < 3 ; ZCounterLast = Zcounter , Zcounter ++ )
{
WaterDepth = *(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[Zcounter]);
ZState = ((*(unsigned long *)&WaterDepth) >> 31) | (ZState<<1); /* Kepp the sign*/
switch ( ZState & 3 )
{
case 2: /*Come in*/
fZClipLocalCoef = WaterDepth / ( WaterDepth - LastWaterDepth );
GLI_M_BuildPointIOMirror( Zcounter , ZCounterLast );
case 0: /*Stay in*/
LocalTab[ZBuilder] = CurrentDestXYZ[Zcounter];
Index_LocalTab[ZBuilder] = p_stCurrentTriangle -> a3_xIndex[Zcounter];
*(ACP_tdst2DUVValues *)&GetU(LocalTab[ZBuilder]) = *d_stVirtualUV[Zcounter];
/*fInvZ[XYBuilder] = 1.0f / GetZ(LocalTab[XYBuilder]);*/
ZBuilder++;
break;
case 1: /*Go out*/
fZClipLocalCoef = LastWaterDepth / ( LastWaterDepth - WaterDepth ) ;
GLI_M_BuildPointIOMirror( ZCounterLast , Zcounter );
case 3: /*Stay out*/
break;
}
LastWaterDepth = WaterDepth;
}
p_stCurrentTriangle = &stNewCurrentTriangle;
if (ZBuilder == 4)
{
BLincheuMirror( 0 , 2 , 3 );
GLI_M_CallNextFuncAndSave();
BLincheuMirror( 0 , 1 , 2 );
GLI_M_CallNextFunc();
} else
{
BLincheuMirror( 0 , 1 , 2 );
GLI_M_CallNextFunc();
}
p_stCurrentTriangle = p_stCurrentTriangleSave ;
return;
}
GLI_M_CallNextFunc();
}
/* ------------------------------------------------------------------------------------------------*/
/* XY Clipping*/
/* ------------------------------------------------------------------------------------------------*/
#define GLI_M_BuildPointIOXY( Index, Index2 )\
{\
SetX(LocalTab[XYBuilder],GetX(CurrentDestXYZ[Index ]) + (GetX(CurrentDestXYZ[Index2 ]) - GetX(CurrentDestXYZ[Index ])) * fXYClipLocalCoef ); \
SetY(LocalTab[XYBuilder],GetY(CurrentDestXYZ[Index ]) + (GetY(CurrentDestXYZ[Index2 ]) - GetY(CurrentDestXYZ[Index ])) * fXYClipLocalCoef ); \
SetZ(LocalTab[XYBuilder],GetZ(CurrentDestXYZ[Index ]) + (GetZ(CurrentDestXYZ[Index2 ]) - GetZ(CurrentDestXYZ[Index ])) * fXYClipLocalCoef ); \
fInvZ[XYBuilder] = 1.0f / GetZ(LocalTab[XYBuilder]);\
GLI_M_restorePerfectClipping();\
SetPackedColor(LocalTab[XYBuilder],GLI_ulInterpol2PackedColor(GetPackedColor(CurrentDestXYZ[Index ]),GetPackedColor(CurrentDestXYZ[Index2]),fXYClipLocalCoef * GetZ(CurrentDestXYZ[Index2]) * fInvZ[XYBuilder] )) ;\
SetPackedSpecular(LocalTab[XYBuilder],GLI_ulInterpol2PackedColor(GetPackedSpecular(CurrentDestXYZ[Index ]),GetPackedSpecular(CurrentDestXYZ[Index2]),fXYClipLocalCoef * GetZ(CurrentDestXYZ[Index2]) * fInvZ[XYBuilder] )) ;\
stUV[XYBuilder].xU = (d_stVirtualUV[Index]) -> xU + ((d_stVirtualUV[Index2]) -> xU - (d_stVirtualUV[Index]) -> xU) * fXYClipLocalCoef ; \
stUV[XYBuilder].xV = (d_stVirtualUV[Index]) -> xV + ((d_stVirtualUV[Index2]) -> xV - (d_stVirtualUV[Index]) -> xV) * fXYClipLocalCoef ; \
}\
#define BLincheuYMin( aws, bws, cws)\
{\
CurrentDestXYZ[0] = LocalTab[aws];\
CurrentDestXYZ[1] = LocalTab[bws];\
CurrentDestXYZ[2] = LocalTab[cws];\
GLI_M_RestoreCW();\
d_stVirtualUV[0] = &stUV[aws];\
d_stVirtualUV[1] = &stUV[bws];\
d_stVirtualUV[2] = &stUV[cws];\
}\
/*VLNG*/
/*
J'ai chang<6E>
fXYClipLocalCoef = MTH_M_xInvLow(GetZ(LocalTab[XYcounter]));\
en
fXYClipLocalCoef = 1.0f / GetZ(LocalTab[XYcounter]);\
*/
/*EVL*/
#define GLI_M_ScreenClipping()\
if (K == 0)\
{\
GLI_M_CallNextFunc();\
return;\
}else\
{\
float fXYClipLocalCoef,CurrentXY,LastXY;\
GLI_tdScreenVertx LocalTab[4];\
unsigned long XYState,XYcounter,XYCounterLast,XYBuilder;\
float fInvZ[4];\
ACP_tdst2DUVValues stUV[4];\
for ( XYcounter = 0 ; XYcounter < 3 ; XYcounter ++ )\
{\
stUV[XYcounter+1].xU = d_stVirtualUV[XYcounter]->xU * GetZ(CurrentDestXYZ[XYcounter]);\
stUV[XYcounter+1].xV = d_stVirtualUV[XYcounter]->xV * GetZ(CurrentDestXYZ[XYcounter]);\
d_stVirtualUV[XYcounter] = &stUV[XYcounter+1];\
}\
XYcounter = 2;\
LastXY = ComputeCurrentXY();\
XYState = (*(unsigned long *)&LastXY) >> 31 ;\
for ( XYBuilder = 0 , XYCounterLast = 2 , XYcounter = 0 ; XYcounter < 3 ; XYCounterLast = XYcounter , XYcounter ++ )\
{\
CurrentXY = ComputeCurrentXY();\
XYState = ((*(unsigned long *)&CurrentXY) >> 31) | (XYState<<1); \
switch ( XYState & 3 )\
{\
case 2: \
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );\
GLI_M_BuildPointIOXY( XYcounter , XYCounterLast );\
XYBuilder++;\
case 0: \
LocalTab[XYBuilder] = CurrentDestXYZ[XYcounter];\
stUV[XYBuilder] = *d_stVirtualUV[XYcounter];\
fInvZ[XYBuilder] = 1.0f / GetZ(LocalTab[XYBuilder]);\
XYBuilder++;\
break;\
case 1: \
fXYClipLocalCoef = LastXY / ( LastXY - CurrentXY ) ;\
GLI_M_BuildPointIOXY( XYCounterLast , XYcounter );\
XYBuilder++;\
case 3: \
break;\
}\
LastXY = CurrentXY;\
}\
for ( XYcounter = 0 ; XYcounter < XYBuilder ; XYcounter ++ )\
{\
/*fXYClipLocalCoef = 1.0f / GetZ(LocalTab[XYcounter]);*/\
stUV[XYcounter].xU = stUV[XYcounter].xU * fInvZ[XYcounter];\
stUV[XYcounter].xV = stUV[XYcounter].xV * fInvZ[XYcounter];\
}\
if (XYBuilder == 4)\
{\
BLincheuYMin( 0 , 2 , 3 );\
GLI_M_CallNextFuncAndSave();\
BLincheuYMin( 0 , 1 , 2 );\
GLI_M_CallNextFunc();\
} else\
if (XYBuilder == 3)\
{\
BLincheuYMin( 0 , 1 , 2 );\
GLI_M_CallNextFunc();\
} \
return;\
}
/* ----------------------------------------------------------------------------------------------*/
/* CLIPPING X MIN */
#undef ComputeCurrentXY
#define ComputeCurrentXY() GetX(CurrentDestXYZ[XYcounter]) - *(float *)&fXMin_CLIP_Optimize
#undef GLI_M_restorePerfectClipping
#define GLI_M_restorePerfectClipping() SetX(LocalTab[XYBuilder],*(float *)&fXMin_CLIP_Optimize);
GLI_FuncNodeBegin(GLI_XMinCLipping)
{
unsigned long K;
K = (((unsigned long )((*((long *)&GetX(CurrentDestXYZ[0])) - fXMin_CLIP_Optimize))) >> 31) | (*((unsigned long *)&GetX(CurrentDestXYZ[0])) >> 31);
K += (((unsigned long )((*((long *)&GetX(CurrentDestXYZ[1])) - fXMin_CLIP_Optimize))) >> 31) | (*((unsigned long *)&GetX(CurrentDestXYZ[1])) >> 31);
K += (((unsigned long )((*((long *)&GetX(CurrentDestXYZ[2])) - fXMin_CLIP_Optimize))) >> 31) | (*((unsigned long *)&GetX(CurrentDestXYZ[2])) >> 31);
GLI_M_ScreenClipping();
}
/* ----------------------------------------------------------------------------------------------*/
/* CLIPPING Y MIN */
#undef ComputeCurrentXY
#define ComputeCurrentXY() GetY(CurrentDestXYZ[XYcounter]) - *(float *)&fYMin_CLIP_Optimize
#undef GLI_M_restorePerfectClipping
#define GLI_M_restorePerfectClipping() SetY(LocalTab[XYBuilder],*(float *)&fYMin_CLIP_Optimize);
GLI_FuncNodeBegin(GLI_YMinCLipping)
{
unsigned long K;
K = (((unsigned long )((*((long *)&GetY(CurrentDestXYZ[0])) - fYMin_CLIP_Optimize))) >> 31) | (*((unsigned long *)&GetY(CurrentDestXYZ[0])) >> 31);
K += (((unsigned long )((*((long *)&GetY(CurrentDestXYZ[1])) - fYMin_CLIP_Optimize))) >> 31) | (*((unsigned long *)&GetY(CurrentDestXYZ[1])) >> 31);
K += (((unsigned long )((*((long *)&GetY(CurrentDestXYZ[2])) - fYMin_CLIP_Optimize))) >> 31) | (*((unsigned long *)&GetY(CurrentDestXYZ[2])) >> 31);
GLI_M_ScreenClipping();
}
/* ----------------------------------------------------------------------------------------------*/
/* CLIPPING X MAX */
#undef ComputeCurrentXY
#define ComputeCurrentXY() *(float *)&fXMax_CLIP_Optimize - GetX(CurrentDestXYZ[XYcounter])
#undef GLI_M_restorePerfectClipping
#define GLI_M_restorePerfectClipping() SetX(LocalTab[XYBuilder],*(float *)&fXMax_CLIP_Optimize );
GLI_FuncNodeBegin(GLI_XMaxCLipping)
{
long K;
K = (((unsigned long )(fXMax_CLIP_Optimize - (*((long *)&GetX(CurrentDestXYZ[0]))))) >> 31) | (*((unsigned long *)&GetX(CurrentDestXYZ[0])) >> 31);
K += (((unsigned long )(fXMax_CLIP_Optimize - (*((long *)&GetX(CurrentDestXYZ[1]))))) >> 31) | (*((unsigned long *)&GetX(CurrentDestXYZ[1])) >> 31);
K += (((unsigned long )(fXMax_CLIP_Optimize - (*((long *)&GetX(CurrentDestXYZ[2]))))) >> 31) | (*((unsigned long *)&GetX(CurrentDestXYZ[2])) >> 31);
GLI_M_ScreenClipping();
}
/* ----------------------------------------------------------------------------------------------*/
/* CLIPPING Y MAX */
#undef ComputeCurrentXY
#define ComputeCurrentXY() *(float *)&fYMax_CLIP_Optimize - GetY(CurrentDestXYZ[XYcounter])
#undef GLI_M_restorePerfectClipping
#define GLI_M_restorePerfectClipping() SetY(LocalTab[XYBuilder],*(float *)&fYMax_CLIP_Optimize);
GLI_FuncNodeBegin(GLI_YMaxCLipping)
{
/*static int mytest = 1;*/
long K;
K = (((unsigned long )(fYMax_CLIP_Optimize - (*((long *)&GetY(CurrentDestXYZ[0]))))) >> 31) | (*((unsigned long *)&GetY(CurrentDestXYZ[0])) >> 31);
K += (((unsigned long )(fYMax_CLIP_Optimize - (*((long *)&GetY(CurrentDestXYZ[1]))))) >> 31) | (*((unsigned long *)&GetY(CurrentDestXYZ[1])) >> 31);
K += (((unsigned long )(fYMax_CLIP_Optimize - (*((long *)&GetY(CurrentDestXYZ[2]))))) >> 31) | (*((unsigned long *)&GetY(CurrentDestXYZ[2])) >> 31);
GLI_M_ScreenClipping();
/*
if (!mytest)
{
GLI_M_ScreenClipping();
}
else
{
if (K == 0)
{
GLI_M_CallNextFunc();
return;
}
else if (K == 3)
{
return;
}
else
{
float fXYClipLocalCoef,CurrentXY,LastXY;
GLI_tdScreenVertx LocalTab[4];
unsigned long XYcounter,XYBuilder;
ACP_tdst2DUVValues stUV[4];
for ( XYcounter = 0 ; XYcounter < 3 ; XYcounter ++ )
{
stUV[XYcounter+1].xU = d_stVirtualUV[XYcounter]->xU * GetZ(CurrentDestXYZ[XYcounter]);
stUV[XYcounter+1].xV = d_stVirtualUV[XYcounter]->xV * GetZ(CurrentDestXYZ[XYcounter]);
d_stVirtualUV[XYcounter] = &stUV[XYcounter+1];
}
if (K == 1) /* un seul <20> l'ext<78>rieur, g<>n<EFBFBD>re deux triangles */
/*
{
XYcounter = 0;
LastXY = ComputeCurrentXY();
if ( (*(unsigned long *)&LastXY) >> 31 )
{
XYBuilder = 0;
XYcounter = 2;
CurrentXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 2, 0);
XYBuilder = 1;
XYcounter = 1;
CurrentXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 1, 0);
LocalTab[2] = CurrentDestXYZ[1];
//stUV[2] = *d_stVirtualUV[1];
LocalTab[3] = CurrentDestXYZ[2];
//stUV[3] = *d_stVirtualUV[2];
}
else
{
XYcounter = 1;
LastXY = ComputeCurrentXY();
if ( (*(unsigned long *)&LastXY) >> 31 )
{
LocalTab[0] = CurrentDestXYZ[0];
stUV[0] = *d_stVirtualUV[0];
XYBuilder = 1;
XYcounter = 0;
CurrentXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 0, 1);
XYBuilder = 2;
XYcounter = 2;
CurrentXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 2, 1);
LocalTab[3] = CurrentDestXYZ[2];
//stUV[XYBuilder] = *d_stVirtualUV[2];
}
else
{
XYcounter = 2;
LastXY = ComputeCurrentXY();
XYBuilder = 0;
XYcounter = 0;
CurrentXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 0, 2);
LocalTab[1] = CurrentDestXYZ[0];
//stUV[1] = *d_stVirtualUV[0];
LocalTab[2] = CurrentDestXYZ[1];
//stUV[XYBuilder] = *d_stVirtualUV[1];
XYBuilder = 3;
XYcounter = 1;
CurrentXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 1, 2);
}
}
for ( XYcounter = 0 ; XYcounter < 4; XYcounter ++ )
{
fXYClipLocalCoef = 1.0f / GetZ(LocalTab[XYcounter]);
stUV[XYcounter].xU = stUV[XYcounter].xU * fXYClipLocalCoef;
stUV[XYcounter].xV = stUV[XYcounter].xV * fXYClipLocalCoef;
}
BLincheuYMin( 0 , 2 , 3 );
GLI_M_CallNextFuncAndSave();
BLincheuYMin( 0 , 1 , 2 );
GLI_M_CallNextFunc();
}
else /* deux <20> l'ext<78>rieur */
/* {
XYcounter = 0;
CurrentXY = ComputeCurrentXY();
if ( !((*(unsigned long *)&CurrentXY) >> 31 ) )
{
XYBuilder = 0;
XYcounter = 2;
LastXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 0, 2);
LocalTab[1] = CurrentDestXYZ[0];
//stUV[1] = *d_stVirtualUV[0];
XYBuilder = 2;
XYcounter = 1;
LastXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 0, 1);
}
else
{
XYcounter = 1;
CurrentXY = ComputeCurrentXY();
if ( !((*(unsigned long *)&CurrentXY) >> 31 ) ) // vertex 1 in other out
{
XYBuilder = 0;
XYcounter = 0;
LastXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 1, 0);
LocalTab[1] = CurrentDestXYZ[1];
stUV[1] = *d_stVirtualUV[1];
XYBuilder = 2;
XYcounter = 2;
LastXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 1, 2);
}
else //vertex2 is in, other out
{
XYcounter = 2;
CurrentXY = ComputeCurrentXY();
XYBuilder = 0;
XYcounter = 0;
LastXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 2, 0);
XYBuilder = 1;
XYcounter = 1;
LastXY = ComputeCurrentXY();
fXYClipLocalCoef = CurrentXY / ( CurrentXY - LastXY );
GLI_M_BuildPointIOXY( 2, 1);
LocalTab[2] = CurrentDestXYZ[2];
stUV[2] = *d_stVirtualUV[2];
}
}
for ( XYcounter = 0 ; XYcounter < 3; XYcounter ++ )
{
fXYClipLocalCoef = 1.0f / GetZ(LocalTab[XYcounter]);
stUV[XYcounter].xU = stUV[XYcounter].xU * fXYClipLocalCoef;
stUV[XYcounter].xV = stUV[XYcounter].xV * fXYClipLocalCoef;
}
BLincheuYMin( 0 , 1 , 2 );
GLI_M_CallNextFunc();
}
return;
}
}
*/
}
/* ------------------------------------------------------------------------------------------------*/
/* Water Clipping*/
/* ------------------------------------------------------------------------------------------------*/
#define GLI_M_BuildPointIOWater( Index, Index2 )\
{\
p_stLocalZClipVertex1 = (GLI_BIG_GLOBALS -> GLI_TurnedScaledDisplecedPoint + p_stCurrentTriangle -> a3_xIndex[Index]);\
p_stLocalZClipVertex2 = (GLI_BIG_GLOBALS -> GLI_TurnedScaledDisplecedPoint + p_stCurrentTriangle -> a3_xIndex[Index2]);\
p_stLocalZClipVertex->xX = p_stLocalZClipVertex1 -> xX + (p_stLocalZClipVertex2 -> xX - p_stLocalZClipVertex1 -> xX) * fZClipLocalCoef;\
p_stLocalZClipVertex->xY = p_stLocalZClipVertex1 -> xY + (p_stLocalZClipVertex2 -> xY - p_stLocalZClipVertex1 -> xY) * fZClipLocalCoef;\
p_stLocalZClipVertex->xZ = p_stLocalZClipVertex1 -> xZ + (p_stLocalZClipVertex2 -> xZ - p_stLocalZClipVertex1 -> xZ) * fZClipLocalCoef;\
xLocalRestoreRefraction = MTH3D_M_xDotProductVector( (MTH3D_tdstVector *)p_stLocalZClipVertex , (MTH3D_tdstVector *)&GLI_BIG_GLOBALS->stWaterPlanNormale) - GLI_BIG_GLOBALS->xWaterPlaneDistance;\
p_stLocalZClipVertex->xX -= GLI_BIG_GLOBALS->stWaterPlanNormale.xX * xLocalRestoreRefraction;\
p_stLocalZClipVertex->xY -= GLI_BIG_GLOBALS->stWaterPlanNormale.xY * xLocalRestoreRefraction;\
p_stLocalZClipVertex->xZ -= GLI_BIG_GLOBALS->stWaterPlanNormale.xZ * xLocalRestoreRefraction;\
/*GLI_vInformWaterNoise(p_stLocalZClipVertex,GLI_BIG_GLOBALS);*/\
GLI_MDRV_vSerialProjection( GLI_BIG_GLOBALS -> p_stCurrentCamera , 1 , p_stLocalZClipVertex , p_stLocalZProjVertex);\
SetX(LocalTab[ZBuilder],p_stLocalZProjVertex->xX); \
SetY(LocalTab[ZBuilder],p_stLocalZProjVertex->xY); \
SetZ(LocalTab[ZBuilder],p_stLocalZProjVertex->xOoZ); \
SetX(LocalTabSub[ZBuilderSub],p_stLocalZProjVertex->xX); \
SetY(LocalTabSub[ZBuilderSub],p_stLocalZProjVertex->xY); \
SetZ(LocalTabSub[ZBuilderSub],p_stLocalZProjVertex->xOoZ); \
SetPackedColor(LocalTab[ZBuilder],GLI_ulInterpol2PackedColor(GetPackedColor(CurrentDestXYZ[Index]),GetPackedColor(CurrentDestXYZ[Index2]),fZClipLocalCoef * GetZ(CurrentDestXYZ[Index2]) / GetZ(LocalTab[ZBuilder])) );\
SetPackedColor(LocalTabSub[ZBuilderSub],GetPackedColor(LocalTab[ZBuilder])) ;\
SetU(LocalTab[ZBuilder],(d_stVirtualUV[Index]) -> xU + ((d_stVirtualUV[Index2]) -> xU - (d_stVirtualUV[Index]) -> xU) * fZClipLocalCoef ); \
SetV(LocalTab[ZBuilder],(d_stVirtualUV[Index]) -> xV + ((d_stVirtualUV[Index2]) -> xV - (d_stVirtualUV[Index]) -> xV) * fZClipLocalCoef ); \
SetU(LocalTabSub[ZBuilderSub],(d_stVirtualUV[Index]) -> xU + ((d_stVirtualUV[Index2]) -> xU - (d_stVirtualUV[Index]) -> xU) * fZClipLocalCoef ); \
SetV(LocalTabSub[ZBuilderSub],(d_stVirtualUV[Index]) -> xV + ((d_stVirtualUV[Index2]) -> xV - (d_stVirtualUV[Index]) -> xV) * fZClipLocalCoef ); \
Index_LocalTabSub[ZBuilderSub++] = NewVertices;\
Index_LocalTab[ZBuilder++] = NewVertices++;\
p_stLocalZClipVertex++;\
p_stLocalZProjVertex++;\
}
#define BLincheuWater( aws, bws, cws)\
{\
p_stCurrentTriangle -> a3_xIndex[0] = Index_LocalTab[aws];\
p_stCurrentTriangle -> a3_xIndex[1] = Index_LocalTab[bws];\
p_stCurrentTriangle -> a3_xIndex[2] = Index_LocalTab[cws];\
CurrentDestXYZ[0] = LocalTab[aws];\
CurrentDestXYZ[1] = LocalTab[bws];\
CurrentDestXYZ[2] = LocalTab[cws];\
GLI_M_RestoreCW();\
d_stVirtualUV[0] = (ACP_tdst2DUVValues *)&GetU(LocalTab[aws]);\
d_stVirtualUV[1] = (ACP_tdst2DUVValues *)&GetU(LocalTab[bws]);\
d_stVirtualUV[2] = (ACP_tdst2DUVValues *)&GetU(LocalTab[cws]);\
}
#define BLincheuWaterSub( aws, bws, cws)\
{\
p_stCurrentTriangle -> a3_xIndex[0] = Index_LocalTabSub[aws];\
p_stCurrentTriangle -> a3_xIndex[1] = Index_LocalTabSub[bws];\
p_stCurrentTriangle -> a3_xIndex[2] = Index_LocalTabSub[cws];\
CurrentDestXYZ[0] = LocalTabSub[aws];\
CurrentDestXYZ[1] = LocalTabSub[bws];\
CurrentDestXYZ[2] = LocalTabSub[cws];\
GLI_M_RestoreCW();\
d_stVirtualUV[0] = (ACP_tdst2DUVValues *)&GetU(LocalTabSub[aws]);\
d_stVirtualUV[1] = (ACP_tdst2DUVValues *)&GetU(LocalTabSub[bws]);\
d_stVirtualUV[2] = (ACP_tdst2DUVValues *)&GetU(LocalTabSub[cws]);\
}
GLI_FuncNodeBegin(GLI_FastWaterCLipping)
{
long K;
K = ((*(unsigned long *)(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[0])>>31) + (*(unsigned long *)(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[1])>>31) + (*(unsigned long *)(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[2])>>31));
if ((K != 3) && (K != 0))
{
GEO_tdstTripledIndex stNewCurrentTriangle;
GEO_tdstTripledIndex *p_stCurrentTriangleSave;
float xLocalRestoreRefraction;
GLI_tdstAligned3DVector *p_stLocalZClipVertex;
GLI_tdstAligned3DVector *p_stLocalZClipVertex1;
GLI_tdstAligned3DVector *p_stLocalZClipVertex2;
GLI_tdstAligned2DVector *p_stLocalZProjVertex;
float fZClipLocalCoef,LastWaterDepth,WaterDepth;
GLI_tdScreenVertx LocalTab[4];
ACP_tdxIndex Index_LocalTab[4],NewVertices ;
GLI_tdScreenVertx LocalTabSub[4];
ACP_tdxIndex Index_LocalTabSub[4];
unsigned long ZState,Zcounter,ZCounterLast,ZBuilder,ZBuilderSub;
NewVertices = GLI_BIG_GLOBALS-> p_stObj -> xNbPoints;
p_stCurrentTriangleSave = p_stCurrentTriangle ;
p_stLocalZClipVertex = GLI_BIG_GLOBALS -> GLI_TurnedScaledDisplecedPoint + NewVertices;
p_stLocalZProjVertex = GLI_BIG_GLOBALS -> GLI_ScreenPoint + NewVertices;
LastWaterDepth = *(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[2]);
ZState = (*(unsigned long *)&LastWaterDepth) >> 31 ;
for ( ZBuilder = 0 , ZBuilderSub = 0 , ZCounterLast = 2 , Zcounter = 0 ; Zcounter < 3 ; ZCounterLast = Zcounter , Zcounter ++ )
{
WaterDepth = *(GLI_BIG_GLOBALS -> GLI_aDEF_xWaterPlaneDepth + p_stCurrentTriangle -> a3_xIndex[Zcounter]);
ZState = ((*(unsigned long *)&WaterDepth) >> 31) | (ZState<<1); /* Kepp the sign*/
switch ( ZState & 3 )
{
case 2: /*Come in*/
fZClipLocalCoef = WaterDepth / ( WaterDepth - LastWaterDepth );
GLI_M_BuildPointIOWater( Zcounter , ZCounterLast );
case 0: /*Stay in*/
LocalTab[ZBuilder] = CurrentDestXYZ[Zcounter];
Index_LocalTab[ZBuilder] = p_stCurrentTriangle -> a3_xIndex[Zcounter];
*(ACP_tdst2DUVValues *)&GetU(LocalTab[ZBuilder]) = *d_stVirtualUV[Zcounter];
ZBuilder++;
break;
case 1: /*Go out*/
fZClipLocalCoef = LastWaterDepth / ( LastWaterDepth - WaterDepth ) ;
GLI_M_BuildPointIOWater( ZCounterLast , Zcounter );
case 3: /*Stay out*/
LocalTabSub[ZBuilderSub] = CurrentDestXYZ[Zcounter];
Index_LocalTabSub[ZBuilderSub] = p_stCurrentTriangle -> a3_xIndex[Zcounter];
*(ACP_tdst2DUVValues *)&GetU(LocalTabSub[ZBuilderSub]) = *d_stVirtualUV[Zcounter];
ZBuilderSub++;
break;
}
LastWaterDepth = WaterDepth;
}
p_stCurrentTriangle = &stNewCurrentTriangle;
if (ZBuilder == 4)
{
BLincheuWater( 0 , 2 , 3 );
GLI_M_CallNextFuncAndSave();
BLincheuWater( 0 , 1 , 2 );
GLI_M_CallNextFuncAndSave();
BLincheuWaterSub( 0 , 1 , 2 );
GLI_M_CallNextFunc();
} else
{
BLincheuWaterSub( 0 , 2 , 3 );
GLI_M_CallNextFuncAndSave();
BLincheuWaterSub( 0 , 1 , 2 );
GLI_M_CallNextFuncAndSave();
BLincheuWater( 0 , 1 , 2 );
GLI_M_CallNextFunc();
}
p_stCurrentTriangle = p_stCurrentTriangleSave ;
return;
}
GLI_M_CallNextFunc();
}

View File

@@ -0,0 +1,921 @@
/******************************************************************************************
FILE : CLIP.C
VERS : 1.00 \ Philippe Vimont
DATE : 15.05.98
*******************************************************************************************/
#include "Gli_st.h"
#include "GLI_Defn.h"
#include "polygon.h"
#include "mater_st.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "Liste.h"
#include "watrplan.h"
#include "proj.h"
#include "vpt3D.h"
#include "camera.h"
#include "material.h"
#include "texture.h"
#include "DLLCom.h"
#include "TEX.h"
#include "PRF.h"
#ifdef SGL2
#include <SGL2.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef ZARMA
}}}
#endif
#include "drawflags.h"
/* collect the functions we need to call*/
/* we need to set this to zero somewhere*/
unsigned long ulFuncMask;
char temp_string[100]; \
/* -----------------------------------------------------------------------------------------*/
/* Global variable for optimisation */
/*---------------------------------------------------------------------------------------------*/
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
static float fAddU,fAddV,fConstantMirrorZValue;
static GEO_tdstTripledIndex *p_stCurrentTriangle , *p_stCurrentTriangleUV , *p_stLastTriangle;
static GEO_tdstElementIndexedTriangles *p_stCurrentElementIndexedTriangle ;
static long fX_CMP_Optimize , fY_CMP_Optimize;
static long fXMin_CLIP_Optimize , fYMin_CLIP_Optimize , fXMax_CLIP_Optimize , fYMax_CLIP_Optimize ;
static unsigned long *footptr;
static ACP_tdst2DUVValues *d_stVirtualUV[3];
extern void GLI_vDoTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
extern void GLI_vSetGlobalAlpha(float Alpha);
#define GLI_C_lCLIP_ALL (GLI_C_ClipMaskXMin | GLI_C_ClipMaskXMax | GLI_C_ClipMaskYMin | GLI_C_ClipMaskYMax )
/* -----------------------------------------------------------------------------------------*/
/**********************************************************************************************/
/* Name: GLI_vSetZClip*/
/* Goal: */
/* Code: Philippe Vimont */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void GLI_DRV_vSetZClip(float ZClip,GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
p_stGlobaleMT -> fZClipping = ZClip;
p_stGlobaleMT -> fWClipping = 1.0f / ZClip;
}
/**********************************************************************************************/
/* Name: GLI_vSetClipWindow*/
/* Goal: */
/* Code: Philippe Vimont */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void GLI_DRV_vSetClipWindow(float fXMin,float fXMax,float fYMin,float fYMax,GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
p_stGlobaleMT->fXMinClipping = fXMin;
p_stGlobaleMT->fXMaxClipping = fXMax;
p_stGlobaleMT->fYMinClipping = fYMin;
p_stGlobaleMT->fYMaxClipping = fYMax;
}
/**********************************************************************************************/
/* Name: GLI_ulInterpol2PackedColor*/
/* Goal: interpol 2 unsigned long coded colors with a float [0.0 .. 1.0f]*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
unsigned long GLI_ulInterpol2PackedColor(unsigned long ulP1,unsigned long ulP2,float fZClipLocalCoef)
{
unsigned long RetValue,Interpoler;
if (fZClipLocalCoef >= 0.98f)
return ulP2;
if (fZClipLocalCoef <= 0.02f)
return ulP1;
*((float *)&Interpoler) = fZClipLocalCoef + 32768.0f + 16384.0f;
RetValue = (Interpoler & 128) ? (ulP2 & 0xfefefefe) >> 1 : (ulP1 & 0xfefefefe) >> 1;
RetValue += (Interpoler & 64) ? (ulP2 & 0xfcfcfcfc) >> 2 : (ulP1 & 0xfcfcfcfc) >> 2;
RetValue += (Interpoler & 32) ? (ulP2 & 0xf8f8f8f8) >> 3 : (ulP1 & 0xf8f8f8f8) >> 3;
RetValue += (Interpoler & 16) ? (ulP2 & 0xf0f0f0f0) >> 4 : (ulP1 & 0xf0f0f0f0) >> 4;
RetValue += (Interpoler & 8) ? (ulP2 & 0xe0e0e0e0) >> 5 : (ulP1 & 0xe0e0e0e0) >> 5;
RetValue += (Interpoler & 4) ? (ulP2 & 0xc0c0c0c0) >> 6 : (ulP1 & 0xc0c0c0c0) >> 6;
RetValue += (Interpoler & 2) ? (ulP2 & 0x80808080) >> 7 : (ulP1 & 0x80808080) >> 7;
return RetValue;
}
/*void GLI_vInformWaterNoise(GLI_tdstAligned3DVector *p_Point,GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BG);*/
/* -----------------------------------------------------------------------------------------*/
/* Stack function's stuff */
/*---------------------------------------------------------------------------------------------*/
#define GLI_FuncNodeBegin(a) static void GLI_INTERFACE_FUNC(a) (void)
static long lActualFunction;
static void GLI_fn_LastFunc(void) {};
static void (* GLI_p_fn_ListOfFunc[20])(void) ;
static void (** GLI_fnCurrentFunc)(void) ;
static void GLI_M_ClearFuncList()
{
ulFuncMask = 0;
lActualFunction = 0;
GLI_p_fn_ListOfFunc[0] = GLI_fn_LastFunc;
}
/* static void GLI_M_AddFunc(void (* Func)(void)) */
#define GLI_M_AddFunc( Func ) \
(GLI_p_fn_ListOfFunc[lActualFunction++] = Func)
/* Print out ulFuncMask to Error log here if benching*/
#define GLI_M_CallFirstFunc() \
{\
GLI_fnCurrentFunc = GLI_p_fn_ListOfFunc; \
(*(GLI_fnCurrentFunc))(); \
}
#define GLI_M_CallNextFunc() (*(++GLI_fnCurrentFunc))();
#define GLI_M_CallNextFuncAndSave() \
{\
void (** GLI_fnCurrentFuncSave)(void) ;\
GLI_fnCurrentFuncSave = GLI_fnCurrentFunc;\
(*(++GLI_fnCurrentFunc))();\
GLI_fnCurrentFunc = GLI_fnCurrentFuncSave ;\
}
#define GLI_M_TriangleIsOut() return
/* -----------------------------------------------------------------------------------------*/
/* ZList function stuff */
/*---------------------------------------------------------------------------------------------*/
void GLI_DRV_xClearViewingList ( void )
{
unsigned long ulTableCounter;
if (GLI_BIG_GLOBALS -> p_TheZListe == NULL) return;
GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint = GLI_BIG_GLOBALS -> p_TheZListe -> p_TableOfPoints;
GLI_BIG_GLOBALS -> p_TheZListe -> p_stCurrentZNode = GLI_BIG_GLOBALS -> p_TheZListe -> aDEF_tdstZListeNodes;
for (ulTableCounter = 0; ulTableCounter < GLI_NumberOfZListes ; ulTableCounter ++)
{
GLI_BIG_GLOBALS -> p_TheZListe -> lMinValue[ulTableCounter] = 1 << GLI_MaxZEntryPO2;
GLI_BIG_GLOBALS -> p_TheZListe -> lMaxValue[ulTableCounter] = 0;
}
}
void GLI_v_AddNodeInZList(float Z)
{
unsigned short index;
index = (unsigned short )(((*(unsigned long *)&Z) >> 16) - 13000) & ((1 << GLI_MaxZEntryPO2) - 1);
if( GLI_BIG_GLOBALS->p_TheZListe->lMinValue[ GLI_BIG_GLOBALS->ulCurrentZTable ] > index )
GLI_BIG_GLOBALS->p_TheZListe->lMinValue[ GLI_BIG_GLOBALS->ulCurrentZTable ] = index;
if( GLI_BIG_GLOBALS->p_TheZListe->lMaxValue[ GLI_BIG_GLOBALS->ulCurrentZTable ] < index )
GLI_BIG_GLOBALS->p_TheZListe->lMaxValue[ GLI_BIG_GLOBALS->ulCurrentZTable ] = index;
GLI_BIG_GLOBALS->p_TheZListe->p_stCurrentZNode->p_ThreePoints = GLI_BIG_GLOBALS->p_TheZListe->p_CurrentPoint;
GLI_BIG_GLOBALS->p_TheZListe->p_stCurrentZNode->p_TextureOfTheTriangle = GLI_BIG_GLOBALS->p_stCurrentTexture;
/**/
GLI_BIG_GLOBALS->p_TheZListe->p_stCurrentZNode->p_stMaterial = GLI_BIG_GLOBALS->hCurrentMaterial;
GLI_BIG_GLOBALS->p_TheZListe->p_stCurrentZNode->lCurrentDrawMask = GLI_BIG_GLOBALS->lCurrentDrawMask & ~GLI_C_lIsWriteZBuffer;
GLI_BIG_GLOBALS->p_TheZListe->p_stCurrentZNode->p_stFogParams = GLI_BIG_GLOBALS->p_stActiveFog ;
GLI_BIG_GLOBALS->p_TheZListe->p_stCurrentZNode->p_NextNode = GLI_BIG_GLOBALS->p_TheZListe->aDEF_p_tdstTableOfZentryNearestOfWaterPlane[ index + ( GLI_BIG_GLOBALS->ulCurrentZTable << GLI_MaxZEntryPO2 ) ];
GLI_BIG_GLOBALS->p_TheZListe->aDEF_p_tdstTableOfZentryNearestOfWaterPlane[ index + ( GLI_BIG_GLOBALS->ulCurrentZTable << GLI_MaxZEntryPO2 ) ] = GLI_BIG_GLOBALS->p_TheZListe->p_stCurrentZNode;
GLI_BIG_GLOBALS->p_TheZListe->p_stCurrentZNode++;
}
#define GLI_M_InitSprite()\
{\
SetX(CurrentDestXYZ[0],a4_st2DVertex [0] . xX);\
SetY(CurrentDestXYZ[0],a4_st2DVertex [0] . xY);\
SetX(CurrentDestXYZ[1],a4_st2DVertex [1] . xX);\
SetY(CurrentDestXYZ[1],a4_st2DVertex [1] . xY);\
SetX(CurrentDestXYZ[2],a4_st2DVertex [2] . xX);\
SetY(CurrentDestXYZ[2],a4_st2DVertex [2] . xY);\
SetX(CurrentDestXYZ[3],a4_st2DVertex [3] . xX);\
SetY(CurrentDestXYZ[3],a4_st2DVertex [3] . xY);\
SetZ(CurrentDestXYZ[0],xZ );\
SetZ(CurrentDestXYZ[1],xZ );\
SetZ(CurrentDestXYZ[2],xZ );\
SetZ(CurrentDestXYZ[3],xZ );\
SetPackedColor( CurrentDestXYZ[0] , p_stGlobaleMT -> ulColorInitForSprite);\
SetPackedColor( CurrentDestXYZ[1] , p_stGlobaleMT -> ulColorInitForSprite);\
SetPackedColor( CurrentDestXYZ[2] , p_stGlobaleMT -> ulColorInitForSprite);\
SetPackedColor( CurrentDestXYZ[3] , p_stGlobaleMT -> ulColorInitForSprite);\
}
#define GLI_M_InitLine()\
{\
SetX(CurrentDestXYZ[0],p_st2DVertex1->xX);\
SetY(CurrentDestXYZ[0],p_st2DVertex1->xY);\
SetX(CurrentDestXYZ[1],p_st2DVertex2->xX);\
SetY(CurrentDestXYZ[1],p_st2DVertex2->xY);\
SetZ(CurrentDestXYZ[0],p_stVertex1->xZ );\
SetZ(CurrentDestXYZ[1],p_stVertex2->xZ );\
SetPackedColor(CurrentDestXYZ[0],p_st2DVertex1->ulPackedColor );\
SetPackedColor(CurrentDestXYZ[1],p_st2DVertex2->ulPackedColor );\
}
/*---------------------------------------------------------------------------------------------*/
/* Kamui specific*/
/*---------------------------------------------------------------------------------------------*/
#ifdef KAMUI
#include "Kamui\Acces_KAMUI.c"
#include "Acces_ALL.c"
#endif
/*---------------------------------------------------------------------------------------------*/
/* SGL2 specific*/
/*---------------------------------------------------------------------------------------------*/
#ifdef SGL2
#include "SGL2\Acces_SGL2.c"
#include "Acces_ALL.c"
#endif
/*---------------------------------------------------------------------------------------------*/
/* VOODOO1 specific*/
/*---------------------------------------------------------------------------------------------*/
#ifdef GLIDE2
#include "GLIDE2\SRC\Acces_GLIDE2.c"
#include "Acces_ALL.c"
#endif
/*---------------------------------------------------------------------------------------------*/
/* VOODOO1 specific with multitexture*/
/*---------------------------------------------------------------------------------------------*/
#ifdef GLIDE2MT
#include "GLIDE2MT\SRC\Glide2MT_Acces.c"
#include "Acces_ALL.c"
#endif
/*---------------------------------------------------------------------------------------------*/
/* VOODOO2 specific*/
/*---------------------------------------------------------------------------------------------*/
#ifdef GLIDE3
#include "GLIDE3\SRC\GLIDE3_Acces.c"
#include "Acces_ALL.c"
#endif
/*---------------------------------------------------------------------------------------------*/
/* DirectX6 specific*/
/*---------------------------------------------------------------------------------------------*/
#ifdef GLI_DIRECTX6
#include "DirectX6\Src\DX6_Acces.c"
#include "Acces_ALL.c"
#endif
/*---------------------------------------------------------------------------------------------*/
/* OpenGL specific*/
/*---------------------------------------------------------------------------------------------*/
#ifdef GLI_OPENGL
#include "OpenGL\Src\OGL_Acces.c"
#include "Acces_ALL.c"
#endif
/* -----------------------------------------------------------------------------------------*/
/* ZList Draw stuff */
/*---------------------------------------------------------------------------------------------*/
void GLI_vDoTransparentTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
void GLI_fn_vSetRenderParametersBeforeTransparencyFace( void );
void GLI_DRV_xSendListToViewport ( GLD_tdstViewportAttributes *p_stVpt )
{
GLI_tdstOneNodeOfZListe *p_CuurentNode,**p_TableEntry,**p_LastTableEntry;
unsigned long ulTableCounter;
if (GLI_BIG_GLOBALS->p_TheZListe == NULL)
return;
GLI_BIG_GLOBALS -> lCurrentDrawMask = 0xFFFFFFFF;
GLI_BIG_GLOBALS -> p_stCurrentTexture = NULL;
GLI_MDRV_vSetGlobalAlpha(128);
GLI_BeforeDraw();
GLI_fn_vSetRenderParametersBeforeTransparencyFace();
for (ulTableCounter = 0; ulTableCounter < GLI_NumberOfZListes; ulTableCounter ++)
{
if ( GLI_BIG_GLOBALS->p_TheZListe->lMaxValue[ulTableCounter] < GLI_BIG_GLOBALS->p_TheZListe->lMinValue[ulTableCounter] )
continue;
p_TableEntry = GLI_BIG_GLOBALS -> p_TheZListe -> aDEF_p_tdstTableOfZentryNearestOfWaterPlane + (ulTableCounter << GLI_MaxZEntryPO2);
p_LastTableEntry = p_TableEntry + GLI_BIG_GLOBALS -> p_TheZListe -> lMaxValue[ulTableCounter];
p_TableEntry += GLI_BIG_GLOBALS -> p_TheZListe -> lMinValue[ulTableCounter];
/*p_LastTableEntry = p_TableEntry + GLI_BIG_GLOBALS -> p_TheZListe -> lMaxValue[ulTableCounter];*/
while (p_TableEntry <= p_LastTableEntry)
{
p_CuurentNode = *(p_TableEntry);
while (p_CuurentNode != NULL)
{
if (
( GLI_BIG_GLOBALS->p_stCurrentTexture != p_CuurentNode->p_TextureOfTheTriangle)
|| ( GLI_BIG_GLOBALS->lCurrentDrawMask != (long) p_CuurentNode->lCurrentDrawMask)
|| ( GLI_BIG_GLOBALS->p_stLastComputedFog != p_CuurentNode->p_stFogParams)
)
{
GLI_AfterDraw();
GLI_BIG_GLOBALS->lCurrentDrawMask = p_CuurentNode->lCurrentDrawMask ;
GLI_BIG_GLOBALS->p_stCurrentTexture = p_CuurentNode->p_TextureOfTheTriangle;
/*GLI_BIG_GLOBALS->hCurrentMaterial = NULL;*/
GLI_BIG_GLOBALS->hCurrentMaterial = p_CuurentNode->p_stMaterial;
/*
* fog
*/
if (p_CuurentNode->p_stFogParams)
{
GLI_BIG_GLOBALS->xFogIsOn = 1;
GLI_BIG_GLOBALS->p_stActiveFog = p_CuurentNode->p_stFogParams;
}
else
{
GLI_BIG_GLOBALS->p_stLastComputedFog = NULL;
GLI_BIG_GLOBALS->p_stActiveFog = NULL;
GLI_BIG_GLOBALS->xFogIsOn = 0;
}
/*GLI_AfterDraw();*/
GLI_BeforeDraw();
GLI_vDoTransparentTextureSelection(GLI_BIG_GLOBALS );
}
if (p_CuurentNode -> lCurrentDrawMask & GLI_C_lIsGouraud )
GLI_vDrawZSortedTriangle(p_CuurentNode -> p_ThreePoints);
else
GLI_vDrawZSortedQuad(p_CuurentNode -> p_ThreePoints);
p_CuurentNode = p_CuurentNode -> p_NextNode;
}
*(p_TableEntry++) = NULL;
}
}
GLI_AfterDraw();
GLI_DRV_xClearViewingList();
}
/**********************************************************************************************/
/* Name: GLI_DRV_xSendElementTIToClip_TRIANGLES*/
/* Goal: Draw an element indexed triangles..*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void GLI_DRV_xSendElementTIToClip_TRIANGLES( GEO_tdstElementIndexedTriangles *p_stLocalElementIndexedTriangle , GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
ACP_tdxIndex xTriangleCounter ;
#ifdef SGL2
long AMirrorIsDetectedSave;
AMirrorIsDetectedSave = GLI_BIG_GLOBALS->lAMirrorIsDetected;
GLI_BIG_GLOBALS->lAMirrorIsDetected &= 0xffffffff - 2;
#endif
p_stCurrentElementIndexedTriangle = p_stLocalElementIndexedTriangle;
GLI_ReComputeClippingMask();
p_stGlobaleMT -> lCurrentDrawMask |= GLI_C_lIsGouraud;
fConstantMirrorZValue = 10.0f;
GLI_M_ClearFuncList();
/* -----------------------------------------------------------------------------------*/
/* First function*/
/* ------------------------------------------------------------------------------------*/
GLI_M_AddFunc(GLI_vComputeXYZ);
ulFuncMask |= Flag_GLI_vComputeXYZ;
/* -----------------------------------------------------------------------------------*/
/* Set UV*/
/* ------------------------------------------------------------------------------------*/
/*if (p_stGlobaleMT-> p_stCurrentTexture != NULL)*/
{
if (!(p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsNotChromed))
GLI_M_AddFunc(GLI_vSetChromeUVW);
else
GLI_M_AddFunc(GLI_vSetNormalUVW);
}
/* -----------------------------------------------------------------------------------*/
/* Fog effect*/
/* ------------------------------------------------------------------------------------*/
if (GLI_BIG_GLOBALS->xFogIsOn)
{
GLI_M_AddFunc(GLI_vSetSpecular);
ulFuncMask |= Flag_GLI_vSetSpecular;
}
/* ------------------------------------------------------------------------------------*/
/* MIRROR - WATER CLIPPING - OTHER CLIPPING ..... */
/* ------------------------------------------------------------------------------------*/
/* It coould be here*/
/* -----------------------------------------------------------------------------------*/
/* First CullingZ */
/* ------------------------------------------------------------------------------------*/
if (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_ClipMaskZ) {
GLI_M_AddFunc(GLI_FastZCull);
ulFuncMask |= Flag_GLI_FastZCull;
}
/* -----------------------------------------------------------------------------------*/
/* First Mirror Culling*/
/* ------------------------------------------------------------------------------------*/
if (!(GLI_BIG_GLOBALS -> lCurrentDrawMask & GLI_C_lNotHideWhatIsUnderWater)) {
GLI_M_AddFunc(GLI_FastMirrorCulling);
ulFuncMask |= Flag_GLI_FastMirrorCulling;
}
/* -----------------------------------------------------------------------------------*/
/* culing X Y*/
/* ------------------------------------------------------------------------------------*/
if (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_lCLIP_ALL)
{
if ( (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_lCLIP_ALL) == GLI_C_lCLIP_ALL ) {
GLI_M_AddFunc(GLI_bCullingXYALL);
ulFuncMask |= Flag_GLI_bCullingXYALL;
}
else
{
switch (GLI_BIG_GLOBALS -> lClippingModeMask & (GLI_C_ClipMaskXMin | GLI_C_ClipMaskXMax ))
{
case 0:break;
case GLI_C_ClipMaskXMin:GLI_M_AddFunc(GLI_bCullingXMin);
ulFuncMask |= Flag_GLI_bCullingXMin;
break;
case GLI_C_ClipMaskXMax:GLI_M_AddFunc(GLI_bCullingXMax);
ulFuncMask |= Flag_GLI_bCullingXMax;
break;
case GLI_C_ClipMaskXMin + GLI_C_ClipMaskXMax:GLI_M_AddFunc(GLI_bCullingXMax_XMin);
ulFuncMask |= Flag_GLI_bCullingXMax_XMin;
break;
}
switch (GLI_BIG_GLOBALS -> lClippingModeMask & (GLI_C_ClipMaskYMin | GLI_C_ClipMaskYMax ))
{
case 0:break;
case GLI_C_ClipMaskYMin:GLI_M_AddFunc(GLI_bCullingYMin);
ulFuncMask |= Flag_GLI_bCullingYMin;
break;
case GLI_C_ClipMaskYMax:GLI_M_AddFunc(GLI_bCullingYMax);
ulFuncMask |= Flag_GLI_bCullingYMax;
break;
case GLI_C_ClipMaskYMin + GLI_C_ClipMaskYMax:GLI_M_AddFunc(GLI_bCullingYMax_YMin);
ulFuncMask |= Flag_GLI_bCullingYMax_YMin;
break;
}
}
}
/* ------------------------------------------------------------------------------------*/
/* MIRROR - WATER CLIPPING - OTHER CLIPPING ..... Done after culling*/
/* ------------------------------------------------------------------------------------*/
if (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_ClipMaskWater)
{
if (GLI_BIG_GLOBALS -> lCurrentDrawMask & GLI_C_lNotHideWhatIsUnderWater) {
GLI_M_AddFunc(GLI_FastWaterCLipping);
ulFuncMask |= Flag_GLI_FastWaterCLipping;
}
else {
GLI_M_AddFunc(GLI_FastMirrorCLipping);
ulFuncMask |= Flag_GLI_FastMirrorCLipping;
}
}
/* ------------------------------------------------------------------------------------*/
/* Z CLIPPING;*/
/* ------------------------------------------------------------------------------------*/
if (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_ClipMaskZ) {
GLI_M_AddFunc(GLI_vZClipping);
ulFuncMask |= Flag_GLI_vZClipping;
}
/* ------------------------------------------------------------------------------------*/
/* BACKFACE INIT;*/
/* ------------------------------------------------------------------------------------*/
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsTestingBackface)
{
if ((p_stGlobaleMT -> lHierachDrawMask & GLI_C_lIsNotDrawingInMirror) ?
(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lNotInvertBackfaces) :
!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lNotInvertBackfaces) ) {
GLI_M_AddFunc(GLI_TestBackfaceClockwise);
ulFuncMask |= Flag_GLI_TestBackfaceClockwise;
}
else { /* reverse */
GLI_M_AddFunc(GLI_TestBackfaceCounterClockwize);
ulFuncMask |= Flag_GLI_TestBackfaceCounterClockwize;
}
}
/* ------------------------------------------------------------------------------------*/
/* XY CLIPPING..*/
/* ------------------------------------------------------------------------------------*/
#define GLI_C_lCUT_ALL (GLI_C_CutMaskXMin | GLI_C_CutMaskXMax | GLI_C_CutMaskYMin | GLI_C_CutMaskYMax )
if (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_lCUT_ALL)
{
switch (GLI_BIG_GLOBALS -> lClippingModeMask & (GLI_C_CutMaskXMin | GLI_C_CutMaskXMax ))
{
case 0:break;
case GLI_C_CutMaskXMin + GLI_C_CutMaskXMax:GLI_M_AddFunc(GLI_XMaxCLipping);
ulFuncMask |= Flag_GLI_XMaxCLipping;
/* STM - fallthrough - was already here*/
case GLI_C_CutMaskXMin:GLI_M_AddFunc(GLI_XMinCLipping);
ulFuncMask |= Flag_GLI_XMinCLipping;
break;
case GLI_C_CutMaskXMax:GLI_M_AddFunc(GLI_XMaxCLipping);
ulFuncMask |= Flag_GLI_XMaxCLipping;
break;
}
switch (GLI_BIG_GLOBALS -> lClippingModeMask & (GLI_C_CutMaskYMin | GLI_C_CutMaskYMax ))
{
case 0:break;
case GLI_C_CutMaskYMin + GLI_C_CutMaskYMax:GLI_M_AddFunc(GLI_YMinCLipping);
ulFuncMask |= Flag_GLI_YMinCLipping;
/* STM - fallthrough - was already here*/
case GLI_C_CutMaskYMax:GLI_M_AddFunc(GLI_YMaxCLipping);
ulFuncMask |= Flag_GLI_YMaxCLipping;
break;
case GLI_C_CutMaskYMin:GLI_M_AddFunc(GLI_YMinCLipping);
ulFuncMask |= Flag_GLI_YMinCLipping;
break;
}
}
/* ------------------------------------------------------------------------------------*/
/* COMPUTE COLOR & UVW INIT;*/
/* ------------------------------------------------------------------------------------*/
if (p_stGlobaleMT-> p_stCurrentTexture != NULL)
{
/*
if (GLI_BIG_GLOBALS->lAMirrorIsDetected & 2)
{
GLI_M_AddFunc(GLI_vComputeMirrorUVW);
ulFuncMask |= Flag_GLI_vComputeMirrorUVW;
}
else
*/
{
if ( p_stGlobaleMT->p_stCurrentTexture->lIncrementIsEnable )
{
fAddU = p_stGlobaleMT-> p_stCurrentTexture -> fAddU;
fAddV = p_stGlobaleMT-> p_stCurrentTexture -> fAddV;
if ((fAddU != 0.0f) || (fAddV != 0.0f))
{
GLI_M_AddFunc(GLI_vComputeMovingUVW);
ulFuncMask |= Flag_GLI_vComputeMovingUVW;
}
else
{
GLI_M_AddFunc(GLI_vComputeNormalUVW);
ulFuncMask |= Flag_GLI_vComputeNormalUVW;
}
}
else
{
GLI_M_AddFunc(GLI_vComputeNormalUVW);
ulFuncMask |= Flag_GLI_vComputeNormalUVW;
}
}
/* ------------------------------------------------------------------------------------*/
/* special function for mirror texture*/
/* ------------------------------------------------------------------------------------*/
if (p_stGlobaleMT->p_stCurrentTexture->ucCylingMode & GLI_C_lMirrorU )
GLI_M_AddFunc(GLI_vAlignUForMirrorTexture);
if (p_stGlobaleMT->p_stCurrentTexture->ucCylingMode & GLI_C_lMirrorV )
GLI_M_AddFunc(GLI_vAlignVForMirrorTexture);
};
/* ------------------------------------------------------------------------------------*/
/* Draw Triangle Func init*/
/* ------------------------------------------------------------------------------------*/
GLI_vAddDrawFunc();
/* ------------------------------------------------------------------------------------*/
/* Add empty func */
/* ------------------------------------------------------------------------------------*/
GLI_M_AddFunc( GLI_fn_LastFunc );
/* ------------------------------------------------------------------------------------*/
/* GO */
/* ------------------------------------------------------------------------------------*/
GLI_BeforeDraw();
{
p_stCurrentTriangle = p_stLocalElementIndexedTriangle -> d_stListOfFacesTripled;
p_stCurrentTriangleUV = p_stLocalElementIndexedTriangle -> d_stListOfFacesTripledIndexUV;
xTriangleCounter = p_stLocalElementIndexedTriangle -> xNbFaces;
/*{
/*
if (xTriangleCounter == 24)
{
if ( (GLI_BIG_GLOBALS->p_stCurrentTexture) && (strnicmp(GLI_BIG_GLOBALS->p_stCurrentTexture->a255_cFileName + 28, "petard", 6) == 0) )
{
long lPointIndex;
MTH3D_tdstVector *pstPoint;
float dY, dX, dZ;
pstPoint = GLI_BIG_GLOBALS->p_stObj->d_stListOfPoints + 53;
if (pstPoint->xY < -.5)
{
lPointIndex = 12;
while (lPointIndex--);
{
dX = 0.005 * pstPoint->xX / (pstPoint->xY + 0.1);
pstPoint->xX -= dX;
dZ = 0.005 * (pstPoint->xZ - 0.1) / (pstPoint->xY + 0.1);
pstPoint->xZ-= dZ;
pstPoint->xY += 0.005;
pstPoint++;
}
}
}
}
}
*/
/* if (ulFuncMask == MaskBigFunc1)*/
/* BigFunc1(xTriangleCounter);*/
/* else */
{
/* normal */
while ( xTriangleCounter -- )
{
#if !defined(PRESS_DEMO)
PRF_MDRV_vSetIndependantVariable( PRF_C_ulIdpDisplayedTriangle , 0 );
#endif /* PRESS_DEMO */
GLI_M_CallFirstFunc();
#if !defined(PRESS_DEMO)
if( PRF_MDRV_lGetIndependantVariable( PRF_C_ulIdpDisplayedTriangle ) )
{
PRF_MDRV_vIncreaseVariable( PRF_C_ulVarFaces + PRF_MDRV_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvDisplayed, 1 );
PRF_MDRV_vSetIndependantVariable( PRF_C_ulIdpDisplayedFaces, 1 );
}
#endif /* PRESS_DEMO */
p_stCurrentTriangle ++;
p_stCurrentTriangleUV ++;
}
}
}
GLI_AfterDraw();
#ifdef SGL2
GLI_BIG_GLOBALS->lAMirrorIsDetected = AMirrorIsDetectedSave ;
#endif
}
/**********************************************************************************************/
/* Name: GLI_DRV_xSendSpriteToClip_TRIANGLES*/
/* Goal: Clip a sprite and draw it*/
/* Code: Vincent Lhullier*/
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void GLI_DRV_xSendSpriteToClip_TRIANGLES( GLI_tdstAligned2DVector *a4_st2DVertex, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
ACP_tdst2DUVValues stUV[3];
GEO_tdstTripledIndex stTriangle[2] = { {0,1,2}, {3,2,0} };
p_stGlobaleMT->lCurrentDrawMask |= GLI_C_lIsGouraud;
GLI_M_ClearFuncList();
/* -----------------------------------------------------------------------------------*/
/* Fog effect*/
/* ------------------------------------------------------------------------------------*/
if (GLI_BIG_GLOBALS->xFogIsOn)
GLI_M_AddFunc(GLI_vSetSpecular);
/* -----------------------------------------------------------------------------------*/
/* First CullingZ */
/* ------------------------------------------------------------------------------------*/
GLI_M_AddFunc(GLI_FastZCull);
GLI_M_AddFunc(GLI_bCullingXYALL);
GLI_M_AddFunc(GLI_vZClipping);
GLI_M_AddFunc(GLI_XMaxCLipping);
GLI_M_AddFunc(GLI_XMinCLipping);
GLI_M_AddFunc(GLI_YMaxCLipping);
GLI_M_AddFunc(GLI_YMinCLipping);
GLI_M_AddFunc(GLI_vComputeNormalUVW);
/* ------------------------------------------------------------------------------------*/
/* Draw Triangle Func init*/
/* ------------------------------------------------------------------------------------*/
GLI_vAddDrawFunc();
/* ------------------------------------------------------------------------------------*/
/* Add empty func */
/* ------------------------------------------------------------------------------------*/
GLI_M_AddFunc( GLI_fn_LastFunc );
/* ------------------------------------------------------------------------------------*/
/* GO */
/* ------------------------------------------------------------------------------------*/
GLI_BeforeDraw();
{
SetX( CurrentDestXYZ[0], a4_st2DVertex[0].xX );
SetY( CurrentDestXYZ[0], a4_st2DVertex[0].xY );
SetZ( CurrentDestXYZ[0], a4_st2DVertex[0].xOoZ );
SetX( CurrentDestXYZ[1], a4_st2DVertex[1].xX );
SetY( CurrentDestXYZ[1], a4_st2DVertex[1].xY );
SetZ( CurrentDestXYZ[1], a4_st2DVertex[1].xOoZ );
SetX( CurrentDestXYZ[2], a4_st2DVertex[2].xX );
SetY( CurrentDestXYZ[2], a4_st2DVertex[2].xY );
SetZ( CurrentDestXYZ[2], a4_st2DVertex[2].xOoZ );
/*
{
char cCounter;
for ( cCounter = 0; cCounter < 4; cCounter++ )
if ( (a4_st2DVertex[cCounter].xOoZ <= 0) || (a4_st2DVertex[cCounter].xOoZ > 4) )
break;
}
*/
SetPackedColor( CurrentDestXYZ[0], p_stGlobaleMT->ulColorInitForSprite );
SetPackedColor( CurrentDestXYZ[1], p_stGlobaleMT->ulColorInitForSprite );
SetPackedColor( CurrentDestXYZ[2], p_stGlobaleMT->ulColorInitForSprite );
d_stVirtualUV[0] = &stUV[0];
d_stVirtualUV[1] = &stUV[1];
d_stVirtualUV[2] = &stUV[2];
stUV[0].xU = 1.0f;
stUV[0].xV = 1.0f;
stUV[1].xU = 0.0f;
stUV[1].xV = 1.0f;
stUV[2].xU = 0.0f;
stUV[2].xV = 0.0f;
p_stCurrentTriangle = stTriangle;
GLI_M_CallFirstFunc();
SetX( CurrentDestXYZ[0], a4_st2DVertex[3].xX);
SetY( CurrentDestXYZ[0], a4_st2DVertex[3].xY);
SetZ( CurrentDestXYZ[0], a4_st2DVertex[3].xOoZ);
SetX( CurrentDestXYZ[1], a4_st2DVertex[2].xX);
SetY( CurrentDestXYZ[1], a4_st2DVertex[2].xY);
SetZ( CurrentDestXYZ[1], a4_st2DVertex[2].xOoZ);
SetX( CurrentDestXYZ[2], a4_st2DVertex[0].xX);
SetY( CurrentDestXYZ[2], a4_st2DVertex[0].xY);
SetZ( CurrentDestXYZ[2], a4_st2DVertex[0].xOoZ);
SetPackedColor( CurrentDestXYZ[0], p_stGlobaleMT->ulColorInitForSprite );
SetPackedColor( CurrentDestXYZ[1], p_stGlobaleMT->ulColorInitForSprite );
SetPackedColor( CurrentDestXYZ[2], p_stGlobaleMT->ulColorInitForSprite );
d_stVirtualUV[0] = &stUV[0];
d_stVirtualUV[1] = &stUV[1];
d_stVirtualUV[2] = &stUV[2];
stUV[0].xU = 1.0f;
stUV[0].xV = 0.0f;
stUV[1].xU = 0.0f;
stUV[1].xV = 0.0f;
stUV[2].xU = 1.0f;
stUV[2].xV = 1.0f;
p_stCurrentTriangle++;
GLI_M_CallFirstFunc();
}
GLI_AfterDraw();
}
/* Only used for tests (infodesign research), because this is definitly NOT optimized. */
void GLI_DRV_xSendSingleTriangleToClip_TRIANGLES( GLI_tdstAligned2DVector *a3_st2DVertex, ACP_tdst2DUVValues *a3_stUV, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GEO_tdstTripledIndex stTriangle = {0,1,2};
p_stGlobaleMT->lCurrentDrawMask |= GLI_C_lIsGouraud;
GLI_M_ClearFuncList();
/* -----------------------------------------------------------------------------------*/
/* Fog effect*/
/* ------------------------------------------------------------------------------------*/
if (GLI_BIG_GLOBALS->xFogIsOn)
GLI_M_AddFunc(GLI_vSetSpecular);
/* -----------------------------------------------------------------------------------*/
/* First CullingZ */
/* ------------------------------------------------------------------------------------*/
GLI_M_AddFunc(GLI_FastZCull);
GLI_M_AddFunc(GLI_bCullingXYALL);
GLI_M_AddFunc(GLI_vZClipping);
GLI_M_AddFunc(GLI_XMaxCLipping);
GLI_M_AddFunc(GLI_XMinCLipping);
GLI_M_AddFunc(GLI_YMaxCLipping);
GLI_M_AddFunc(GLI_YMinCLipping);
GLI_M_AddFunc(GLI_vComputeNormalUVW);
/* ------------------------------------------------------------------------------------*/
/* Draw Triangle Func init*/
/* ------------------------------------------------------------------------------------*/
GLI_vAddDrawFunc();
/* ------------------------------------------------------------------------------------*/
/* Add empty func */
/* ------------------------------------------------------------------------------------*/
GLI_M_AddFunc( GLI_fn_LastFunc );
/* ------------------------------------------------------------------------------------*/
/* GO */
/* ------------------------------------------------------------------------------------*/
GLI_BeforeDraw();
{
SetX( CurrentDestXYZ[0], a3_st2DVertex[0].xX );
SetY( CurrentDestXYZ[0], a3_st2DVertex[0].xY );
SetZ( CurrentDestXYZ[0], a3_st2DVertex[0].xOoZ );
SetX( CurrentDestXYZ[1], a3_st2DVertex[1].xX );
SetY( CurrentDestXYZ[1], a3_st2DVertex[1].xY );
SetZ( CurrentDestXYZ[1], a3_st2DVertex[1].xOoZ );
SetX( CurrentDestXYZ[2], a3_st2DVertex[2].xX );
SetY( CurrentDestXYZ[2], a3_st2DVertex[2].xY );
SetZ( CurrentDestXYZ[2], a3_st2DVertex[2].xOoZ );
SetPackedColor( CurrentDestXYZ[0], 0xffffffff );
SetPackedColor( CurrentDestXYZ[1], 0xffffffff );
SetPackedColor( CurrentDestXYZ[2], 0xffffffff );
d_stVirtualUV[0] = &a3_stUV[0];
d_stVirtualUV[1] = &a3_stUV[1];
d_stVirtualUV[2] = &a3_stUV[2];
p_stCurrentTriangle = &stTriangle;
GLI_M_CallFirstFunc();
}
GLI_AfterDraw();
}
/**********************************************************************************************/
/* Name: GLI_lCullListOfPoints*/
/* Goal: return 0 if it's sure that this list is invisible*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
long GLI_lCullListOfPoints (GLD_tdstViewportAttributes *p_stVpt,long lNbPoints,GLI_tdstAligned2DVector *p_st2DVertex)
{
long CullCounter;
GLI_tdstAligned2DVector *p_VertexCmp;
*(float *)&fX_CMP_Optimize = 640.0f;
*(float *)&fY_CMP_Optimize = 480.0f;
p_VertexCmp = p_st2DVertex;
CullCounter = 0;
p_st2DVertex[8].xX = 320.0f;
while ((p_VertexCmp++) -> xX < 0) CullCounter++;
if (CullCounter == 8) return 0;
p_VertexCmp = p_st2DVertex;
CullCounter = 0;
while (*(long *)&(p_VertexCmp++)->xX > fX_CMP_Optimize) CullCounter++;
if (CullCounter == 8) return 0;
p_VertexCmp = p_st2DVertex;
CullCounter = 0;
p_st2DVertex[8].xY = 240.0f;
while ((p_VertexCmp++)->xY < 0) CullCounter++;
if (CullCounter == 8) return 0;
p_VertexCmp = p_st2DVertex;
CullCounter = 0;
while (*(long *)&(p_VertexCmp++)->xY > fY_CMP_Optimize) CullCounter++;
if (CullCounter == 8) return 0;
/* mmmmouais..*/
return (1);
}
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@@ -0,0 +1,292 @@
/**********************************************************************************************/
/* Name: ColorVtx.C*/
/* Goal : compute screen color for all vertices. These functions write the colors*/
/* directly to the device dependent vertices to avoid copies. That's why this*/
/* is in the drivers directory.*/
/* Author: Steve McCalla*/
/**********************************************************************************************/
/**/
/* TODO: Get rid of writes to the packed colors */
/*
Tested with LINT
*/
#include"gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "dllcom.h"
#ifdef __cplusplus
extern "C"
{
#endif
#define GLI_C_fMagicNumber (16384.0f + 8192.0f)
/**********************************************************************************************/
/* Name: GLI_DRV_vColorVertexIndexedNoAlpha*/
/* Goal : compute screen color for all vertices*/
/* Code: Steve McCalla*/
/* OPTIMIZED : Yes - no more branches*/
/**********************************************************************************************/
void
GLI_DRV_vColorVertexIndexedNoAlpha( GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP,
ACP_tdxIndex xNumber,
ACP_tdxIndex *p_ListOfIndexes)
{
unsigned long *p_Baseu32Colors;
GLI_tdScreenVertx *pScrVertex;
unsigned long ulAlpha;
unsigned long ulTmpCol1, ulTmpCol2, ulTmpCol3;
unsigned long ulRed, ulGreen, ulBlue, ulTmpColNew;
GEO_tdstColor stComputedColor,*p_SRCColors;
GEO_tdstColor stTempColor;
ACP_tdxIndex *p_ListOfIndexesLast;
/* use a temp so we don't have to subtract at the end*/
stTempColor.xR = p_stGP->GLI_stColorsAdd.xR + GLI_C_fMagicNumber;
stTempColor.xG = p_stGP->GLI_stColorsAdd.xG + GLI_C_fMagicNumber;
stTempColor.xB = p_stGP->GLI_stColorsAdd.xB + GLI_C_fMagicNumber;
stTempColor.xA = p_stGP->GLI_stColorsAdd.xA + GLI_C_fMagicNumber;
p_ListOfIndexesLast = p_ListOfIndexes + xNumber;
ulTmpCol1 = (~(*((unsigned long *)&stTempColor.xA) & 0x80000000)) & 0x00000001;
ulTmpCol2 = (*((unsigned long *)&stTempColor.xA) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stTempColor.xA) & 0x000000FF);
ulAlpha = ulTmpCol1 * (ulTmpCol2 | ulTmpCol3);
while (p_ListOfIndexes < p_ListOfIndexesLast)
{
p_Baseu32Colors = &(p_stGP->GLI_ScreenPoint + *p_ListOfIndexes)->ulPackedColor;
pScrVertex = GLI_ScreenVertices + *p_ListOfIndexes;
p_SRCColors = p_stGP -> GLI_aDEF_stColorsRLID + *(p_ListOfIndexes++);
stComputedColor.xR = p_SRCColors->xR * p_stGP->GLI_stColorsMul.xR + stTempColor.xR ;
stComputedColor.xG = p_SRCColors->xG * p_stGP->GLI_stColorsMul.xG + stTempColor.xG ;
stComputedColor.xB = p_SRCColors->xB * p_stGP->GLI_stColorsMul.xB + stTempColor.xB ;
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xR) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xR) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xR) & 0x000000FF);
ulRed = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xG) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xG) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xG) & 0x000000FF);
ulGreen = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xB) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xB) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xB) & 0x000000FF);
ulBlue = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpColNew = 0x000000ff; /*(ulAlpha<<24) | (ulRed<<16) | (ulGreen<<8) | ulBlue;*/
PSetRGBA(pScrVertex, ulRed, ulGreen, ulBlue, ulAlpha);
*p_Baseu32Colors = ulTmpColNew;
}
}
/**********************************************************************************************/
/* Name: GLI_DRV_vColorVertexNoAlpha*/
/* Goal : compute screen color for all vertices*/
/* Code: Steve McCalla*/
/* OPTIMIZED : Yes*/
/**********************************************************************************************/
void
GLI_DRV_vColorVertexNoAlpha(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP,
ACP_tdxIndex xNumber)
{
GLI_tdstAligned2DVector *p_Baseu32Colors;
GLI_tdScreenVertx *pScrVertex;
GEO_tdstColor stComputedColor,*p_SRCColors;
GEO_tdstColor stTempColor;
unsigned long ulTmpCol1, ulTmpCol2, ulTmpCol3;
unsigned long ulRed, ulGreen, ulBlue, ulTmpColNew;
unsigned long ulAlpha;
stTempColor.xR = p_stGP->GLI_stColorsAdd.xR + GLI_C_fMagicNumber;
stTempColor.xG = p_stGP->GLI_stColorsAdd.xG + GLI_C_fMagicNumber;
stTempColor.xB = p_stGP->GLI_stColorsAdd.xB + GLI_C_fMagicNumber;
stTempColor.xA = p_stGP->GLI_stColorsAdd.xA + GLI_C_fMagicNumber;
p_Baseu32Colors = p_stGP->GLI_ScreenPoint;
p_SRCColors = p_stGP -> GLI_aDEF_stColorsRLID;
pScrVertex = GLI_ScreenVertices;
ulAlpha = 0;
ulTmpCol1 = (~(*((unsigned long *)&stTempColor.xA) & 0x80000000)) & 0x00000001;
ulTmpCol2 = (*((unsigned long *)&stTempColor.xA) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stTempColor.xA) & 0x000000FF);
ulAlpha = ulTmpCol1 * (ulTmpCol2 | ulTmpCol3);
while (xNumber--)
{
stComputedColor.xR = p_SRCColors->xR * p_stGP->GLI_stColorsMul.xR + stTempColor.xR ;
stComputedColor.xG = p_SRCColors->xG * p_stGP->GLI_stColorsMul.xG + stTempColor.xG ;
stComputedColor.xB = p_SRCColors->xB * p_stGP->GLI_stColorsMul.xB + stTempColor.xB ;
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xR) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xR) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xR) & 0x000000FF);
ulRed = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xG) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xG) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xG) & 0x000000FF);
ulGreen = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xB) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xB) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xB) & 0x000000FF);
ulBlue = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpColNew = 0x000000ff; /*(ulAlpha<<24) | (ulRed<<16) | (ulGreen<<8) | ulBlue;*/
p_Baseu32Colors->ulPackedColor = ulTmpColNew;
PSetRGBA(pScrVertex, ulRed, ulGreen, ulBlue, ulAlpha);
pScrVertex++;
p_Baseu32Colors++;
p_SRCColors++;
}
}
/**********************************************************************************************/
/* Name: GLI_DRV_vColorVertexIndexedAlpha*/
/* Goal : compute screen color for all vertex when Light is alpha sensitive*/
/* Code: Steve McCalla*/
/* OPTIMIZED : Yes*/
/**********************************************************************************************/
void
GLI_DRV_vColorVertexIndexedAlpha( GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP,
ACP_tdxIndex xNumber,
ACP_tdxIndex *p_ListOfIndexes)
{
GEO_tdstColor stComputedColor;
GEO_tdstColor stTempColor;
GLI_tdScreenVertx *pScrVertex;
unsigned long *p_Baseu32Colors;
unsigned long ulTmpCol1, ulTmpCol2, ulTmpCol3;
unsigned long ulAlpha, ulRed, ulGreen, ulBlue, ulTmpColNew;
stTempColor.xR = p_stGP->GLI_stColorsAdd.xR + GLI_C_fMagicNumber;
stTempColor.xG = p_stGP->GLI_stColorsAdd.xG + GLI_C_fMagicNumber;
stTempColor.xB = p_stGP->GLI_stColorsAdd.xB + GLI_C_fMagicNumber;
stTempColor.xA = p_stGP->GLI_stColorsAdd.xA + GLI_C_fMagicNumber;
while (xNumber--) {
p_Baseu32Colors = &(p_stGP->GLI_ScreenPoint + *p_ListOfIndexes)->ulPackedColor;
pScrVertex = GLI_ScreenVertices + *p_ListOfIndexes;
stComputedColor.xR = (p_stGP -> GLI_aDEF_stColorsRLID + (*p_ListOfIndexes)) -> xR * p_stGP -> GLI_stColorsMul . xR + stTempColor.xR;
stComputedColor.xG = (p_stGP -> GLI_aDEF_stColorsRLID + (*p_ListOfIndexes)) -> xG * p_stGP -> GLI_stColorsMul . xG + stTempColor.xG ;
stComputedColor.xB = (p_stGP -> GLI_aDEF_stColorsRLID + (*p_ListOfIndexes)) -> xB * p_stGP -> GLI_stColorsMul . xB + stTempColor.xB;
stComputedColor.xA = (p_stGP -> GLI_aDEF_stColorsRLID + (*p_ListOfIndexes)) -> xA * p_stGP -> GLI_stColorsMul . xA + stTempColor.xA ;
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xA) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xA) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xA) & 0x000000FF);
ulAlpha = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xR) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xR) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xR) & 0x000000FF);
ulRed = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xG) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xG) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xG) & 0x000000FF);
ulGreen = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xB) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xB) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xB) & 0x000000FF);
ulBlue = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpColNew = 0x000000ff; /* (ulAlpha<<24) | (ulRed<<16) | (ulGreen<<8) | ulBlue;*/
PSetRGBA(pScrVertex, ulRed, ulGreen, ulBlue, ulAlpha);
*p_Baseu32Colors = ulTmpColNew;
p_ListOfIndexes++;
}
}
/**********************************************************************************************/
/* Name: GLI_DRV_vColorVertexAlpha */
/* Goal : compute screen color for all vertices*/
/* Code: Steve McCalla*/
/* OPTIMIZED : Yes*/
/**********************************************************************************************/
void
GLI_DRV_vColorVertexAlpha ( GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP,
ACP_tdxIndex xNumber)
{
GLI_tdstAligned2DVector *p_Baseu32Colors;
GLI_tdScreenVertx *pScrVertex;
GEO_tdstColor stComputedColor,*p_SRCColors;
GEO_tdstColor stTempColor;
unsigned long ulTmpCol1, ulTmpCol2, ulTmpCol3;
unsigned long ulAlpha, ulRed, ulGreen, ulBlue;
unsigned long ulTmpColNew;
stTempColor.xR = p_stGP->GLI_stColorsAdd.xR + GLI_C_fMagicNumber;
stTempColor.xG = p_stGP->GLI_stColorsAdd.xG + GLI_C_fMagicNumber;
stTempColor.xB = p_stGP->GLI_stColorsAdd.xB + GLI_C_fMagicNumber;
stTempColor.xA = p_stGP->GLI_stColorsAdd.xA + GLI_C_fMagicNumber;
p_Baseu32Colors = p_stGP->GLI_ScreenPoint;
p_SRCColors = p_stGP->GLI_aDEF_stColorsRLID;
pScrVertex = GLI_ScreenVertices;
while (xNumber--)
{
stComputedColor.xR = p_SRCColors->xR * p_stGP->GLI_stColorsMul.xR + stTempColor.xR;
stComputedColor.xG = p_SRCColors->xG * p_stGP->GLI_stColorsMul.xG + stTempColor.xG;
stComputedColor.xB = p_SRCColors->xB * p_stGP->GLI_stColorsMul.xB + stTempColor.xB;
stComputedColor.xA = p_SRCColors->xA * p_stGP->GLI_stColorsMul.xA + stTempColor.xA;
ulTmpCol1 = (~(*((unsigned long *)&stTempColor.xA) & 0x80000000)) & 0x00000001;
ulTmpCol2 = (*((unsigned long *)&stTempColor.xA) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stTempColor.xA) & 0x000000FF);
ulAlpha = ulTmpCol1 * (ulTmpCol2 | ulTmpCol3);
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xR) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xR) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xR) & 0x000000FF);
ulRed = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xG) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xG) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xG) & 0x000000FF);
ulGreen = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpCol1 = (*((unsigned long *)&stComputedColor.xB) & 0x00400000);
ulTmpCol2 = (*((unsigned long *)&stComputedColor.xB) & 0x0000FF00) ? 0x000000ff: 0x00000000;
ulTmpCol3 = (*((unsigned long *)&stComputedColor.xB) & 0x000000FF);
ulBlue = (ulTmpCol1 >> 22) * (ulTmpCol2 | ulTmpCol3);
ulTmpColNew = (ulAlpha<<24) | (ulRed<<16) | (ulGreen<<8) | ulBlue;
p_Baseu32Colors->ulPackedColor = 0x000000ff; /* ulTmpColNew;*/
PSetRGBA(pScrVertex, ulRed, ulGreen, ulBlue, ulAlpha);
pScrVertex++;
p_Baseu32Colors++;
p_SRCColors++;
}
}
#ifdef __cplusplus
}/* extern "C" */
#endif

View File

@@ -0,0 +1,221 @@
# Microsoft Developer Studio Project File - Name="DirectX6" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=DirectX6 - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "DirectX6.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "DirectX6.mak" CFG="DirectX6 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "DirectX6 - Win32 Release" (based on\
"Win32 (x86) Dynamic-Link Library")
!MESSAGE "DirectX6 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "DirectX6 - Win32 Retail" (based on\
"Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""$/cpa/tempgrp/GliGlou/Drivers/DirectX6", WUPAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "DirectX6 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "temp\Release"
# PROP Intermediate_Dir "temp\Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "t:\mssdk\include" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /D "NDEBUG" /D "_WINDOWS" /D "USE_PROFILER" /D "WIN32" /D "GLI_DIRECTX6" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"x:\cpa\exe\main\dll\GliDX6vr.dll"
!ELSEIF "$(CFG)" == "DirectX6 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "temp\Debug"
# PROP Intermediate_Dir "temp\Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "t:\mssdk\include" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /D "_DEBUG" /D "VISUAL" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /D "WIN32" /D "GLI_DIRECTX6" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"x:\cpa\exe\main\dll\GliDX6vd.dll" /pdbtype:sept
!ELSEIF "$(CFG)" == "DirectX6 - Win32 Retail"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "DirectX6__"
# PROP BASE Intermediate_Dir "DirectX6__"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Temp\Retail"
# PROP Intermediate_Dir "Temp\Retail"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /I "t:\mssdk\include" /D "NDEBUG" /D "_WINDOWS" /D "RETAIL" /D "WIN32" /D "GLI_DIRECTX6" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"x:\cpa\exe\main\dll\GliDX6vf.dll"
!ENDIF
# Begin Target
# Name "DirectX6 - Win32 Release"
# Name "DirectX6 - Win32 Debug"
# Name "DirectX6 - Win32 Retail"
# Begin Group "Src"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Acces_ALL.c
!IF "$(CFG)" == "DirectX6 - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "DirectX6 - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "DirectX6 - Win32 Retail"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\ClipTRIANGLES.c
# End Source File
# Begin Source File
SOURCE=..\DllCom.c
# End Source File
# Begin Source File
SOURCE=.\Src\DX6_Acces.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\Src\DX6_Caps.c
# End Source File
# Begin Source File
SOURCE=.\Src\DX6_Choose.c
# End Source File
# Begin Source File
SOURCE=.\Src\DX6_Dll.c
# End Source File
# Begin Source File
SOURCE=.\Src\DX6_Domat.c
# End Source File
# Begin Source File
SOURCE=.\Src\DX6_HdwTx.c
# End Source File
# Begin Source File
SOURCE=.\Src\DX6_Init.c
# End Source File
# Begin Source File
SOURCE=..\GliDLL.def
# End Source File
# End Group
# Begin Group "inc"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\DllCom.h
# End Source File
# Begin Source File
SOURCE=.\inc\DX6_Caps.h
# End Source File
# Begin Source File
SOURCE=.\inc\DX6_Choose.h
# End Source File
# Begin Source File
SOURCE=.\inc\MacroD3D.h
# End Source File
# Begin Source File
SOURCE=.\inc\TextuD3D.h
# End Source File
# End Group
# Begin Group "lib"
# PROP Default_Filter ""
# Begin Source File
SOURCE=T:\mssdk\lib\ddraw.lib
# End Source File
# End Group
# Begin Source File
SOURCE=.\DirectX6.mak
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectX6", "DirectX6.vcproj", "{0F794DE0-9589-4116-8D57-08C979511B61}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SourceCodeControl) = preSolution
SccNumberOfProjects = 1
SccProjectUniqueName0 = DirectX6.vcproj
SccProjectName0 = \u0022$/cpa/tempgrp/GliGlou/Drivers/DirectX6\u0022,\u0020WUPAAAAA
SccLocalPath0 = .
SccProvider0 = MSSCCI:NXN\u0020alienbrain
EndGlobalSection
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
Retail = Retail
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{0F794DE0-9589-4116-8D57-08C979511B61}.Debug.ActiveCfg = Debug|Win32
{0F794DE0-9589-4116-8D57-08C979511B61}.Debug.Build.0 = Debug|Win32
{0F794DE0-9589-4116-8D57-08C979511B61}.Release.ActiveCfg = Release|Win32
{0F794DE0-9589-4116-8D57-08C979511B61}.Release.Build.0 = Release|Win32
{0F794DE0-9589-4116-8D57-08C979511B61}.Retail.ActiveCfg = Retail|Win32
{0F794DE0-9589-4116-8D57-08C979511B61}.Retail.Build.0 = Retail|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,528 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="DirectX6"
ProjectGUID="{0F794DE0-9589-4116-8D57-08C979511B61}"
RootNamespace="DirectX6"
SccProjectName="&quot;$/cpa/tempgrp/GliGlou/Drivers/DirectX6&quot;, WUPAAAAA"
SccAuxPath=""
SccLocalPath="."
SccProvider="MSSCCI:Microsoft Visual SourceSafe">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\temp\Debug"
IntermediateDirectory=".\temp\Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="t:\3dFX\GLIDE\SRC\SST1\INCLUDE,t:\mssdk\include,x:\cpa\public,x:\cpa\public\gli,x:\cpa\public\geo,inc,x:\cpa\tempgrp\gliglou\multidrv\inc,..\"
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;WIN32;GLI_DIRECTX6"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\temp\Debug/DirectX6.pch"
AssemblerListingLocation=".\temp\Debug/"
ObjectFile=".\temp\Debug/"
ProgramDataBaseFileName=".\temp\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ddraw.lib"
OutputFile="x:\cpa\exe\main\dll\GliDX6vd.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile="..\GliDLL.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\temp\Debug/GliDX6vd.pdb"
SubSystem="2"
ImportLibrary=".\temp\Debug/GliDX6vd.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\temp\Debug/DirectX6.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Retail|Win32"
OutputDirectory=".\Temp\Retail"
IntermediateDirectory=".\Temp\Retail"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="t:\3dFX\GLIDE\SRC\SST1\INCLUDE,x:\cpa\public,x:\cpa\public\gli,x:\cpa\public\geo,inc,x:\cpa\tempgrp\gliglou\multidrv\inc,..\,t:\mssdk\include"
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;WIN32;GLI_DIRECTX6"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Temp\Retail/DirectX6.pch"
AssemblerListingLocation=".\Temp\Retail/"
ObjectFile=".\Temp\Retail/"
ProgramDataBaseFileName=".\Temp\Retail/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="x:\cpa\exe\main\dll\GliDX6vf.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile="..\GliDLL.def"
ProgramDatabaseFile=".\Temp\Retail/GliDX6vf.pdb"
SubSystem="2"
ImportLibrary=".\Temp\Retail/GliDX6vf.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Temp\Retail/DirectX6.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\temp\Release"
IntermediateDirectory=".\temp\Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="t:\3dFX\GLIDE\SRC\SST1\INCLUDE,t:\mssdk\include,x:\cpa\public,x:\cpa\public\gli,x:\cpa\public\geo,inc,x:\cpa\tempgrp\gliglou\multidrv\inc,..\"
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;WIN32;GLI_DIRECTX6"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\temp\Release/DirectX6.pch"
AssemblerListingLocation=".\temp\Release/"
ObjectFile=".\temp\Release/"
ProgramDataBaseFileName=".\temp\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="x:\cpa\exe\main\dll\GliDX6vr.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile="..\GliDLL.def"
ProgramDatabaseFile=".\temp\Release/GliDX6vr.pdb"
SubSystem="2"
ImportLibrary=".\temp\Release/GliDX6vr.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\temp\Release/DirectX6.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Src"
Filter="">
<File
RelativePath="..\Acces_ALL.c">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="..\ClipTRIANGLES.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="..\DllCom.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="Src\DX6_Acces.c">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="Src\DX6_Caps.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="Src\DX6_Choose.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="Src\DX6_Dll.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="Src\DX6_Domat.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="Src\DX6_HdwTx.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="Src\DX6_Init.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;WIN32;GLI_DIRECTX6;$(NoInherit);USE_DX"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;WIN32;GLI_DIRECTX6;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="..\GliDLL.def">
</File>
</Filter>
<Filter
Name="inc"
Filter="">
<File
RelativePath="..\DllCom.h">
</File>
<File
RelativePath="inc\DX6_Caps.h">
</File>
<File
RelativePath="inc\DX6_Choose.h">
</File>
<File
RelativePath="inc\MacroD3D.h">
</File>
<File
RelativePath="inc\TextuD3D.h">
</File>
</Filter>
<Filter
Name="lib"
Filter="">
</Filter>
<File
RelativePath="DirectX6.mak">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,553 @@
#include <d3d.h>
#include <ddraw.h>
/*
=======================================================================================
Vertex Access Macros
=======================================================================================
*/
/* GET*/
#define GetX(a) a.sx
#define GetY(a) a.sy
#define GetZ(a) a.rhw
#define GetPackedColor(a) a.color
#define GetPackedSpecular(a) a.specular
#define GetU(a) a.tu
#define GetV(a) a.tv
/* SET*/
#define SetX(a,b) a.sx = b
#define SetY(a,b) a.sy = b
#define SetZ(a,b) a.sz = a.rhw = b
#define SetPackedColor(a,b) a.color = b
#define SetPackedSpecular(a,b) a.specular = b
#define SetU(a,b) a.tu = b
#define SetV(a,b) a.tv = b
#define SetU_Cpy(a,b) a.tu = b
#define SetV_Cpy(a,b) a.tv = b
/*
=======================================================================================
Globals
=======================================================================================
*/
/*
double fNumberOfTexels = 0;
double fNumberMinOfTexels = 1e30;
double fNumberMaxOfTexels = 0;
*/
/*
* Draw primitive flag
*/
#define GLI_C_dwDPFlag_NoClip D3DDP_DONOTCLIP | D3DDP_DONOTLIGHT
#define GLI_C_dwDPFlag_Clip D3DDP_DONOTLIGHT
DWORD dwDrawPrimitiveFlag = GLI_C_dwDPFlag_NoClip;
/*
* D3D vertex buffer
*/
#define GLI_tdScreenVertx D3DTLVERTEX
GLI_tdScreenVertx ga_stVertexBuffer[ 3000 ];
GLI_tdScreenVertx *CurrentDestXYZ = ga_stVertexBuffer;
/*
=======================================================================================
External
=======================================================================================
*/
extern LPDIRECT3DDEVICE3 g_pd3dDevice;
extern void GLI_DRV_xSendSpriteToClip_TRIANGLES( GLI_tdstAligned2DVector *a4_st2DVertex, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
/*
=======================================================================================
Function & macros
=======================================================================================
*/
#define GLI_M_RestoreCW()
/*
----------------------------------------------------------------------------------------
Description : called before a complex object is drawn
complex object is several faces with same material
----------------------------------------------------------------------------------------
*/
void GLI_BeforeDraw()
{
CurrentDestXYZ = ga_stVertexBuffer;
};
/*
----------------------------------------------------------------------------------------
Description : called after complex object is send
----------------------------------------------------------------------------------------
*/
void GLI_AfterDraw()
{
long lVertexNumber;
if ((lVertexNumber = CurrentDestXYZ - ga_stVertexBuffer) != 0)
{
/* if( FAILED( g_pd3dDevice->lpVtbl->BeginScene(g_pd3dDevice) ) )
return;
*/
/* Draw the triangles*/
g_pd3dDevice->lpVtbl->DrawPrimitive( g_pd3dDevice, D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, ga_stVertexBuffer, lVertexNumber, dwDrawPrimitiveFlag );
/* End the scene.*/
/* g_pd3dDevice->lpVtbl->EndScene(g_pd3dDevice); */
}
/* bench : count texels*/
/*
if ( GLI_BIG_GLOBALS->p_stCurrentTexture != NULL)
{
GLI_tdScreenVertx *p_stCurVertex = ga_stVertexBuffer;
unsigned long ulSizeOfTexture = GLI_BIG_GLOBALS->p_stCurrentTexture->lHeight * GLI_BIG_GLOBALS->p_stCurrentTexture->lWidth / 2;
float fLocalNumberOfTexels, fSizeInPixel;
while (p_stCurVertex != CurrentDestXYZ)
{
fLocalNumberOfTexels = fabs( ( p_stCurVertex[0].tu - p_stCurVertex[1].tu ) * fabs( p_stCurVertex[0].tv - p_stCurVertex[2].tv ) * ulSizeOfTexture);
fSizeInPixel = fabs( ( p_stCurVertex[0].sx - p_stCurVertex[1].sx ) * fabs( p_stCurVertex[0].sy - p_stCurVertex[2].sy ) * 0.5f);
if (fSizeInPixel > fLocalNumberOfTexels)
fLocalNumberOfTexels = fSizeInPixel;
fNumberOfTexels += fLocalNumberOfTexels;
p_stCurVertex += 3;
}
}
*/
};
/*
----------------------------------------------------------------------------------------
Description : Draw single triangle stored in CurrentDestXYZ array
----------------------------------------------------------------------------------------
*/
GLI_FuncNodeBegin(GLI_vDrawTriangle)
{
CurrentDestXYZ += 3;
}
/*
----------------------------------------------------------------------------------------
Description : Add a single triangle in Z sorted list
----------------------------------------------------------------------------------------
*/
GLI_FuncNodeBegin(GLI_vZSortTriangle)
{
float ZMax;
if ((unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint > (unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_TableOfPoints + ((3L << GLI_MaxZListeTrianglesPO2)* sizeof (GLI_tdScreenVertx)) - 3L * sizeof(GLI_tdScreenVertx))
return;
memcpy(GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint , CurrentDestXYZ , sizeof(GLI_tdScreenVertx) * 3L);
if (*(unsigned long *)&GetZ(CurrentDestXYZ[0]) < *(unsigned long *)&GetZ(CurrentDestXYZ[1]))
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[0]);
else
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[1]);
if (*(unsigned long *)&ZMax > *(unsigned long *)&GetZ(CurrentDestXYZ[2]))
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[2]);
GLI_v_AddNodeInZList(ZMax);
(unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint += sizeof(GLI_tdScreenVertx) * 3L;
}
/*
----------------------------------------------------------------------------------------
Description : Add a single triangle in Z sorted list
----------------------------------------------------------------------------------------
*/
GLI_FuncNodeBegin(GLI_vDrawWiredTriangle)
{
/* if( FAILED( g_pd3dDevice->lpVtbl->BeginScene(g_pd3dDevice) ) )
return;
*/
/* Draw the triangle using a DrawPrimitive() call. */
CurrentDestXYZ[3] = CurrentDestXYZ[0];
g_pd3dDevice->lpVtbl->DrawPrimitive( g_pd3dDevice, D3DPT_LINESTRIP, D3DFVF_TLVERTEX, CurrentDestXYZ, 4, GLI_C_dwDPFlag_Clip );
/* End the scene.*/
/* g_pd3dDevice->lpVtbl->EndScene(g_pd3dDevice); */
}
/*
----------------------------------------------------------------------------------------
Description : draw a quad stored in CurrentDestXYZ array or add it in Z list
1-----0
| /| Send two triangle : 0 1 2 and 3 2 0
| / |
|/ |
2-----3
----------------------------------------------------------------------------------------
*/
void GLI_DrawQuad(void)
{
/* draw 2 triangles */
/*
CurrentDestXYZ[0].color = 0xFFFFFFFF;
CurrentDestXYZ[1].color = 0xFFFFFFFF;
CurrentDestXYZ[2].color = 0xFFFFFFFF;
CurrentDestXYZ[3].color = 0xFFFFFFFF;
*/
if ( GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_TrianglesMustBeSorted )
{
GLI_BIG_GLOBALS -> lCurrentDrawMask &= ~GLI_C_lIsGouraud;
if ((unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint > (unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_TableOfPoints + ((3L << GLI_MaxZListeTrianglesPO2)* sizeof (GLI_tdScreenVertx)) - 4L * sizeof(GLI_tdScreenVertx))
return;
memcpy(GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint , CurrentDestXYZ , sizeof(GLI_tdScreenVertx) * 4L);
GLI_v_AddNodeInZList(GetZ(CurrentDestXYZ[0]));
(unsigned long) GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint += sizeof(GLI_tdScreenVertx) * 4L;
}
else
{
CurrentDestXYZ[4] = CurrentDestXYZ[2];
CurrentDestXYZ[5] = CurrentDestXYZ[0];
CurrentDestXYZ += 6;
}
}
/*
----------------------------------------------------------------------------------------
Description : Draw a line
----------------------------------------------------------------------------------------
*/
void GLI_DrawLine(void)
{
/* if( FAILED( g_pd3dDevice->lpVtbl->BeginScene(g_pd3dDevice) ) )
return;
*/
/* Draw the triangle using a DrawPrimitive() call. */
g_pd3dDevice->lpVtbl->DrawPrimitive( g_pd3dDevice, D3DPT_LINELIST, D3DFVF_TLVERTEX, CurrentDestXYZ, 2, GLI_C_dwDPFlag_Clip );
//g_pd3dDevice->lpVtbl->DrawPrimitive( g_pd3dDevice, D3DPT_LINELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, CurrentDestXYZ, 2, GLI_C_dwDPFlag_Clip );
/* End the scene.*/
/* g_pd3dDevice->lpVtbl->EndScene(g_pd3dDevice); */
}
/*
----------------------------------------------------------------------------------------
Description : draw Zsorted triangle
----------------------------------------------------------------------------------------
*/
void GLI_vDrawZSortedTriangle(void *p_3Point)
{
memcpy( CurrentDestXYZ, p_3Point, 3 * sizeof(GLI_tdScreenVertx) );
CurrentDestXYZ += 3;
}
/*
----------------------------------------------------------------------------------------
Description : draw ZSorted quad
----------------------------------------------------------------------------------------
*/
void GLI_vDrawZSortedQuad(void *p_3Point)
{
memcpy( CurrentDestXYZ, p_3Point, 4 * sizeof(GLI_tdScreenVertx) );
CurrentDestXYZ[4] = *((GLI_tdScreenVertx *) p_3Point + 2);
CurrentDestXYZ[5] = *((GLI_tdScreenVertx *) p_3Point);
CurrentDestXYZ += 6;
}
/*
----------------------------------------------------------------------------------------
Description : choose good drawing function
----------------------------------------------------------------------------------------
*/
void GLI_vAddDrawFunc()
{
if (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_TrianglesMustBeSorted)
{
GLI_M_AddFunc(GLI_vZSortTriangle);
}
#ifdef _DEBUG
else if ( (GLI_BIG_GLOBALS->lCurrentDrawMask & GLI_C_lIsNotWired) == 0 )
{
GLI_M_AddFunc(GLI_vDrawWiredTriangle);
}
#endif
else
{
GLI_M_AddFunc(GLI_vDrawTriangle);
}
}
/*
----------------------------------------------------------------------------------------
Description : compute clipping mask
----------------------------------------------------------------------------------------
*/
void GLI_ReComputeClippingMask()
{
*(float *)&fX_CMP_Optimize = GLI_BIG_GLOBALS->fXMaxClipping;
*(float *)&fY_CMP_Optimize = GLI_BIG_GLOBALS->fYMaxClipping;
*(float *)&fXMin_CLIP_Optimize = GLI_BIG_GLOBALS->fXMinClipping;
*(float *)&fYMin_CLIP_Optimize = GLI_BIG_GLOBALS->fYMinClipping;
*(float *)&fXMax_CLIP_Optimize = GLI_BIG_GLOBALS->fXMaxClipping;
*(float *)&fYMax_CLIP_Optimize = GLI_BIG_GLOBALS->fYMaxClipping;
GLI_BIG_GLOBALS->lClippingModeMask |= (GLI_BIG_GLOBALS->lClippingModeMask & GLI_C_lCLIP_ALL) << 4;
/*
if (GLI_BIG_GLOBALS->lClippingModeMask & GLI_C_lCLIP_ALL == 0)
{
dwDrawPrimitiveFlag = GLI_C_dwDPFlag_NoClip;
}
else
{
dwDrawPrimitiveFlag = GLI_C_dwDPFlag_Clip;
}
*/
}
/*
----------------------------------------------------------------------------------------
Description : clip a sprite
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vSendSpriteToClip
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT
)
{
float fClipYMax, fClipYMin, fClipXMax, fClipXMin;
unsigned long ulColor;
GLI_BeforeDraw();
if (a4_st2DVertex[0].xY == a4_st2DVertex[1].xY) /* Aligned sprite */
{
GLI_ReComputeClippingMask();
if ( ( *(long *) &a4_st2DVertex[0].xY > fYMax_CLIP_Optimize) || (*(long *) &a4_st2DVertex[2].xY < fYMin_CLIP_Optimize) || (*(long *) &a4_st2DVertex[0].xX < fXMin_CLIP_Optimize) || (*(long *) &a4_st2DVertex[1].xX > fXMax_CLIP_Optimize) )
return;
/*
* clip xMax
*/
if ( *(long *) &a4_st2DVertex[0].xX > fXMax_CLIP_Optimize )
{
fClipXMax = (GLI_BIG_GLOBALS->fXMaxClipping - a4_st2DVertex[1].xX) / ( a4_st2DVertex[0].xX - a4_st2DVertex[1].xX );
a4_st2DVertex[0].xX = a4_st2DVertex[3].xX = GLI_BIG_GLOBALS->fXMaxClipping;
}
else
fClipXMax = 1.0f;
/*
* clip xMin
*/
if ( *(long *) &a4_st2DVertex[1].xX < fXMin_CLIP_Optimize )
{
fClipXMin = (fClipXMax * ( GLI_BIG_GLOBALS->fXMinClipping - a4_st2DVertex[1].xX) ) / ( a4_st2DVertex[0].xX - a4_st2DVertex[1].xX );
a4_st2DVertex[1].xX = a4_st2DVertex[2].xX = GLI_BIG_GLOBALS->fXMinClipping;
}
else
fClipXMin = 0.0f;
/*
* clip yMin
*/
if ( *(long *) &a4_st2DVertex[0].xY < fYMin_CLIP_Optimize )
{
fClipYMin = (GLI_BIG_GLOBALS->fYMinClipping - a4_st2DVertex[2].xY) / ( a4_st2DVertex[0].xY - a4_st2DVertex[2].xY );
a4_st2DVertex[0].xY = a4_st2DVertex[1].xY = GLI_BIG_GLOBALS->fYMinClipping;
}
else
fClipYMin = 1.0f;
/*
* clip yMax
*/
if ( *(long *) &a4_st2DVertex[2].xY > fYMax_CLIP_Optimize )
{
fClipYMax = (fClipYMin * ( GLI_BIG_GLOBALS->fYMaxClipping - a4_st2DVertex[2].xY ) ) / ( a4_st2DVertex[0].xY - a4_st2DVertex[2].xY );
a4_st2DVertex[2].xY = a4_st2DVertex[3].xY = GLI_BIG_GLOBALS->fYMaxClipping;
}
else
fClipYMax = 0.0f;
}
else
{
if ( *(long *) &GLI_BIG_GLOBALS->xWaterPlaneDistance != 0 );
{
GLI_DRV_xSendSpriteToClip_TRIANGLES( a4_st2DVertex, p_stGlobaleMT);
return;
}
if ( (a4_st2DVertex [0] . xY < 0.0f) || (a4_st2DVertex [1] . xY < 0.0f) || (a4_st2DVertex [2] . xY < 0.0f) || (a4_st2DVertex [3] . xY < 0.0f) ) return;
if ( (a4_st2DVertex [0] . xX < 0.0f) || (a4_st2DVertex [1] . xX < 0.0f) || (a4_st2DVertex [2] . xX < 0.0f) || (a4_st2DVertex [3] . xX < 0.0f) ) return;
if ( (a4_st2DVertex [0] . xY > 480.0f) || (a4_st2DVertex [1] . xY > 480.0f) || (a4_st2DVertex [2] . xY > 480.0f) || (a4_st2DVertex [3] . xY > 480.0f) ) return;
if ( (a4_st2DVertex [0] . xX > 640.0f) || (a4_st2DVertex [1] . xX > 640.0f) || (a4_st2DVertex [2] . xX > 640.0f) || (a4_st2DVertex [3] . xX > 640.0f) ) return;
fClipXMin = fClipYMax = 0.0f;
fClipYMin = fClipXMax = 1.0f;
}
GLI_M_InitSprite();
ulColor = (p_stGlobaleMT->xTextureDontAcceptFog) ? 0xFF000000 : p_stGlobaleMT->ulSpecularColorForSprite;
SetPackedSpecular( CurrentDestXYZ[0], ulColor );
SetPackedSpecular( CurrentDestXYZ[1], ulColor );
SetPackedSpecular( CurrentDestXYZ[2], ulColor );
SetPackedSpecular( CurrentDestXYZ[3], ulColor );
SetU(CurrentDestXYZ[0], fClipXMax );
SetV(CurrentDestXYZ[0], fClipYMin );
SetU(CurrentDestXYZ[1], fClipXMin );
SetV(CurrentDestXYZ[1], fClipYMin );
SetU(CurrentDestXYZ[2], fClipXMin );
SetV(CurrentDestXYZ[2], fClipYMax );
SetU(CurrentDestXYZ[3], fClipXMax );
SetV(CurrentDestXYZ[3], fClipYMax );
GLI_DrawQuad();
GLI_AfterDraw();
}
/*
----------------------------------------------------------------------------------------
Description : clip a sprite that have UV coordinates (it seems to be unused)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vSendSpriteToClipWithUV
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal *a8_stUVVertex,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
unsigned long ulColor;
GLI_BeforeDraw();
GLI_M_InitSprite();
if (a4_st2DVertex [0] . xY < 0.0f) return;
if (a4_st2DVertex [1] . xY < 0.0f) return;
if (a4_st2DVertex [2] . xY < 0.0f) return;
if (a4_st2DVertex [3] . xY < 0.0f) return;
if (a4_st2DVertex [0] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [1] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [2] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [3] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
ulColor = (p_stGlobaleMT->xTextureDontAcceptFog) ? 0xFF000000 : p_stGlobaleMT->ulSpecularColorForSprite;
SetPackedSpecular( CurrentDestXYZ[0], ulColor );
SetPackedSpecular( CurrentDestXYZ[1], ulColor );
SetPackedSpecular( CurrentDestXYZ[2], ulColor );
SetPackedSpecular( CurrentDestXYZ[3], ulColor );
if ( p_stGlobaleMT->p_stCurrentTexture->lIncrementIsEnable )
{
float fAddU, fAddV;
fAddU = p_stGlobaleMT-> p_stCurrentTexture -> fAddU;
fAddV = p_stGlobaleMT-> p_stCurrentTexture -> fAddV;
SetU(CurrentDestXYZ[2], a8_stUVVertex[4] + fAddU );
SetV(CurrentDestXYZ[2], a8_stUVVertex[4 + 1] + fAddV);
SetU(CurrentDestXYZ[3], a8_stUVVertex[6] + fAddU);
SetV(CurrentDestXYZ[3], a8_stUVVertex[6 + 1] + fAddV);
SetU(CurrentDestXYZ[0], a8_stUVVertex[0] + fAddU);
SetV(CurrentDestXYZ[0], a8_stUVVertex[0 + 1] + fAddV);
SetU(CurrentDestXYZ[1], a8_stUVVertex[2] + fAddU);
SetV(CurrentDestXYZ[1], a8_stUVVertex[2 + 1] + fAddV);
}
else
{
SetU(CurrentDestXYZ[2], a8_stUVVertex[4]);
SetV(CurrentDestXYZ[2], a8_stUVVertex[4 + 1]);
SetU(CurrentDestXYZ[3], a8_stUVVertex[6]);
SetV(CurrentDestXYZ[3], a8_stUVVertex[6 + 1]);
SetU(CurrentDestXYZ[0], a8_stUVVertex[0]);
SetV(CurrentDestXYZ[0], a8_stUVVertex[0 + 1]);
SetU(CurrentDestXYZ[1], a8_stUVVertex[2]);
SetV(CurrentDestXYZ[1], a8_stUVVertex[2 + 1]);
}
GLI_DrawQuad();
GLI_AfterDraw();
}
/*
----------------------------------------------------------------------------------------
Description : clip a line (not implemented)
----------------------------------------------------------------------------------------
*/
#if 0
void GLI_DRV_vSendSingleLineToClip
(
GLD_tdstViewportAttributes *p_stVpt ,
GLI_tdstAligned3DVector *p_stVertex1 ,
GLI_tdstAligned2DVector *p_st2DVertex1 ,
GLI_tdstAligned3DVector *p_stVertex2 ,
GLI_tdstAligned2DVector *p_st2DVertex2 ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT,
long lDrawModeMask, GEO_tdstColor *p_stColor
)
{
p_st2DVertex1->ulPackedColor =0xFFFFFFFF;
p_st2DVertex2->ulPackedColor =0xFFFFFFFF;
GLI_M_InitLine();
GLI_DrawLine();
}
#else
void GLI_DRV_vSendSingleLineToClip
(
GLD_tdstViewportAttributes *p_stVpt ,
GLI_tdstAligned3DVector *p_stVertex1 ,
GLI_tdstAligned2DVector *p_st2DVertex1 ,
GLI_tdstAligned3DVector *p_stVertex2 ,
GLI_tdstAligned2DVector *p_st2DVertex2 ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT,
long lDrawModeMask, GEO_tdstColor *p_stColor
)
{
DWORD dwRenderState;
g_pd3dDevice->lpVtbl->GetRenderState(g_pd3dDevice, D3DRENDERSTATE_ZENABLE,&dwRenderState);
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice, D3DRENDERSTATE_ZENABLE, FALSE);
g_pd3dDevice->lpVtbl->SetTexture(g_pd3dDevice,0, NULL );
SetX(CurrentDestXYZ[0],p_st2DVertex1->xX);
SetY(CurrentDestXYZ[0],p_st2DVertex1->xY);
SetX(CurrentDestXYZ[1],p_st2DVertex2->xX);
SetY(CurrentDestXYZ[1],p_st2DVertex2->xY);
SetZ(CurrentDestXYZ[0],p_st2DVertex1->xOoZ );
SetZ(CurrentDestXYZ[1],p_st2DVertex2->xOoZ );
SetPackedColor(CurrentDestXYZ[0],p_st2DVertex1->ulPackedColor );
SetPackedColor(CurrentDestXYZ[1],p_st2DVertex2->ulPackedColor );
g_pd3dDevice->lpVtbl->DrawPrimitive( g_pd3dDevice, D3DPT_LINELIST, D3DFVF_TLVERTEX, CurrentDestXYZ, 2, GLI_C_dwDPFlag_Clip );
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice, D3DRENDERSTATE_ZENABLE, (BOOL)dwRenderState);
}
#endif

View File

@@ -0,0 +1,738 @@
/*
=======================================================================================
Name : DX6_Caps.c
Author : vincent lhullier Date :30/10/98
Description : capabilities of driver (depend on hardware)
=======================================================================================
*/
#include "DLLCom.h"
#include "DX6_Choose.h"
#include "DX6_Caps.h"
extern LPDIRECTDRAW4 g_pDD4;
extern LPDIRECT3DDEVICE3 g_pd3dDevice;
extern LPDIRECTDRAWSURFACE4 g_pddsPrimary;
/*
=======================================================================================
Globals
=======================================================================================
*/
static long gs_lNumberOfPixelFormats;
static DDPIXELFORMAT gs_a_stD3DPixelFormat[20];
static char gs_a_cPixelFormatIndex[ GLI_DX6_TexNbFormats ];
static long gs_a_lPrecalculatedTextureSize[GLI_DX6_TexNbFormats][2][9][9];
/*
=======================================================================================
private Functions prototypes
=======================================================================================
*/
unsigned char GLI_DX6_fn_ucGetPrimarySurfacePixelFormat( LPDDPIXELFORMAT _p_stDDPF );
/*
=======================================================================================
public Functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : compute video memory
----------------------------------------------------------------------------------------
*/
HRESULT GLI_DX6_hGetVideoMemory( LPDIRECTDRAW4 _pDD4, long _lDDSCaps, unsigned long *_ulTotal, unsigned long *_ulLeft )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
DDSCAPS2 stLocalVideoCaps;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
memset(&stLocalVideoCaps,0,sizeof(stLocalVideoCaps));
stLocalVideoCaps.dwCaps = _lDDSCaps;
return _pDD4->lpVtbl->GetAvailableVidMem( _pDD4 ,&stLocalVideoCaps,_ulTotal, _ulLeft );
}
/*
----------------------------------------------------------------------------------------
Description : Get driver caps
----------------------------------------------------------------------------------------
*/
HRESULT GLI_DX6_fn_hGetDriverCaps( tdstGliCaps *_pst_Caps, long _lFlags, LPDIRECTDRAW4 _pDD4 )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
DDCAPS stHDDCaps;
DDCAPS stSDDCaps;
DDCAPS *p_stCaps;
HRESULT hr;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
memset( &stHDDCaps, 0, sizeof( DDCAPS ) );
memset( &stSDDCaps, 0, sizeof( DDCAPS ) );
stHDDCaps.dwSize = stSDDCaps.dwSize = sizeof( DDCAPS );
hr = _pDD4->lpVtbl->GetCaps( _pDD4, &stHDDCaps, &stSDDCaps );
if (hr != DD_OK)
{
char szText[512];
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0, szText, 512, NULL );
return hr;
}
p_stCaps = (_lFlags & DX6_C_Dev_Hardware) ? &stHDDCaps : &stSDDCaps;
if( p_stCaps->dwCaps & DDCAPS_3D)
_pst_Caps->ulDriverCaps |= GLICAPS_DRV_C_ulIsHardware;
if ( ( p_stCaps->dwCaps & DDCAPS_PALETTE ) && (p_stCaps->dwPalCaps & DDPCAPS_8BIT ) && (p_stCaps->dwPalCaps & DDPCAPS_ALLOW256 ) )
_pst_Caps->ulTextureCaps |= GLICAPS_TEX_C_ulSupport8P;
if( p_stCaps->dwCaps2 & DDCAPS2_NONLOCALVIDMEM)
_pst_Caps->ulDriverCaps |= GLICAPS_DRV_C_ulCanUseAGP;
if( p_stCaps->dwCaps2 & DDCAPS2_CANRENDERWINDOWED )
_pst_Caps->ulDriverCaps |= GLICAPS_DRV_C_ulCanBeWindowed | GLICAPS_DRV_C_ulReadjustViewport;
/*if( (stHDDCaps.ddsCaps.dwCaps & (DDSCAPS_COMPLEX | DDSCAPS_MIPMAP)) == (DDSCAPS_COMPLEX | DDSCAPS_MIPMAP) )*/
if( p_stCaps->ddsCaps.dwCaps & DDSCAPS_MIPMAP )
_pst_Caps->ulTextureCaps |= GLICAPS_TEX_C_ulSupportMipmap;
/* Compute monitor's refresh rate */
if( TMR_MDRV_vTimerGetCounter && TMR_MDRV_ulTimerTickPerSecond )
{
hr = _pDD4->lpVtbl->WaitForVerticalBlank( _pDD4, DDWAITVB_BLOCKBEGIN, NULL );
if( FAILED( hr ) )
_pst_Caps->fRefreshRate = 60.0f;
else
{
stTimerCount stTimerBefore, stTimerAfter;
int i;
TMR_MDRV_vTimerGetCounter( C_wTimerFrequencyMedium, &stTimerBefore );
/* it's a 10 frame sample */
for( i=0; i<10; i++ )
{
hr = _pDD4->lpVtbl->WaitForVerticalBlank( _pDD4, DDWAITVB_BLOCKBEGIN, NULL );
if( FAILED( hr ) )
break;
}
TMR_MDRV_vTimerGetCounter( C_wTimerFrequencyMedium, &stTimerAfter );
if( i<10 )
/* If an error occured we set the refresh rate to 60Hz */
_pst_Caps->fRefreshRate = 60.0f;
else
/* Else, we compute it normally. The result is rounded to the nearest integer value. */
_pst_Caps->fRefreshRate =
(float)floor(
0.5f +
((float) i * TMR_MDRV_ulTimerTickPerSecond(C_wTimerFrequencyMedium))
/ ((float)abs( stTimerAfter.m_ulLowPart - stTimerBefore.m_ulLowPart) ) );
}
}
else
_pst_Caps->fRefreshRate = 60.0f;
return hr;
}
/*
----------------------------------------------------------------------------------------
Description : Get device caps
----------------------------------------------------------------------------------------
*/
HRESULT GLI_DX6_fn_hGetDeviceCaps( tdstGliCaps *_pst_Caps, LPDIRECTDRAW4 _pDD4, D3DDEVICEDESC *_pst_DevDesc )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
HRESULT hr;
unsigned long ulTotal, ulLeft;
DDPIXELFORMAT stPixelFormat;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Alpha test
*/
if ( _pst_DevDesc->dpcTriCaps.dwAlphaCmpCaps & D3DPCMPCAPS_GREATEREQUAL )
_pst_Caps->ulDriverCaps |= GLICAPS_DRV_C_ulSupportAlphaTest;
/*
* non squared texture
*/
if (!(_pst_DevDesc->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY))
_pst_Caps->ulTextureCaps |= GLICAPS_TEX_C_ulSupportNonSquare;
/*
* non local texture
*/
if ( _pst_DevDesc->dwDevCaps & D3DDEVCAPS_TEXTURENONLOCALVIDMEM )
_pst_Caps->ulDriverCaps |= GLICAPS_DRV_C_ulCanUseAGP;
else if (_pst_Caps->ulDriverCaps & GLICAPS_DRV_C_ulCanUseAGP )
_pst_Caps->ulDriverCaps -= GLICAPS_DRV_C_ulCanUseAGP;
/*
* max texture size
*/
_pst_Caps->ulTextureMaxSize = __min(_pst_DevDesc->dwMaxTextureWidth, _pst_DevDesc->dwMaxTextureHeight);
if ( _pst_Caps->ulTextureMaxSize == 0)
_pst_Caps->ulTextureMaxSize = 256;
/*
* total video mem (local and non local)
*/
hr = GLI_DX6_hGetVideoMemory( _pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulLeft );
if (hr == DD_OK)
{
_pst_Caps->ulTotalVideoMemory = ulTotal;
_pst_Caps->ulTotalTextureMemory = ulLeft;
}
if ( _pst_Caps->ulDriverCaps & GLICAPS_DRV_C_ulCanUseAGP)
{
hr = GLI_DX6_hGetVideoMemory( _pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_NONLOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulLeft );
if (hr == DD_OK)
{
_pst_Caps->ulTotalAGPMemory = ulTotal;
/*_pst_Caps->ulTotalTextureMemory += ulLeft;*/
}
else
_pst_Caps->ulDriverCaps -= GLICAPS_DRV_C_ulCanUseAGP;
}
/*
* pixel format of primary surface
*/
if ( g_pddsPrimary )
{
memset( &stPixelFormat, 0, sizeof(DDPIXELFORMAT) );
stPixelFormat.dwSize = sizeof( DDPIXELFORMAT );
g_pddsPrimary->lpVtbl->GetPixelFormat(g_pddsPrimary, &stPixelFormat );
_pst_Caps->ucPrimarySurfacePixelFormat = GLI_DX6_fn_ucGetPrimarySurfacePixelFormat(&stPixelFormat);
}
return DD_OK;
}
/*
=======================================================================================
=======================================================================================
Private Function
=======================================================================================
=======================================================================================
*/
/*
=======================================================================================
conversion D3D Pixel format to Defined Pixel Format
=======================================================================================
*/
long GLI_DX6_fn_lConvertMaskToShift ( unsigned long _ulMask )
{
if ( _ulMask & 0x00000001 ) return 0;
if ( _ulMask & 0x00000002 ) return 1;
if ( _ulMask & 0x00000004 ) return 2;
if ( _ulMask & 0x00000008 ) return 3;
if ( _ulMask & 0x00000010 ) return 4;
if ( _ulMask & 0x00000020 ) return 5;
if ( _ulMask & 0x00000040 ) return 6;
if ( _ulMask & 0x00000080 ) return 7;
if ( _ulMask & 0x00000100 ) return 8;
if ( _ulMask & 0x00000200 ) return 9;
if ( _ulMask & 0x00000400 ) return 10;
if ( _ulMask & 0x00000800 ) return 11;
if ( _ulMask & 0x00001000 ) return 12;
if ( _ulMask & 0x00002000 ) return 13;
if ( _ulMask & 0x00004000 ) return 14;
if ( _ulMask & 0x00008000 ) return 15;
if ( _ulMask & 0x00010000 ) return 16;
if ( _ulMask & 0x00020000 ) return 17;
if ( _ulMask & 0x00040000 ) return 18;
if ( _ulMask & 0x00080000 ) return 19;
if ( _ulMask & 0x00100000 ) return 20;
if ( _ulMask & 0x00200000 ) return 21;
if ( _ulMask & 0x00400000 ) return 22;
if ( _ulMask & 0x00800000 ) return 23;
if ( _ulMask & 0x01000000 ) return 24;
if ( _ulMask & 0x02000000 ) return 25;
if ( _ulMask & 0x04000000 ) return 26;
if ( _ulMask & 0x08000000 ) return 27;
if ( _ulMask & 0x10000000 ) return 28;
if ( _ulMask & 0x20000000 ) return 29;
if ( _ulMask & 0x40000000 ) return 30;
if ( _ulMask & 0x80000000 ) return 31;
return 0;
}
unsigned long GLI_DX6_fn_ulConvertNbBitsToMask ( long _lNbBits )
{
if ( _lNbBits == 0 ) return 0x00000000;
if ( _lNbBits == 1 ) return 0x00000001;
if ( _lNbBits == 2 ) return 0x00000003;
if ( _lNbBits == 3 ) return 0x00000007;
if ( _lNbBits == 4 ) return 0x0000000F;
if ( _lNbBits == 5 ) return 0x0000001F;
if ( _lNbBits == 6 ) return 0x0000003F;
if ( _lNbBits == 7 ) return 0x0000007F;
if ( _lNbBits == 8 ) return 0x000000FF;
if ( _lNbBits == 9 ) return 0x000001FF;
if ( _lNbBits == 10 ) return 0x000003FF;
if ( _lNbBits == 11 ) return 0x000007FF;
if ( _lNbBits == 12 ) return 0x00000FFF;
if ( _lNbBits == 13 ) return 0x00001FFF;
if ( _lNbBits == 14 ) return 0x00003FFF;
if ( _lNbBits == 15 ) return 0x00007FFF;
if ( _lNbBits == 16 ) return 0x0000FFFF;
if ( _lNbBits == 17 ) return 0x0001FFFF;
if ( _lNbBits == 18 ) return 0x0003FFFF;
if ( _lNbBits == 19 ) return 0x0007FFFF;
if ( _lNbBits == 20 ) return 0x000FFFFF;
if ( _lNbBits == 21 ) return 0x001FFFFF;
if ( _lNbBits == 22 ) return 0x003FFFFF;
if ( _lNbBits == 23 ) return 0x007FFFFF;
if ( _lNbBits == 24 ) return 0x00FFFFFF;
if ( _lNbBits == 25 ) return 0x01FFFFFF;
if ( _lNbBits == 26 ) return 0x03FFFFFF;
if ( _lNbBits == 27 ) return 0x07FFFFFF;
if ( _lNbBits == 28 ) return 0x0FFFFFFF;
if ( _lNbBits == 29 ) return 0x1FFFFFFF;
if ( _lNbBits == 30 ) return 0x3FFFFFFF;
if ( _lNbBits == 31 ) return 0x7FFFFFFF;
if ( _lNbBits == 32 ) return 0xFFFFFFFF;
return 0x00000000;
}
long GLI_DX6_fn_lConvertMaskToNbBits( unsigned long _ulMask )
{
if ( _ulMask == 0x00000000 ) return 0;
if ( _ulMask == 0x00000001 ) return 1;
if ( _ulMask == 0x00000003 ) return 2;
if ( _ulMask == 0x00000007 ) return 3;
if ( _ulMask == 0x0000000F ) return 4;
if ( _ulMask == 0x0000001F ) return 5;
if ( _ulMask == 0x0000003F ) return 6;
if ( _ulMask == 0x0000007F ) return 7;
if ( _ulMask == 0x000000FF ) return 8;
if ( _ulMask == 0x000001FF ) return 9;
if ( _ulMask == 0x000003FF ) return 10;
if ( _ulMask == 0x000007FF ) return 11;
if ( _ulMask == 0x00000FFF ) return 12;
if ( _ulMask == 0x00001FFF ) return 13;
if ( _ulMask == 0x00003FFF ) return 14;
if ( _ulMask == 0x00007FFF ) return 15;
if ( _ulMask == 0x0000FFFF ) return 16;
if ( _ulMask == 0x0001FFFF ) return 17;
if ( _ulMask == 0x0003FFFF ) return 18;
if ( _ulMask == 0x0007FFFF ) return 19;
if ( _ulMask == 0x000FFFFF ) return 20;
if ( _ulMask == 0x001FFFFF ) return 21;
if ( _ulMask == 0x003FFFFF ) return 22;
if ( _ulMask == 0x007FFFFF ) return 23;
if ( _ulMask == 0x00FFFFFF ) return 24;
if ( _ulMask == 0x01FFFFFF ) return 25;
if ( _ulMask == 0x03FFFFFF ) return 26;
if ( _ulMask == 0x07FFFFFF ) return 27;
if ( _ulMask == 0x0FFFFFFF ) return 28;
if ( _ulMask == 0x1FFFFFFF ) return 29;
if ( _ulMask == 0x3FFFFFFF ) return 30;
if ( _ulMask == 0x7FFFFFFF ) return 31;
if ( _ulMask == 0xFFFFFFFF ) return 32;
return 0;
}
ACP_tdxBool GLI_DX6_fn_bEqualRGBMask( GLD_tdpstPixelFormat _p_stPF, DDPIXELFORMAT *_p_stDDPF )
{
return ( _p_stPF->ulRedMask == _p_stDDPF->dwRBitMask ) && ( _p_stPF->ulGreenMask == _p_stDDPF->dwGBitMask ) && ( _p_stPF->ulBlueMask == _p_stDDPF->dwBBitMask );
}
ACP_tdxBool GLI_DX6_fn_bEqualRGBAMask( GLD_tdpstPixelFormat _p_stPF, DDPIXELFORMAT *_p_stDDPF )
{
return ( _p_stPF->ulRedMask == _p_stDDPF->dwRBitMask ) && ( _p_stPF->ulGreenMask == _p_stDDPF->dwGBitMask ) && ( _p_stPF->ulBlueMask == _p_stDDPF->dwBBitMask ) && ( _p_stPF->ulAlphaMask == _p_stDDPF->dwRGBAlphaBitMask );
}
void GLI_DX6_fn_vConvertDDPixelFormatToPixelFormat( GLD_tdpstPixelFormat _p_stPF, LPDDPIXELFORMAT _p_stDDPF )
{
_p_stPF->xFormatNumber = 0;
_p_stPF->bAlpha = (unsigned char) (_p_stDDPF->dwFlags & DDPF_ALPHAPIXELS);
_p_stPF->lPixelNbBits = _p_stDDPF->dwRGBBitCount;
_p_stPF->ulPixelMask = GLI_DX6_fn_ulConvertNbBitsToMask( _p_stPF->lPixelNbBits );
_p_stPF->lPixelNbBytes = _p_stPF->lPixelNbBits/8;
_p_stPF->ulRedMask = _p_stDDPF->dwRBitMask;
_p_stPF->lRedShift = GLI_DX6_fn_lConvertMaskToShift( _p_stPF->ulRedMask );
_p_stPF->lRedNbBits = GLI_DX6_fn_lConvertMaskToNbBits( _p_stPF->ulRedMask >> _p_stPF->lRedShift );
_p_stPF->ulGreenMask = _p_stDDPF->dwGBitMask;
_p_stPF->lGreenShift = GLI_DX6_fn_lConvertMaskToShift( _p_stPF->ulGreenMask );
_p_stPF->lGreenNbBits = GLI_DX6_fn_lConvertMaskToNbBits( _p_stPF->ulGreenMask >> _p_stPF->lGreenShift );
_p_stPF->ulBlueMask = _p_stDDPF->dwBBitMask;
_p_stPF->lBlueShift = GLI_DX6_fn_lConvertMaskToShift( _p_stPF->ulBlueMask );
_p_stPF->lBlueNbBits = GLI_DX6_fn_lConvertMaskToNbBits( _p_stPF->ulBlueMask >> _p_stPF->lBlueShift );
if ( _p_stPF->bAlpha )
{
_p_stPF->ulAlphaMask = _p_stDDPF->dwRGBAlphaBitMask;
_p_stPF->lAlphaShift = GLI_DX6_fn_lConvertMaskToShift( _p_stPF->ulAlphaMask );
_p_stPF->lAlphaNbBits= GLI_DX6_fn_lConvertMaskToNbBits( _p_stPF->ulAlphaMask >> _p_stPF->lAlphaShift );
}
else
{
_p_stPF->ulAlphaMask = 0x00000000;
_p_stPF->lAlphaShift = 0;
_p_stPF->lAlphaNbBits= 0;
}
}
long GLI_DX6_fn_lGetEquivalentPixelFormat( LPDDPIXELFORMAT _p_stDDPixelFormat )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lFormatIndex;
GLD_tdstPixelFormat *_p_stDefinedPF;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if ( !(_p_stDDPixelFormat->dwFlags & DDPF_RGB) )
return -1;
lFormatIndex = 0;
while(1)
{
_p_stDefinedPF = GLD_MDRV_fn_p_stGetDefinedPixelFormat( lFormatIndex );
if (_p_stDefinedPF == NULL)
return -1;
if ( _p_stDefinedPF->lPixelNbBits == (long) _p_stDDPixelFormat->dwRGBBitCount )
{
if ( _p_stDDPixelFormat->dwFlags & DDPF_ALPHAPIXELS )
{
if ( ( _p_stDefinedPF->bAlpha ) && ( GLI_DX6_fn_bEqualRGBAMask( _p_stDefinedPF, _p_stDDPixelFormat ) ) )
return lFormatIndex;
}
else
{
if ( ( !_p_stDefinedPF->bAlpha ) && ( GLI_DX6_fn_bEqualRGBMask( _p_stDefinedPF, _p_stDDPixelFormat ) ) )
return lFormatIndex;
}
}
lFormatIndex++;
}
return -1;
}
unsigned char GLI_DX6_fn_ucGetPrimarySurfacePixelFormat( LPDDPIXELFORMAT _p_stDDPF )
{
long lPixelFormat;
GLD_tdstPixelFormat stPF;
lPixelFormat = GLI_DX6_fn_lGetEquivalentPixelFormat( _p_stDDPF );
if (lPixelFormat != -1)
return (unsigned char) lPixelFormat;
GLI_DX6_fn_vConvertDDPixelFormatToPixelFormat( &stPF, _p_stDDPF );
lPixelFormat = GLD_MDRV_fn_lAddDefinedPixelFormat( &stPF );
if (lPixelFormat != -1 )
return (unsigned char ) lPixelFormat;
return (unsigned char) GLD_C_xUndefinedPixelFormat;
}
/*
=======================================================================================
D3D texture format
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : callback (use by D3DDevice3 method "EnumTextureFormats")
----------------------------------------------------------------------------------------
*/
static HRESULT CALLBACK fn_D3DCallbackGetPixelFormats (LPDDPIXELFORMAT _pddPF,LPVOID lpContext)
{
/*
* Record the DDSURFACEDESC of this texture format
*/
/* Skip any funky modes*/
if( _pddPF->dwFlags & (DDPF_LUMINANCE|DDPF_BUMPLUMINANCE|DDPF_BUMPDUDV) )
return DDENUMRET_OK;
memset(&gs_a_stD3DPixelFormat[ gs_lNumberOfPixelFormats ], 0,sizeof(DDPIXELFORMAT));
memcpy(&gs_a_stD3DPixelFormat[ gs_lNumberOfPixelFormats ], _pddPF,sizeof(DDPIXELFORMAT));
gs_lNumberOfPixelFormats++;
return DDENUMRET_OK;
};
/*
----------------------------------------------------------------------------------------
Description : This function update stD3DTextureFormat from the device
----------------------------------------------------------------------------------------
*/
HRESULT GLI_DX6_fn_hGetPixelFormats( void )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
HRESULT hr;
long lIndex;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* Set the default format to -1 to let the callback know it's being
* called for the first time.
*/
gs_lNumberOfPixelFormats = 0;
hr = g_pd3dDevice->lpVtbl->EnumTextureFormats( g_pd3dDevice, &fn_D3DCallbackGetPixelFormats,NULL);
if (hr != DD_OK)
return hr;
memset( gs_a_cPixelFormatIndex, -1, GLI_DX6_TexNbFormats );
for ( lIndex = 0; lIndex < gs_lNumberOfPixelFormats; lIndex++)
{
if (gs_a_stD3DPixelFormat[lIndex].dwFlags & DDPF_RGB)
{
/*
* 32 bits format
*/
if (gs_a_stD3DPixelFormat[lIndex].dwRGBBitCount == 32)
{
if (gs_a_stD3DPixelFormat[lIndex].dwFlags & DDPF_ALPHAPIXELS)
{
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat8888 ] = (char) lIndex;
}
else
{
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat888 ] = (char) lIndex;
}
}
/*
* 16 bit format
*/
else if (gs_a_stD3DPixelFormat[lIndex].dwRGBBitCount == 16)
{
/* alpha format*/
if (gs_a_stD3DPixelFormat[lIndex].dwFlags & DDPF_ALPHAPIXELS)
{
if( (gs_a_stD3DPixelFormat[lIndex].dwRGBAlphaBitMask == 0xF000) || (gs_a_stD3DPixelFormat[lIndex].dwRGBAlphaBitMask == 0xF) )
{
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat4444 ] = (char) lIndex;
}
else if ( (gs_a_stD3DPixelFormat[lIndex].dwRGBAlphaBitMask != 0x1) && (gs_a_stD3DPixelFormat[lIndex].dwRGBAlphaBitMask != 0x8000) )
{
if ( gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat4444 ] == -1)
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat4444 ] = (char) lIndex;
}
else if ( (gs_a_stD3DPixelFormat[lIndex].dwRGBAlphaBitMask == 0x1) || (gs_a_stD3DPixelFormat[lIndex].dwRGBAlphaBitMask == 0x8000) )
{
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat1555 ] = (char) lIndex;
}
else
{
if ( gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat4444 ] == -1)
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat4444 ] = (char) lIndex;
if ( gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat1555 ] == -1)
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat1555 ] = (char) lIndex;
}
}
else
{
if(gs_a_stD3DPixelFormat[lIndex].dwGBitMask == 0x07E0)
{
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat565 ] = (char) lIndex;
if ( gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat4444 ] == -1)
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat4444 ] = (char) lIndex;
if ( gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat1555 ] == -1)
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat1555 ] = (char) lIndex;
}
else if(gs_a_stD3DPixelFormat[lIndex].dwGBitMask == 0x03E0)
{
if ( gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat565 ] != -1 )
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat565 ] = (char) lIndex;
if ( gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat4444 ] == -1)
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat4444 ] = (char) lIndex;
if ( gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat1555 ] == -1)
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormat1555 ] = (char) lIndex;
}
}
}
/*
* 8 bit format
*/
else if (gs_a_stD3DPixelFormat[lIndex].dwRGBBitCount == 8)
{
if( gs_a_stD3DPixelFormat[lIndex].dwFlags & DDPF_PALETTEINDEXED8 )
gs_a_cPixelFormatIndex[ GLI_DX6_TexFormatPalette8 ] = (char) lIndex;
}
}
}
/*
* some more check
*/
if ( ( gs_a_cPixelFormatIndex[ GLI_DX6_TexFormatPalette8 ] == -1) && (g_p_stGliCaps->ulTextureCaps & GLICAPS_TEX_C_ulSupport8P) )
g_p_stGliCaps->ulTextureCaps -= GLICAPS_TEX_C_ulSupport8P;
return DD_OK;
}
/*
----------------------------------------------------------------------------------------
Description : Get pixel format that correspond to a constant
----------------------------------------------------------------------------------------
*/
void GLI_DX6_fn_vGetPixelFormat( char _ucFormatAsked, DDPIXELFORMAT *_p_stPixelFormat )
{
if ( (_ucFormatAsked >= GLI_DX6_TexNbFormats) || (gs_a_cPixelFormatIndex[ _ucFormatAsked ] == -1 ) )
*_p_stPixelFormat = gs_a_stD3DPixelFormat[0];
else
*_p_stPixelFormat = gs_a_stD3DPixelFormat[ gs_a_cPixelFormatIndex[ _ucFormatAsked ] ];
}
/*
=======================================================================================
Precalculate different texture size
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : precalculate texture size
----------------------------------------------------------------------------------------
*/
void GLI_DX6_fn_vPrecalculateTextureSize( void )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char cTexFormat;
char cMipmap;
char cWidth, cHeight;
long lWidth, lHeight;
DDSURFACEDESC2 ddsd;
unsigned long ulMemoryBefore, ulMemoryAfter, ulTotal, ulLeft;
HRESULT hr;
LPDIRECTDRAWSURFACE4 p_stDDS4;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
for (cTexFormat = 0; cTexFormat < GLI_DX6_TexNbFormats; cTexFormat++)
{
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT ;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_ALLOCONLOAD | DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
GLI_DX6_fn_vGetPixelFormat( cTexFormat, &ddsd.ddpfPixelFormat );
for (cMipmap = 0; cMipmap < 2; cMipmap++)
{
if (cMipmap)
{
if ( !( g_p_stGliCaps->ulTextureCaps & GLICAPS_TEX_C_ulSupportMipmap ) )
{
for (cWidth = 0, lWidth = 1; cWidth < 9 ; cWidth++, lWidth <<= 1 )
for (cHeight = 0, lHeight = 1; cHeight < 9; cHeight++, lHeight <<= 1)
gs_a_lPrecalculatedTextureSize[ cTexFormat ][ 1 ][ cWidth ][ cHeight ] = gs_a_lPrecalculatedTextureSize[ cTexFormat ][ 0 ][ cWidth ][ cHeight ];
continue;
}
ddsd.ddsCaps.dwCaps |= DDSCAPS_MIPMAP | DDSCAPS_COMPLEX;
ddsd.dwFlags |= DDSD_MIPMAPCOUNT;
}
for (cWidth = 0, lWidth = 1; cWidth < 9 ; cWidth++, lWidth <<= 1 )
{
for (cHeight = 0, lHeight = 1; cHeight < 9; cHeight++, lHeight <<= 1)
{
ddsd.dwWidth = lWidth;
ddsd.dwHeight = lHeight;
if (cMipmap)
ddsd.dwMipMapCount = ((cWidth > cHeight) ? cHeight : cWidth) + 1;
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulMemoryBefore );
if (g_p_stGliCaps->ulDriverCaps & GLICAPS_DRV_C_ulCanUseAGP )
{
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_NONLOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulLeft);
ulMemoryBefore += ulLeft;
}
/*
* create texture surface
*/
hr = g_pDD4->lpVtbl->CreateSurface( g_pDD4, &ddsd, &p_stDDS4, NULL );
if ( (hr != DD_OK) || !(p_stDDS4) )
{
gs_a_lPrecalculatedTextureSize[ cTexFormat ][ cMipmap ][ cWidth ][ cHeight ] = 0;
continue;
}
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulMemoryAfter );
if (g_p_stGliCaps->ulDriverCaps & GLICAPS_DRV_C_ulCanUseAGP )
{
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_NONLOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulLeft);
ulMemoryAfter += ulLeft;
}
gs_a_lPrecalculatedTextureSize[ cTexFormat ][ cMipmap ][ cWidth ][ cHeight ] = ulMemoryBefore - ulMemoryAfter;
do
{
hr = p_stDDS4->lpVtbl->Release( p_stDDS4 );
} while( hr );
}
}
}
}
/*
{
FILE *hpFile;
hpFile = fopen( "PreCalcTextureSize.log", "wt" );
if (hpFile == NULL)
return;
fprintf( hpFile, "Precalculated texture size\r\n\r\n[PixelFormat][mipmap count][Width][height][size]\r\n\r\n" );
for (cTexFormat = 0; cTexFormat < GLI_DX6_TexNbFormats; cTexFormat++)
for (cMipmap = 0; cMipmap < 2; cMipmap++)
for (cWidth = 0, lWidth = 1; cWidth < 9 ; cWidth++, lWidth <<= 1 )
for (cHeight = 0, lHeight = 1; cHeight < 9; cHeight++, lHeight <<= 1)
{
if (cMipmap)
ddsd.dwMipMapCount = ((cWidth > cHeight) ? cHeight : cWidth) + 1;
else
ddsd.dwMipMapCount = 0;
fprintf( hpFile, "%d %d %3d %3d %8d %8X\r\n", cTexFormat, ddsd.dwMipMapCount, lWidth, lHeight,
gs_a_lPrecalculatedTextureSize[ cTexFormat ][ cMipmap ][ cWidth ][ cHeight ],
gs_a_lPrecalculatedTextureSize[ cTexFormat ][ cMipmap ][ cWidth ][ cHeight ] );
}
fclose( hpFile );
}
*/
}
/*
----------------------------------------------------------------------------------------
Description : Get precalculated size
----------------------------------------------------------------------------------------
*/
long GLI_DX6_fn_lGetPrecalculatedTextureSize( char _cTexFormat, char _cMipmap, long _lWidth, long _lHeight )
{
char cWidth, cHeight;
cWidth = (char) GLI_DX6_fn_lConvertMaskToShift( _lWidth );
cHeight = (char) GLI_DX6_fn_lConvertMaskToShift( _lHeight );
return gs_a_lPrecalculatedTextureSize[ _cTexFormat ][ _cMipmap ][ cWidth ][ cHeight ];
}

View File

@@ -0,0 +1,319 @@
/*
=======================================================================================
Name : DX6_Choose.c
Author : vincent lhullier Date :21/08/98
Description : choose DirectX modes
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <stdio.h>
#define INITGUID
#include "d3d.h"
#include "ddraw.h"
#include "GLI_util.h"
#include "DispMode.h"
#include "DLLCom.h"
#include "DX6_Caps.h"
#include "DX6_Choose.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Extern (globals and function prototypes)
=======================================================================================
*/
extern GUID GLIDX6_gx_DDDriverGuid;
extern GUID GLIDX6_gx_D3DDeviceGuid;
long GLIDX6_gl_DeviceFlags;
D3DDEVICEDESC GLIDX6_gst_DeviceDesc;
static char GLIDX6_gc_Found;
/*
=======================================================================================
Direct draw Display mode
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : enumeration call back to get all display mode
----------------------------------------------------------------------------------------
*/
HRESULT CALLBACK GLIDX6_fnh_GetAllDisplayModesCallback(LPDDSURFACEDESC2 pddsd, LPVOID lpContext)
{
//chbani if ( ( pddsd->ddpfPixelFormat.dwRGBBitCount == 16 ) /* || ( pddsd->ddpfPixelFormat.dwRGBBitCount == 32 )*/ )
{
GLI_MDRV_lAddDisplayMode( 0, pddsd->dwWidth, pddsd->dwHeight, pddsd->ddpfPixelFormat.dwRGBBitCount ); //chbani 1-->0
}
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : enumeration call back to get all drivers
----------------------------------------------------------------------------------------
*/
BOOL WINAPI GLIDX6_fnb_GetDriverCallback( GUID FAR *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext )
{
if ( strcmp( (char*) lpContext, lpDriverName ) == 0 )
{
if (lpGUID != NULL)
memcpy( &GLIDX6_gx_DDDriverGuid, lpGUID, sizeof( GUID ) );
else
memset( &GLIDX6_gx_DDDriverGuid, 0, sizeof( GUID ) );
GLIDX6_gc_Found = 1;
return 0;
}
/* continue enumeration*/
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : enumeration call back to get device
----------------------------------------------------------------------------------------
*/
static HRESULT CALLBACK GLIDX6_fnh_GetDeviceCallback( GUID *_pGuid, LPSTR _szDesc, LPSTR _szName, LPD3DDEVICEDESC _lpHWDesc, LPD3DDEVICEDESC _lpHELDesc, LPVOID _lpContext )
{
if ( strcmp( _szName, (char*) _lpContext ) == 0 )
{
GLIDX6_gc_Found = 1;
memcpy( &GLIDX6_gx_D3DDeviceGuid, _pGuid, sizeof( GUID ) );
if ( _lpHWDesc->dcmColorModel )
{
GLIDX6_gl_DeviceFlags = DX6_C_Dev_Hardware;
memcpy( &GLIDX6_gst_DeviceDesc, _lpHWDesc, sizeof( D3DDEVICEDESC ) );
}
else
{
GLIDX6_gl_DeviceFlags = 0;
memcpy( &GLIDX6_gst_DeviceDesc, _lpHELDesc, sizeof( D3DDEVICEDESC ) );
}
return 0;
}
return D3DENUMRET_OK;
}
/*
----------------------------------------------------------------------------------------
Description : Main mode enumeration function called by engine initialization
----------------------------------------------------------------------------------------
*/
long __declspec(dllexport) GLI_DRV_fnl_EnumModes( char *_sz_DriverName, char *_sz_DeviceName )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
LPDIRECT3D3 pD3D = NULL;
LPDIRECTDRAW4 pDD4 = NULL;
LPDIRECTDRAW pDD;
HRESULT hr;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* get driver
*/
GLIDX6_gc_Found = 0;
hr = DirectDrawEnumerate( GLIDX6_fnb_GetDriverCallback, (void *) _sz_DriverName );
if ( (hr != DD_OK) || (GLIDX6_gc_Found == 0) )
return 0;
/*
* get device
*/
hr = DirectDrawCreate( &GLIDX6_gx_DDDriverGuid, &pDD, NULL );
if (hr != DD_OK)
return 0;
/* Get a ptr to an IDirectDraw4 interface. This interface to DirectDraw represents the DX6 version of the API.*/
hr = pDD->lpVtbl->QueryInterface( pDD, &IID_IDirectDraw4, (LPVOID *) &pDD4 );
pDD->lpVtbl->Release(pDD);
if (hr != DD_OK)
return 0;
/* Query DirectDraw for access to Direct3D*/
hr = pDD4->lpVtbl->QueryInterface( pDD4, &IID_IDirect3D3, (VOID**)&pD3D );
if (hr == DD_OK)
{
GLIDX6_gc_Found = 0;
hr = pD3D->lpVtbl->EnumDevices( pD3D, GLIDX6_fnh_GetDeviceCallback, (void *) _sz_DeviceName );
if ( (hr == DD_OK) && (GLIDX6_gc_Found != 0) )
{
hr = pDD4->lpVtbl->EnumDisplayModes( pDD4, 0, NULL, 0, GLIDX6_fnh_GetAllDisplayModesCallback );
}
}
if (pD3D) pD3D->lpVtbl->Release(pD3D);
if (pDD4) pDD4->lpVtbl->Release(pDD4);
return ( (hr == DD_OK) && (GLIDX6_gc_Found != 0) ) ? 1 : 0;
}
/*
=======================================================================================
Access function
=======================================================================================
*/
char GLIDX6_fnc_IsHardware( void )
{
return (GLIDX6_gl_DeviceFlags & DX6_C_Dev_Hardware) ? 1 : 0;
}
long GLIDX6_fnl_GetDeviceFlag( void )
{
return GLIDX6_gl_DeviceFlags;
}
D3DDEVICEDESC *GLIDX6_fnpst_GetDeviceDesc( void )
{
return &GLIDX6_gst_DeviceDesc;
}
/*
=======================================================================================
Function used only by GliDetect not in engine used.
=======================================================================================
*/
long (*gpfnl_AddDisplayInfo) (long, long, long , char*, unsigned long );
long gl_Driver, gl_Device;
/*
----------------------------------------------------------------------------------------
Description : enumeration call back to get all display mode
----------------------------------------------------------------------------------------
*/
static HRESULT CALLBACK DX6_fnh_ModeCallback(LPDDSURFACEDESC2 pddsd, LPVOID lpContext)
{
long l_Mode;
if ( ( pddsd->ddpfPixelFormat.dwRGBBitCount == 16 ) || ( pddsd->ddpfPixelFormat.dwRGBBitCount == 32 ) )
{
l_Mode = gpfnl_AddDisplayInfo( gl_Driver, 0, 0, "modeadd", 0);
gpfnl_AddDisplayInfo( gl_Driver, 0, l_Mode, "modefs", 1 );
gpfnl_AddDisplayInfo( gl_Driver, 0, l_Mode, "modebpp", pddsd->ddpfPixelFormat.dwRGBBitCount );
gpfnl_AddDisplayInfo( gl_Driver, 0, l_Mode, "modew", pddsd->dwWidth );
gpfnl_AddDisplayInfo( gl_Driver, 0, l_Mode, "modeh", pddsd->dwHeight );
}
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : enumeration call back to get all device
----------------------------------------------------------------------------------------
*/
static HRESULT CALLBACK DX6_fnh_DevicesCallback( GUID *_pGuid, LPSTR _szDesc, LPSTR _szName, LPD3DDEVICEDESC _lpHWDesc, LPD3DDEVICEDESC _lpHELDesc, LPVOID _lpContext )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tdstGliCaps st_Caps;
D3DDEVICEDESC *_pst_DevDesc;
long lFlags;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
gl_Device = gpfnl_AddDisplayInfo( gl_Driver, 0, 0, "dev_add", 0);
gpfnl_AddDisplayInfo( gl_Driver, gl_Device, 0, "dev_name", (unsigned long) _szName );
gpfnl_AddDisplayInfo( gl_Driver, gl_Device, 0, "dev_desc", (unsigned long) _szDesc );
gpfnl_AddDisplayInfo( gl_Driver, gl_Device, 0, "dev_param", (unsigned long) _pGuid );
if ( _lpHWDesc->dcmColorModel )
{
_pst_DevDesc = _lpHWDesc;
lFlags = DX6_C_Dev_Hardware;
}
else
{
_pst_DevDesc = _lpHELDesc;
lFlags = 0;
}
memset( &st_Caps, 0, sizeof( tdstGliCaps ) );
GLI_DX6_fn_hGetDriverCaps( &st_Caps, lFlags, (LPDIRECTDRAW4) _lpContext );
GLI_DX6_fn_hGetDeviceCaps( &st_Caps, (LPDIRECTDRAW4) _lpContext, _pst_DevDesc );
//GLI_DX6_fn_hGetPixelFormats();
//GLI_DX6_fn_vPrecalculateTextureSize();
gpfnl_AddDisplayInfo( gl_Driver, gl_Device, 0, "dev_caps", (unsigned long) &st_Caps );
return D3DENUMRET_OK;
}
/*
----------------------------------------------------------------------------------------
Description : enumeration call back to get all drivers
----------------------------------------------------------------------------------------
*/
BOOL WINAPI DX6_fnb_DriverCallback( GUID FAR *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
LPDIRECT3D3 pD3D = NULL;
LPDIRECTDRAW4 pDD4 = NULL;
LPDIRECTDRAW pDD = NULL;
HRESULT hr;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
gl_Driver = gpfnl_AddDisplayInfo( 0, 0, 0, "dispadd", 0);
gpfnl_AddDisplayInfo( gl_Driver, 0, 0, "dispname", (unsigned long) lpDriverName );
gpfnl_AddDisplayInfo( gl_Driver, 0, 0, "dispdesc", (unsigned long) lpDriverDescription );
gpfnl_AddDisplayInfo( gl_Driver, 0, 0, "dispparam", (unsigned long) lpGUID );
hr = DirectDrawCreate( lpGUID, &pDD, NULL );
if (hr == DD_OK)
{
/* Get a ptr to an IDirectDraw4 interface. This interface to DirectDraw represents the DX6 version of the API.*/
hr = pDD->lpVtbl->QueryInterface( pDD, &IID_IDirectDraw4, (LPVOID *) &pDD4 );
if (hr == DD_OK)
{
/* Query DirectDraw for access to Direct3D*/
hr = pDD4->lpVtbl->QueryInterface( pDD4, &IID_IDirect3D3, (VOID**)&pD3D );
if ( hr == DD_OK )
{
hr = pD3D->lpVtbl->EnumDevices( pD3D, DX6_fnh_DevicesCallback, pDD4 );
pDD4->lpVtbl->EnumDisplayModes( pDD4, 0, NULL, 0, DX6_fnh_ModeCallback );
}
}
}
if (pDD) pDD->lpVtbl->Release(pDD);
if (pD3D) pD3D->lpVtbl->Release(pD3D);
if (pDD4) pDD4->lpVtbl->Release(pDD4);
/* continue enumeration*/
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : Function to Get All display information
----------------------------------------------------------------------------------------
*/
long __declspec(dllexport) GLI_DRV_fn_lGetAllDisplayConfig( FARPROC _x_Fct )
{
HRESULT hr;
long lVersion;
gpfnl_AddDisplayInfo = (long (__cdecl *)( long, long, long, char *, unsigned long ) ) _x_Fct;
gpfnl_AddDisplayInfo( 0, 0, 0, "dll_bmp", 2);
lVersion = gpfnl_AddDisplayInfo(0,0,0,"miscdxversiondetect", 0);
if (lVersion < 0x600)
return 0;
hr = DirectDrawEnumerate( DX6_fnb_DriverCallback, NULL );
if (hr != DD_OK )
return 0;
return 1;
}

View File

@@ -0,0 +1,26 @@
/*
=======================================================================================
Name : DX6_Dll.c
Author : vincent lhullier Date :16/09/98
Description : specific DLL fonction
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "init_gli.h"
#include "DLLCom.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tdstGliDriverIdentity stDirectX6Id =
{
"DirectX6",
"Driver for DirectX6",
"1.0.0",
GLI_C_VersionD3DDP,
};
void fn_vInitDllIdentity( void )
{
memcpy( &g_stGliDrvId, &stDirectX6Id, sizeof( tdstGliDriverIdentity ) );
}

View File

@@ -0,0 +1,879 @@
/******************************************************************************************
FILE : DoMat DirectX6
Do render parameters settings for texture/material/fog
Dispay black triangles for window smaller than screen
*******************************************************************************************/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <d3d.h>
#include "Gli_st.h"
#include "GLI_Defn.h"
#include "polygon.h"
#include "mater_st.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "Liste.h"
#include "watrplan.h"
#include "proj.h"
#include "vpt3D.h"
#include "camera.h"
#include "material.h"
#include "texture.h"
#include "TEX.h"
#include "light.h"
#include "GliBench.h"
#include "TextuD3D.h"
#include "MacroD3D.h"
#include "DLLCom.h"
#include "PRF.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef ZARMA
}
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Globals, Externals
=======================================================================================
*/
D3DCOLOR xFogColor, xFogColorStart, xFogColorEnd, xFogcolorInfinite;
void GLI_vSetFogParams( tdstFogParams *_p_stFogParams );
HRESULT GLI_fn_hRestoreSurfaces( void );
extern LPDIRECT3DDEVICE3 g_pd3dDevice;
extern LPDIRECTDRAWSURFACE4 g_pddsBackBuffer;
/*
* for Black triangles
*/
D3DTLVERTEX g_stBlackTriangle[24];
long g_lNumberOfBlackTriangles = 0;
/*
* For fog
*/
static float xZDepthConstant;
/* Begin G.CLEMENT 23/08/1999 : unused vars, now local to GLI_vSetFogParams */
/*static float xFogIntensityEnd;*/
/*static float xFogIntensityStart;*/
/* End G.CLEMENT 23/08/1999 */
static float xZDepthStart, xZDepthStart2;
static float xZDepthEnd;
D3DCOLOR xFogColor, xFogColorStart, xFogColorEnd, xFogcolorInfinite;
/*
* For ZBuffer
*/
static long bIsWriteEnable = 1;
/*
* for render
*/
static ACP_tdxIndex xSaveFogIsOn = 0;
static unsigned char ucSaveCyclingMode = -1;
static unsigned char ucSaveFunction = -1;
static unsigned long gs_ulDepthBufferTestEnabled = 0;
/*
* for 32 bit back buffer
*/
extern long g_lFullScreenBpp;
/*
=======================================================================================
Special function for displaying black polygon
it's for cinematic scene to hide non black background color
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : reinit list of black triangles
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vNoBlackPolygon()
{
g_lNumberOfBlackTriangles = 0;
}
/*
----------------------------------------------------------------------------------------
Description : Add a black triangles to list
Assume that list is large enough (no test)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vAddBlackPolygon( long _lLeft, long _lTop, long _lRight, long _lBottom )
{
D3DTLVERTEX *p_stVertex;
static float fOoDepth = 0.8f/*4.0f*/;
if (g_lNumberOfBlackTriangles + 6 > 24 )
return;
p_stVertex = g_stBlackTriangle + g_lNumberOfBlackTriangles;
memset( p_stVertex, 0, 6 * sizeof( D3DTLVERTEX ) );
g_lNumberOfBlackTriangles += 6;
p_stVertex->sx = (D3DVALUE) _lLeft;
p_stVertex->sy = (D3DVALUE) _lBottom;
p_stVertex->rhw = (D3DVALUE) fOoDepth;
p_stVertex++;
p_stVertex->sx = (D3DVALUE) _lLeft;
p_stVertex->sy = (D3DVALUE) _lTop;
p_stVertex->rhw = (D3DVALUE) fOoDepth;
p_stVertex++;
p_stVertex->sx = (D3DVALUE) _lRight;
p_stVertex->sy = (D3DVALUE) _lTop;
p_stVertex->rhw = (D3DVALUE) fOoDepth;
p_stVertex++;
p_stVertex->sx = (D3DVALUE) _lRight;
p_stVertex->sy = (D3DVALUE) _lTop;
p_stVertex->rhw = (D3DVALUE) fOoDepth;
p_stVertex++;
p_stVertex->sx = (D3DVALUE) _lRight;
p_stVertex->sy = (D3DVALUE) _lBottom;
p_stVertex->rhw = (D3DVALUE) fOoDepth;
p_stVertex++;
p_stVertex->sx = (D3DVALUE) _lLeft;
p_stVertex->sy = (D3DVALUE) _lBottom;
p_stVertex->rhw = (D3DVALUE) fOoDepth;
}
/*
----------------------------------------------------------------------------------------
Description : Draw black triangles
----------------------------------------------------------------------------------------
*/
void GLI_vSendBlackPolygon()
{
if (g_lNumberOfBlackTriangles == 0)
return;
g_pd3dDevice->lpVtbl->SetTexture(g_pd3dDevice,0, NULL );
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_FOGENABLE,FALSE);
xSaveFogIsOn = 0;
/*
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
if( FAILED( g_pd3dDevice->lpVtbl->BeginScene(g_pd3dDevice) ) )
return;
*/
/* Draw the triangles*/
g_pd3dDevice->lpVtbl->DrawPrimitive( g_pd3dDevice, D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, g_stBlackTriangle, g_lNumberOfBlackTriangles, D3DDP_DONOTCLIP | D3DDP_DONOTLIGHT );
/*
/* End the scene./
g_pd3dDevice->lpVtbl->EndScene(g_pd3dDevice);
*/
}
/*
=======================================================================================
FOG
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : set render for fog parameters
----------------------------------------------------------------------------------------
*/
/* Begin G.CLEMENT 23/08/1999 : modified computation of xZDepthStart2,
turned global vars xFogIntensityStart/End into local ones */
void GLI_vSetFogParams( tdstFogParams *_p_stFogParams )
{
/*
xZDepthStart = _p_stFogParams->xDepthStart;
xZDepthEnd = _p_stFogParams->xDepthEnd;
xFogIntensityStart = _p_stFogParams->xBlendStart / 255.0f;
xFogIntensityEnd = _p_stFogParams->xBlendEnd / 255.0f;
xZDepthConstant = _p_stFogParams->xDepthEnd - _p_stFogParams->xDepthStart;
if ( xZDepthConstant )
xZDepthConstant = ( xFogIntensityEnd - xFogIntensityStart) / xZDepthConstant;
xZDepthStart2 = 1.0f / (256.0f * xZDepthConstant) + xZDepthStart;
if (_p_stFogParams->stColor.xR < 0.0f)
_p_stFogParams->stColor.xR = 0.0f;
else if (_p_stFogParams->stColor.xR > 1.0f)
_p_stFogParams->stColor.xR = 1.0f;
if (_p_stFogParams->stColor.xG < 0.0f)
_p_stFogParams->stColor.xG = 0.0f;
else if (_p_stFogParams->stColor.xG > 1.0f)
_p_stFogParams->stColor.xG = 1.0f;
if (_p_stFogParams->stColor.xB < 0.0f)
_p_stFogParams->stColor.xB = 0.0f;
else if (_p_stFogParams->stColor.xB > 1.0f)
_p_stFogParams->stColor.xB = 1.0f;
xFogColor = D3DRGBA( _p_stFogParams->stColor.xR, _p_stFogParams->stColor.xG, _p_stFogParams->stColor.xB, 0 );
xFogColorStart = D3DRGBA( 0, 0, 0, 1.f - xFogIntensityStart );
xFogColorEnd = D3DRGBA( 0, 0, 0, 1.f - xFogIntensityEnd );
*/
float xFogIntensityStart = _p_stFogParams->xBlendStart / 255.0f;
float xFogIntensityEnd = _p_stFogParams->xBlendEnd / 255.0f;
xZDepthStart = _p_stFogParams->xDepthStart;
xZDepthEnd = _p_stFogParams->xDepthEnd;
xZDepthConstant = xZDepthEnd - xZDepthStart;
if ( xZDepthConstant )
{
xZDepthConstant = ( xFogIntensityEnd - xFogIntensityStart) / xZDepthConstant;
if (xFogIntensityStart == 0)
xZDepthStart2 = xZDepthStart; /* More accurate than actual computation */
else
xZDepthStart2 = (xFogIntensityEnd * xZDepthStart - xFogIntensityStart * xZDepthEnd) / (xFogIntensityEnd - xFogIntensityStart);
} else {
xZDepthStart2 = xZDepthConstant = 0;
}
/* xZDepthStart2 = 1.0f / (256.0f * xZDepthConstant) + xZDepthStart; /* was wrong */
if (_p_stFogParams->stColor.xR < 0.0f)
_p_stFogParams->stColor.xR = 0.0f;
else if (_p_stFogParams->stColor.xR > 1.0f)
_p_stFogParams->stColor.xR = 1.0f;
if (_p_stFogParams->stColor.xG < 0.0f)
_p_stFogParams->stColor.xG = 0.0f;
else if (_p_stFogParams->stColor.xG > 1.0f)
_p_stFogParams->stColor.xG = 1.0f;
if (_p_stFogParams->stColor.xB < 0.0f)
_p_stFogParams->stColor.xB = 0.0f;
else if (_p_stFogParams->stColor.xB > 1.0f)
_p_stFogParams->stColor.xB = 1.0f;
xFogColor = D3DRGBA( _p_stFogParams->stColor.xR, _p_stFogParams->stColor.xG, _p_stFogParams->stColor.xB, 0 );
xFogColorStart = D3DRGBA( 0, 0, 0, 1.0f - xFogIntensityStart);
xFogColorEnd = D3DRGBA( 0, 0, 0, 1.0f - xFogIntensityEnd);
/* End G.CLEMENT 23/08/1999 */
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice, D3DRENDERSTATE_FOGCOLOR, xFogColor);
}
/*
----------------------------------------------------------------------------------------
Description : compute vertex color to render fog
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vComputeFogEffect(GLI_tdstInternalGlobalValuesFor3dEngine *p_stBG )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstAligned3DVector *p_stVertex, *p_stLastVertex;
D3DCOLOR *p_xColor;
unsigned long ulAlpha;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if ( !GLI_BIG_GLOBALS->xFogIsOn )
return;
if ( GLI_BIG_GLOBALS->p_stLastComputedFog != GLI_BIG_GLOBALS->p_stActiveFog )
{
GLI_vSetFogParams( GLI_BIG_GLOBALS->p_stActiveFog );
GLI_BIG_GLOBALS->p_stLastComputedFog = GLI_BIG_GLOBALS->p_stActiveFog;
}
p_stVertex = p_stBG->GLI_TurnedScaledDisplecedPoint;
p_stLastVertex = p_stVertex + p_stBG->p_stObj->xNbPoints;
p_xColor = (D3DCOLOR *) p_stBG->GLI_aDEF_stColorsRLIS;
for ( ; p_stVertex < p_stLastVertex;p_stVertex++, p_xColor++)
{
if (p_stVertex->xZ >= xZDepthEnd)
*p_xColor = xFogColorEnd;
else if ( p_stVertex->xZ <= xZDepthStart2)
*p_xColor = 0xff000000; /* and not xFogColorStart; /* G.CLEMENT 24/08/1999 */
else
{
/* Begin G.CLEMENT 24/08/1999 : added post-computation test */
*(float *) &ulAlpha = (1.f - (p_stVertex->xZ - xZDepthStart2) * xZDepthConstant) + 32768.0f + 16384.0f; /* G.CLEMENT 23/08/1999 : changed xZDepthStart to xZDepthStart2 */
/* Blending factor as a float is between 0 and 1, so we don't have to test the negative case.
We just test if it is too near 1, which would cause *p_xColor to be 0x00 */
if (ulAlpha & 0x0000ff00)
*p_xColor = 0xff000000;
else
*p_xColor = ulAlpha << 24;
/* End G.CLEMENT 24/08/1999 */
}
}
}
/*
=======================================================================================
ZBuffer function
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : To enable write to ZBuffer
----------------------------------------------------------------------------------------
*/
static void GLI_fn_vEnableWriteToZBuffer()
{
if (bIsWriteEnable) return;
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ZWRITEENABLE, TRUE );
bIsWriteEnable = 1;
}
/*
----------------------------------------------------------------------------------------
Description : To disable write to ZBuffer
----------------------------------------------------------------------------------------
*/
static void GLI_fn_vDisableWriteToZBuffer()
{
if (!bIsWriteEnable) return;
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ZWRITEENABLE, FALSE );
bIsWriteEnable = 0;
}
/*
----------------------------------------------------------------------------------------
Description : To manage use of ZBuffer
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vEnableDepthTest()
{
if( gs_ulDepthBufferTestEnabled )
return;
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ZFUNC, D3DCMP_GREATEREQUAL );
gs_ulDepthBufferTestEnabled = 1;
}
void GLI_DRV_vDisableDepthTest()
{
if( ! gs_ulDepthBufferTestEnabled )
return;
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS );
gs_ulDepthBufferTestEnabled = 0;
}
/*
=======================================================================================
Main render parameter setting functions
=======================================================================================
*/
/*
* Write to ZBuffer
*/
#define M_vZBuffer()\
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsWriteZBuffer) \
GLI_fn_vEnableWriteToZBuffer(); \
else \
GLI_fn_vDisableWriteToZBuffer();
/*
* fog
*/
#define M_vFog()\
if (GLI_BIG_GLOBALS->xFogIsOn) \
{ \
if ( GLI_BIG_GLOBALS->p_stLastComputedFog != GLI_BIG_GLOBALS->p_stActiveFog ) \
{ \
GLI_vSetFogParams( GLI_BIG_GLOBALS->p_stActiveFog ); \
GLI_BIG_GLOBALS->p_stLastComputedFog = GLI_BIG_GLOBALS->p_stActiveFog; \
} \
if (!xSaveFogIsOn) \
{ \
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_FOGENABLE,TRUE); \
xSaveFogIsOn = 1; \
} \
} \
else if (xSaveFogIsOn) \
{ \
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_FOGENABLE,FALSE); \
xSaveFogIsOn = 0; \
}
/*
* back face testing
*/
/*
#define M_vBackFace()\
if (p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsTestingBackface) \
if ((p_stGlobaleMT -> lHierachDrawMask & GLI_C_lIsNotDrawingInMirror) ? \
(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lNotInvertBackfaces) : \
!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lNotInvertBackfaces) ) \
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_CULLMODE, D3DCULL_CW); \
else \
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); \
else \
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
*/
/*
* Chromakey
*/
#define M_vChromakey()\
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lNZTexture) \
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_COLORKEYENABLE,TRUE); \
else \
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_COLORKEYENABLE,FALSE);
/*
* uv cycling mode
*/
/* Begin G.CLEMENT 20/07/1999 : replacing superseded SetRenderState's with SetTextureStageState */
#define M_vUVCyclingMode()\
if ( p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode != ucSaveCyclingMode ) \
{ \
switch ( ucSaveCyclingMode = p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode ) \
{ \
case 0: \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice ,D3DRENDERSTATE_TEXTUREADDRESS,D3DTADDRESS_CLAMP); */ \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREADDRESSU,D3DTADDRESS_CLAMP); */ \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREADDRESSV,D3DTADDRESS_CLAMP); */ \
/*g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP); */ \
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP); \
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP); \
break; \
case GLI_C_lCylingU: /* Cycling V */ \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREADDRESS,D3DTADDRESS_WRAP); */ \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREADDRESSU,D3DTADDRESS_CLAMP); */ \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREADDRESSV,D3DTADDRESS_WRAP); */ \
/* g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); */ \
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP); \
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); \
break; \
case GLI_C_lCylingV: /* Cycling U */ \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREADDRESS,D3DTADDRESS_WRAP); */ \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREADDRESSU,D3DTADDRESS_WRAP); */ \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREADDRESSV,D3DTADDRESS_CLAMP); */ \
/*g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); */\
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); \
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP); \
break; \
case GLI_C_lCylingUV: \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREADDRESS,D3DTADDRESS_WRAP); */ \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREADDRESSU,D3DTADDRESS_WRAP); */ \
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREADDRESSV,D3DTADDRESS_WRAP); */ \
/*g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); */ \
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); \
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); \
break; \
} \
}
/* End G.CLEMENT 20/07/1999 */
/* Begin G.CLEMENT 20/07/1999 : some macros for Texture Stage Settings */
#define GLI_M_SetTextureColorStage(dev, i, arg1, op, arg2) { \
dev->lpVtbl->SetTextureStageState(dev, i, D3DTSS_COLOROP, op); \
dev->lpVtbl->SetTextureStageState(dev, i, D3DTSS_COLORARG1, arg1); \
dev->lpVtbl->SetTextureStageState(dev, i, D3DTSS_COLORARG2, arg2); \
}
#define GLI_M_SetTextureAlphaStage(dev, i, arg1, op, arg2) {\
dev->lpVtbl->SetTextureStageState(dev, i, D3DTSS_ALPHAOP, op); \
dev->lpVtbl->SetTextureStageState(dev, i, D3DTSS_ALPHAARG1, arg1); \
dev->lpVtbl->SetTextureStageState(dev, i, D3DTSS_ALPHAARG2, arg2); \
}
/* End G.CLEMENT 20/07/1999 */
/*
----------------------------------------------------------------------------------------
Description : set render parameters that will work for all Opaque faces
----------------------------------------------------------------------------------------
*/
void GLI_fn_vSetRenderParametersBeforeOpaqueFace( void )
{
GLI_fn_vEnableWriteToZBuffer();
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
/* Begin G.CLEMENT 19/07/1999 */
/* g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATEALPHA); replaced with */
GLI_M_SetTextureColorStage(g_pd3dDevice, 0, D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_DIFFUSE);
GLI_M_SetTextureAlphaStage(g_pd3dDevice, 0, D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_DIFFUSE); /* For NZ-textures */
/* End G.CLEMENT 19/07/1999 */
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ALPHATESTENABLE, FALSE );
ucSaveFunction = 4;
}
/*
----------------------------------------------------------------------------------------
Description : called before the rendering of any triangle
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bBeginScene()
{
if( SUCCEEDED( g_pd3dDevice->lpVtbl->BeginScene(g_pd3dDevice) ) )
{
GLI_fn_vSetRenderParametersBeforeOpaqueFace();
GLI_vSendBlackPolygon();
return TRUE;
}
return FALSE;
}
/*
----------------------------------------------------------------------------------------
Description : called after the rendering of all triangles
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bEndScene()
{
return SUCCEEDED( g_pd3dDevice->lpVtbl->EndScene(g_pd3dDevice) );
}
/*
=======================================================================================
Special function for displaying black polygon
it's for cinematic scene to hide non black background color
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Called for all object before drawn.
Set some general parameters and set render parameter for opaque texture only
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vDoOpaqueTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
BOOL bTexture;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
bTexture = (p_stGlobaleMT->p_stCurrentTexture != NULL) && (p_stGlobaleMT->p_stCurrentTexture->bIsAvailable);
/*p_stGlobaleMT->xTextureDontAcceptFog = TRUE;*/
p_stGlobaleMT->xTextureDontAcceptFog = FALSE;
/*
* test if triangle will be transparent if so do not set render parameters
*/
if (GLI_BIG_GLOBALS->lAMirrorIsDetected)
GLI_BIG_GLOBALS->lAMirrorIsDetected = 3;
if (
(!(GLI_BIG_GLOBALS->lAMirrorIsDetected) && bTexture && (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTexture | GLI_C_lNZFilteredTexture | GLI_C_lAddTransparencyTexture) ) )
|| (!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))
)
{
p_stGlobaleMT -> lClippingModeMask |= GLI_C_TrianglesMustBeSorted;
if (bTexture && !(p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAlphaTexture ))
p_stGlobaleMT->xTextureDontAcceptFog = TRUE;
return;
}
p_stGlobaleMT->lClippingModeMask &= 0xffffffff - GLI_C_TrianglesMustBeSorted;
/*
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ZFUNC, D3DCMP_GREATEREQUAL );
else
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS );
*/
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
GLI_DRV_vEnableDepthTest();
else
GLI_DRV_vDisableDepthTest();
M_vFog();
/* GuS : Backfaces are removed by the engine itself. */
/*
M_vBackFace();
*/
M_vZBuffer();
/*
* mirror
*/
if ( bTexture )
{
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAlphaTest)
{
if (ucSaveFunction != 5)
{
if ( ucSaveFunction == 2 )
GLI_fn_vSetRenderParametersBeforeOpaqueFace() ;
/* Begin Guidom */
/*g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE ); /*
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ALPHAFUNC, D3DCMP_GREATEREQUAL );
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ALPHAREF, 0xC0 );
/* End Guidom */
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ALPHATESTENABLE, TRUE );
/*g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_ALPHABLENDENABLE,FALSE);*/
/*g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREMAPBLEND,D3DTBLEND_MODULATEALPHA);*/
ucSaveFunction = 5;
}
}
else if (GLI_BIG_GLOBALS->lAMirrorIsDetected & 2)
{
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ALPHATESTENABLE, FALSE );
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_ALPHABLENDENABLE,TRUE);
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_SRCBLEND,D3DBLEND_SRCALPHA);
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_DESTBLEND,D3DBLEND_INVSRCALPHA);
/* Begin G.CLEMENT 19/07/1999 */
/* g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATEALPHA); replaced with */
GLI_M_SetTextureColorStage(g_pd3dDevice, 0, D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_DIFFUSE);
GLI_M_SetTextureAlphaStage(g_pd3dDevice, 0, D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_DIFFUSE);
/* End G.CLEMENT 19/07/1999 */
ucSaveFunction = 2;
}
else
{
if (ucSaveFunction != 4)
{
if ( ucSaveFunction == 2 )
GLI_fn_vSetRenderParametersBeforeOpaqueFace() ;
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ALPHATESTENABLE, FALSE );
/*g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_ALPHABLENDENABLE,FALSE);*/
/*g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREMAPBLEND,D3DTBLEND_MODULATEALPHA);*/
ucSaveFunction = 4;
}
}
M_vChromakey();
M_vUVCyclingMode();
g_pd3dDevice->lpVtbl->SetTexture(g_pd3dDevice,0, (LPDIRECT3DTEXTURE2) p_stGlobaleMT->p_stCurrentTexture->p_stSpecParam );
}
else /* gouraud */
{
if (ucSaveFunction != 4)
{
if ( ucSaveFunction == 2 )
GLI_fn_vSetRenderParametersBeforeOpaqueFace() ;
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ALPHATESTENABLE, FALSE );
/*g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_ALPHABLENDENABLE,FALSE);*/
/*g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREMAPBLEND,D3DTBLEND_MODULATEALPHA);*/
ucSaveFunction = 4;
}
g_pd3dDevice->lpVtbl->SetTexture(g_pd3dDevice,0, NULL );
}
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters that will work for all transparency faces
----------------------------------------------------------------------------------------
*/
void GLI_fn_vSetRenderParametersBeforeTransparencyFace( void )
{
GLI_fn_vDisableWriteToZBuffer();
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ALPHATESTENABLE, FALSE );
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_ALPHABLENDENABLE,TRUE);
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_SRCBLEND,D3DBLEND_SRCALPHA);
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters for transparent triangles
----------------------------------------------------------------------------------------
*/
void GLI_vDoTransparentTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
/*
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ZFUNC, D3DCMP_GREATEREQUAL );
else
g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS );
*/
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
GLI_DRV_vEnableDepthTest();
else
GLI_DRV_vDisableDepthTest();
M_vFog();
/* GuS : Backfaces are removed by the engine itself. */
/*
M_vBackFace();
*/
if ((p_stGlobaleMT -> p_stCurrentTexture != NULL) && (p_stGlobaleMT -> p_stCurrentTexture -> bIsAvailable))
{
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAddTransparencyTexture)
{
/* Begin G.CLEMENT 02/08/1999 : Take the fog-disabling outside the 'if' statement */
/* Otherwise several addtransp. textures won't work well together */
if (ucSaveFunction != 1)
{
/*g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_ALPHABLENDENABLE,TRUE);*/
/*g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_SRCBLEND,D3DBLEND_SRCALPHA);*/
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_DESTBLEND,D3DBLEND_ONE);
/* Begin G.CLEMENT 19/07/1999 */
/* g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_TEXTUREMAPBLEND,D3DTBLEND_COPY); replaced with */
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_pd3dDevice->lpVtbl->SetTextureStageState(g_pd3dDevice, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
/* End G.CLEMENT 19/07/1999 */
ucSaveFunction = 1;
}
if (xSaveFogIsOn)
{
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_FOGENABLE,FALSE);
xSaveFogIsOn = 0;
}
/* End G.CLEMENT 02/08/1999 */
}
else if (ucSaveFunction != 2)
{
/*g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);*/
/*g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_SRCBLEND,D3DBLEND_SRCALPHA);*/
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_DESTBLEND,D3DBLEND_INVSRCALPHA);
/* Begin G.CLEMENT 19/07/1999 */
/* g_pd3dDevice->lpVtbl->SetRenderState( g_pd3dDevice, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATEALPHA); replaced with */
GLI_M_SetTextureColorStage(g_pd3dDevice, 0, D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_DIFFUSE);
GLI_M_SetTextureAlphaStage(g_pd3dDevice, 0, D3DTA_TEXTURE, D3DTOP_MODULATE, D3DTA_DIFFUSE);
/* End G.CLEMENT 19/07/1999 */
ucSaveFunction = 2;
}
M_vChromakey();
M_vUVCyclingMode();
g_pd3dDevice->lpVtbl->SetTexture(g_pd3dDevice,0, (LPDIRECT3DTEXTURE2) p_stGlobaleMT->p_stCurrentTexture->p_stSpecParam );
}
else
{
/* GOURAUD*/
/* Begin G.CLEMENT 02/08/1999 : Don't forget to reset destination alpha */
if (ucSaveFunction == 1)
g_pd3dDevice->lpVtbl->SetRenderState(g_pd3dDevice,D3DRENDERSTATE_DESTBLEND,D3DBLEND_INVSRCALPHA);
/* End G.CLEMENT 02/08/1999 */
g_pd3dDevice->lpVtbl->SetTexture(g_pd3dDevice, 0, NULL );
ucSaveFunction = 0;
}
}
/*
=======================================================================================
Write bitmap in backbuffer
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : write region of a bitmap into a region of the backbuffer
----------------------------------------------------------------------------------------
*/
void GLI_WriteRegionD3D(long X, long Y, long l, long h, unsigned char *p_ucSrc, long SrcPitch , LPDDSURFACEDESC2 p_ddsd )
{
long lXDst, lYDst;
unsigned short *p_uwSrc, *p_uwTgt;
long TgtPitch;
p_uwSrc = (unsigned short *) p_ucSrc;
p_uwTgt = (unsigned short *) ( (unsigned char *) p_ddsd->lpSurface + Y * p_ddsd->lPitch + X * 2 );
SrcPitch = (SrcPitch >> 1) - l;
TgtPitch = (p_ddsd->lPitch >> 1) - l;
for ( lYDst = 0 ; lYDst < h ; lYDst ++ )
{
for ( lXDst = 0 ; lXDst < l; lXDst ++ )
*p_uwTgt++ = *p_uwSrc++;
p_uwTgt += TgtPitch;
p_uwSrc += SrcPitch;
}
}
/*
----------------------------------------------------------------------------------------
Description : Write a 16 bit bitmap in the back buffer
_p_vSourceBuffer -> bitmap
_lWidth, _lHeight -> dimension of bitmap
_lDestX, _lDestY -> where the bitmap have to be copied in the backbuffer
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vWrite16bBitmapToBackBuffer( void *_p_vSourceBuffer, long _lWidth, long _lHeight, long _lDestLeft, long _lDestTop, long _lDestRight, long _lDestBottom )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lXDst, lYDst;
DDSURFACEDESC2 ddsd;
unsigned short *p_uwSrc, *p_uwTgt;
HRESULT hr;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
hr = g_pddsBackBuffer->lpVtbl->Lock(g_pddsBackBuffer, NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_NOSYSLOCK, NULL);
if ( hr != DD_OK )
{
GLI_fn_hRestoreSurfaces();
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
hr = g_pddsBackBuffer->lpVtbl->Lock(g_pddsBackBuffer, NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_NOSYSLOCK, NULL);
if ( hr != DD_OK )
return;
}
if ( g_lFullScreenBpp == 32 )
{
unsigned char *p_ucSrc, *p_ucTgt;
p_ucSrc = (unsigned char *) _p_vSourceBuffer;
p_ucTgt = (unsigned char *) ddsd.lpSurface;
ddsd.lPitch = ddsd.lPitch - (_lWidth * 4);
for ( lYDst = 0 ; lYDst < _lHeight ; lYDst ++ )
{
for ( lXDst = 0 ; lXDst < _lWidth; lXDst ++ )
{
*p_ucTgt++ = *p_ucSrc++;
*p_ucTgt++ = *p_ucSrc++;
*p_ucTgt++ = *p_ucSrc++;
p_ucTgt++;
}
}
}
else
{
p_uwSrc = (unsigned short *) _p_vSourceBuffer;
p_uwTgt = (unsigned short *) ddsd.lpSurface;
p_uwTgt += (ddsd.lPitch >> 1) * _lDestTop + _lDestLeft;
GLD_MDRV_vBlitStretched16b( _lDestRight - _lDestLeft + 1, _lDestBottom - _lDestTop + 1, p_uwTgt, ddsd.lPitch >> 1, _lWidth, _lHeight, p_uwSrc );
}
hr = g_pddsBackBuffer->lpVtbl->Unlock(g_pddsBackBuffer, NULL);
}
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@@ -0,0 +1,881 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "GLD.h"
#include "GEO.h"
#include "TEX.h"
#include "gli_st.h"
#include "textu_st.h"
#include "texture.h"
#include "ErrGli.h"
#include "DLLCaps.h"
#include <string.h>
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "d3d.h"
#include "ddraw.h"
#include "TextuD3D.h"
#include "MacroD3D.h"
#include "DLLCom.h"
#include "DX6_Caps.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
externals globals
=======================================================================================
*/
extern LPDIRECT3DDEVICE3 g_pd3dDevice;
extern LPDIRECTDRAW4 g_pDD4;
extern LPDIRECTDRAWSURFACE4 g_pddsPrimary;
extern long g_lFullScreenBpp;
/*
=======================================================================================
globals
=======================================================================================
*/
static long gs_lRestore = 0;
static LPDIRECTDRAWSURFACE4 g_p_stDDS4Temp = NULL;
static LPDIRECTDRAWSURFACE4 g_p_stDDS4New = NULL;
static LPDIRECT3DTEXTURE2 g_p_stD3DT2Temp = NULL;
static LPDIRECT3DTEXTURE2 g_p_stD3DT2New = NULL;
/*
=======================================================================================
functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : get video memory size taken by a given texture
----------------------------------------------------------------------------------------
*/
long GLI_DRV_lGetSizeOfTexture( GLI_tdstTexture *_p_stTexture )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char cPixelFormat;
char cMipmap;
long lSize;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if ( g_lFullScreenBpp == 32)
{
if ( _p_stTexture->lTextureCaps & GLI_C_lPaletteTexture )
cPixelFormat = GLI_DX6_TexFormatPalette8;
else if ( _p_stTexture->lTextureCaps & (GLI_C_lAlphaTexture | GLI_C_lAlphaTest | GLI_C_lNZFilteredTexture) )
cPixelFormat = GLI_DX6_TexFormat8888;
else
cPixelFormat = GLI_DX6_TexFormat888;
}
else if ( g_lFullScreenBpp == 16)
{
if ( _p_stTexture->lTextureCaps & GLI_C_lPaletteTexture )
cPixelFormat = GLI_DX6_TexFormatPalette8;
else if ( _p_stTexture->lTextureCaps & GLI_C_lAlphaTexture)
cPixelFormat = GLI_DX6_TexFormat4444;
else if ( _p_stTexture->lTextureCaps & (GLI_C_lAlphaTest | GLI_C_lNZFilteredTexture) )
cPixelFormat = GLI_DX6_TexFormat1555;
else
cPixelFormat = GLI_DX6_TexFormat565;
}
else
cPixelFormat = GLI_DX6_TexFormat565;
cMipmap = (char) ((_p_stTexture->lNumberOfLod) ? 1 : 0);
lSize = GLI_DX6_fn_lGetPrecalculatedTextureSize( cPixelFormat, cMipmap, _p_stTexture->lWidth, _p_stTexture->lHeight );
GLI_MDRV_TEXBENCH_vSetTextureSize( _p_stTexture, TEXBENCH_C_cComputedSize, lSize );
return lSize;
}
/*
=======================================================================================
General functions
=======================================================================================
*/
typedef struct tdstD3DErrorDesc_
{
HRESULT hErrorValue;
char *szText;
} tdstD3DErrorDesc;
#define C_cNumberOfD3DErrorDesc 65
tdstD3DErrorDesc g_a_stD3DError[C_cNumberOfD3DErrorDesc] =
{
{ DDERR_SURFACELOST, "DDERR_SURFACELOST"}, { DDERR_SURFACEBUSY, "DDERR_SURFACEBUSY"},
{ DDERR_INCOMPATIBLEPRIMARY, "DDERR_INCOMPATIBLEPRIMARY"}, { DDERR_INVALIDCAPS, "DDERR_INVALIDCAPS"},
{ DDERR_INVALIDOBJECT, "DDERR_INVALIDOBJECT"}, { DDERR_INVALIDPARAMS, "DDERR_INVALIDPARAMS"},
{ DDERR_INVALIDPIXELFORMAT, "DDERR_INVALIDPIXELFORMAT"}, { DDERR_NOALPHAHW, "DDERR_NOALPHAHW"},
{ DDERR_NOCOOPERATIVELEVELSET, "DDERR_NOCOOPERATIVELEVELSET"}, { DDERR_NODIRECTDRAWHW, "DDERR_NODIRECTDRAWHW"},
{ DDERR_NOEMULATION, "DDERR_NOEMULATION"}, { DDERR_NOEXCLUSIVEMODE, "DDERR_NOEXCLUSIVEMODE"},
{ DDERR_NOFLIPHW, "DDERR_NOFLIPHW"}, { DDERR_NOMIPMAPHW, "DDERR_NOMIPMAPHW"},
{ DDERR_NOOVERLAYHW, "DDERR_NOOVERLAYHW"}, { DDERR_NOZBUFFERHW, "DDERR_NOZBUFFERHW"},
{ DDERR_OUTOFMEMORY, "DDERR_OUTOFMEMORY"}, { DDERR_OUTOFVIDEOMEMORY, "DDERR_OUTOFVIDEOMEMORY"},
{ DDERR_PRIMARYSURFACEALREADYEXISTS,"DDERR_PRIMARYSURFACEALREADYEXISTS"}, { DDERR_UNSUPPORTEDMODE, "DDERR_UNSUPPORTEDMODE"},
{ D3DERR_BADMAJORVERSION, "D3DERR_BADMAJORVERSION"}, { D3DERR_BADMINORVERSION, "D3DERR_BADMINORVERSION"},
{ D3DERR_EXECUTE_CLIPPED_FAILED, "D3DERR_EXECUTE_CLIPPED_FAILED"}, { D3DERR_EXECUTE_CREATE_FAILED, "D3DERR_EXECUTE_CREATE_FAILED"},
{ D3DERR_EXECUTE_DESTROY_FAILED, "D3DERR_EXECUTE_DESTROY_FAILED"}, { D3DERR_EXECUTE_FAILED, "D3DERR_EXECUTE_FAILED"},
{ D3DERR_EXECUTE_LOCK_FAILED, "D3DERR_EXECUTE_LOCK_FAILED"}, { D3DERR_EXECUTE_LOCKED, "D3DERR_EXECUTE_LOCKED"},
{ D3DERR_EXECUTE_NOT_LOCKED, "D3DERR_EXECUTE_NOT_LOCKED"}, { D3DERR_EXECUTE_UNLOCK_FAILED, "D3DERR_EXECUTE_UNLOCK_FAILED"},
{ D3DERR_INBEGIN, "D3DERR_INBEGIN"}, { D3DERR_INVALID_DEVICE, "D3DERR_INVALID_DEVICE"},
{ D3DERR_INVALIDCURRENTVIEWPORT, "D3DERR_INVALIDCURRENTVIEWPORT"}, { D3DERR_INVALIDPRIMITIVETYPE, "D3DERR_INVALIDPRIMITIVETYPE"},
{ D3DERR_INVALIDVERTEXTYPE, "D3DERR_INVALIDVERTEXTYPE"}, { D3DERR_LIGHT_SET_FAILED, "D3DERR_LIGHT_SET_FAILED"},
{ D3DERR_MATERIAL_CREATE_FAILED, "D3DERR_MATERIAL_CREATE_FAILED"}, { D3DERR_MATERIAL_DESTROY_FAILED, "D3DERR_MATERIAL_DESTROY_FAILED"},
{ D3DERR_MATERIAL_GETDATA_FAILED, "D3DERR_MATERIAL_GETDATA_FAILED"}, { D3DERR_MATERIAL_SETDATA_FAILED, "D3DERR_MATERIAL_SETDATA_FAILED"},
{ D3DERR_MATRIX_CREATE_FAILED, "D3DERR_MATRIX_CREATE_FAILED"}, { D3DERR_MATRIX_DESTROY_FAILED, "D3DERR_MATRIX_DESTROY_FAILED"},
{ D3DERR_MATRIX_GETDATA_FAILED, "D3DERR_MATRIX_GETDATA_FAILED"}, { D3DERR_MATRIX_SETDATA_FAILED, "D3DERR_MATRIX_SETDATA_FAILED"},
{ D3DERR_NOTINBEGIN, "D3DERR_NOTINBEGIN"}, { D3DERR_NOVIEWPORTS, "D3DERR_NOVIEWPORTS"},
{ D3DERR_SCENE_BEGIN_FAILED, "D3DERR_SCENE_BEGIN_FAILED"}, { D3DERR_SCENE_END_FAILED, "D3DERR_SCENE_END_FAILED"},
{ D3DERR_SCENE_IN_SCENE, "D3DERR_SCENE_IN_SCENE"}, { D3DERR_SCENE_NOT_IN_SCENE, "D3DERR_SCENE_NOT_IN_SCENE"},
{ D3DERR_SETVIEWPORTDATA_FAILED, "D3DERR_SETVIEWPORTDATA_FAILED"}, { D3DERR_TEXTURE_BADSIZE , "D3DERR_TEXTURE_BADSIZE"},
{ D3DERR_TEXTURE_CREATE_FAILED, "D3DERR_TEXTURE_CREATE_FAILED"}, { D3DERR_TEXTURE_DESTROY_FAILED, "D3DERR_TEXTURE_DESTROY_FAILED"},
{ D3DERR_TEXTURE_GETSURF_FAILED, "D3DERR_TEXTURE_GETSURF_FAILED"}, { D3DERR_TEXTURE_LOAD_FAILED, "D3DERR_TEXTURE_LOAD_FAILED"},
{ D3DERR_TEXTURE_LOCK_FAILED, "D3DERR_TEXTURE_LOCK_FAILED"}, { D3DERR_TEXTURE_LOCKED, "D3DERR_TEXTURE_LOCKED"},
{ D3DERR_TEXTURE_NO_SUPPORT, "D3DERR_TEXTURE_NO_SUPPORT"}, { D3DERR_TEXTURE_NOT_LOCKED, "D3DERR_TEXTURE_NOT_LOCKED"},
{ D3DERR_TEXTURE_SWAP_FAILED, "D3DERR_TEXTURE_SWAP_FAILED"}, { D3DERR_TEXTURE_UNLOCK_FAILED, "D3DERR_TEXTURE_UNLOCK_FAILED"},
{ D3DERR_VIEWPORTDATANOTSET, "D3DERR_VIEWPORTDATANOTSET"}, { D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY, "D3DERR_ZBUFF_NEEDS_SYSTEMMEMORY"},
{ D3DERR_ZBUFF_NEEDS_VIDEOMEMORY, "D3DERR_ZBUFF_NEEDS_VIDEOMEMORY"},
};
/*
----------------------------------------------------------------------------------------
Description : return text that correspond to D3D error
----------------------------------------------------------------------------------------
*/
void vGetD3DError(HRESULT ddres,char *result)
{
tdstD3DErrorDesc *p_stErrorDesc = g_a_stD3DError;
tdstD3DErrorDesc *p_stLastErrorDesc = p_stErrorDesc + C_cNumberOfD3DErrorDesc;
for ( ; p_stErrorDesc < p_stLastErrorDesc; p_stErrorDesc++ )
{
if ( p_stErrorDesc->hErrorValue == ddres )
{
strcpy( result, p_stErrorDesc->szText );
return;
}
}
/* not a registered error*/
strcpy(result, "DDERR : default");
}
/*
=======================================================================================
compute functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description :
----------------------------------------------------------------------------------------
*/
static void fn_vGetScaleAndShiftFromMask(unsigned long ulMask, long *p_lShift, long *p_lScale)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned long ulTemp;
long lNbBits;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
ulTemp = ulMask;
*p_lShift = *p_lScale = lNbBits = 0;
while( (lNbBits != 32) && ((ulTemp&0x1) == 0) )
{
ulTemp >>= 1;
(*p_lShift)++;
lNbBits++;
}
while( (lNbBits != 32) && ((ulTemp&0x1) == 1) )
{
ulTemp >>= 1;
(*p_lScale)++;
lNbBits++;
}
*p_lScale = 8 - (*p_lScale);
}
/*
----------------------------------------------------------------------------------------
Description : copy a bitmap to a D3D surface
----------------------------------------------------------------------------------------
*/
/* Begin G.CLEMENT 28/07/1999 : added 'GLI_tdstTexture *p_stTexture' parameter for NZ special cases */
BOOL GLI_D3D_bCopyBitmapToSurface(char *hBitmap, LPDIRECTDRAWSURFACE4 p_stDDSurface, GLI_tdstTexture *p_stTexture)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lShiftRed, lScaleRed, lShiftGreen, lScaleGreen, lShiftBlue, lScaleBlue, lShiftAlpha, lScaleAlpha ;
unsigned long ulMaskRed, ulMaskGreen, ulMaskBlue, ulMaskAlpha;
DDSURFACEDESC2 ddsd;
HRESULT ddres;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
do
{
ddres = p_stDDSurface->lpVtbl->Lock( p_stDDSurface, NULL, &ddsd, 0, NULL);
} while (ddres==DDERR_WASSTILLDRAWING);
/*get the pixel format*/
if (ddsd.ddpfPixelFormat.dwRGBBitCount == 8)
{
memcpy( ddsd.lpSurface, hBitmap, ddsd.dwWidth * ddsd.dwHeight );
}
else
{
ulMaskRed = ddsd.ddpfPixelFormat.dwRBitMask;
ulMaskGreen = ddsd.ddpfPixelFormat.dwGBitMask;
ulMaskBlue = ddsd.ddpfPixelFormat.dwBBitMask;
ulMaskAlpha = ddsd.ddpfPixelFormat.dwRGBAlphaBitMask;
fn_vGetScaleAndShiftFromMask(ulMaskRed, &lShiftRed, &lScaleRed);
fn_vGetScaleAndShiftFromMask(ulMaskGreen, &lShiftGreen, &lScaleGreen);
fn_vGetScaleAndShiftFromMask(ulMaskBlue, &lShiftBlue, &lScaleBlue);
fn_vGetScaleAndShiftFromMask(ulMaskAlpha, &lShiftAlpha, &lScaleAlpha);
/*Translate load texture in the temporary texture*/
switch (ddsd.ddpfPixelFormat.dwRGBBitCount)
{
case 16:
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lHCounter,lWCounter;
char *p_cSource;
unsigned short *p_uwDest, *p_uwDestLocal;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
p_cSource=(char*)hBitmap;
p_uwDestLocal = p_uwDest=(unsigned short *)ddsd.lpSurface;
/* Here is the special NZ case */
if ((p_stTexture!=NULL) && (p_stTexture->lTextureCaps & GLI_C_lNZTexture)) {
/* It's mostly the same as non-NZ but we have to check that we don't add false chromakeyed pixels */
/* For this we need : */
char *p_cOriginalKey ; /* points to the original Chroma Key color, needed for comparison */
unsigned short usConvertedKey; /* The corresponding 16-bit value, so as not to recalculate it endlessly */
p_cOriginalKey = (char *) &(p_stTexture->lChromakeyColorRGBA);
/* Yes, we could get it with GetColorKey instead of recompute it...
But that way we don't depend on wether SetColoKey was called before */
usConvertedKey = (unsigned short)((((p_cOriginalKey[0]>>lScaleRed) <<lShiftRed) & ulMaskRed)
|(((p_cOriginalKey[1]>>lScaleGreen)<<lShiftGreen) & ulMaskGreen)
|(((p_cOriginalKey[2]>>lScaleBlue) <<lShiftBlue) & ulMaskBlue));
/* Note : no need for the alpha field in the chromakey */
for (lHCounter=0;lHCounter<(long)ddsd.dwHeight;lHCounter++,(unsigned char *)p_uwDestLocal += ddsd.lPitch )
for (lWCounter=0,p_uwDest = p_uwDestLocal;lWCounter<(long)ddsd.dwWidth;lWCounter++)
{
*p_uwDest = (unsigned short)((((p_cSource[0]>>lScaleRed) <<lShiftRed) &ulMaskRed)
|(((p_cSource[1]>>lScaleGreen)<<lShiftGreen)&ulMaskGreen)
|(((p_cSource[2]>>lScaleBlue) <<lShiftBlue) &ulMaskBlue)
|(((p_cSource[3]>>lScaleAlpha)<<lShiftAlpha)&ulMaskAlpha));
if ( ((*p_uwDest & ~ulMaskAlpha) == usConvertedKey) /* converted RGB values match */ &&
( (((*(unsigned long *)p_cSource) ^ (*(unsigned long *)p_cOriginalKey)) & 0x00ffffff) )) /* but original don't */ /* 0x00f8f8f8 */
{
/* We slightly change the converted value */
/* by inverting the least significant green bit */
*p_uwDest ^= ((unsigned short)1) << lShiftGreen;
/* Why the green bit ? Because in 565 it shows the least, and otherwise, why not ! */
} else if ((*p_uwDest & ~ulMaskAlpha) == usConvertedKey) {
*p_uwDest &= ~ulMaskAlpha;
}
p_uwDest++;
p_cSource+=4;
}
} else {
for (lHCounter=0;lHCounter<(long)ddsd.dwHeight;lHCounter++,(unsigned char *)p_uwDestLocal += ddsd.lPitch )
for (lWCounter=0,p_uwDest = p_uwDestLocal;lWCounter<(long)ddsd.dwWidth;lWCounter++)
{
*p_uwDest = (unsigned short)((((p_cSource[0]>>lScaleRed) <<lShiftRed) &ulMaskRed)
|(((p_cSource[1]>>lScaleGreen)<<lShiftGreen)&ulMaskGreen)
|(((p_cSource[2]>>lScaleBlue) <<lShiftBlue) &ulMaskBlue)
|(((p_cSource[3]>>lScaleAlpha)<<lShiftAlpha)&ulMaskAlpha));
p_uwDest++;
p_cSource+=4;
}
}
}
break;
case 24:
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lHCounter,lWCounter;
char *p_cSource;
unsigned long *p_ulDest , *p_ulDestLocal;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
p_cSource=(char*)hBitmap;
p_ulDestLocal = p_ulDest=(unsigned long *)ddsd.lpSurface;
for (lHCounter=0;lHCounter<(long)ddsd.dwHeight;lHCounter++, (unsigned char *)p_ulDestLocal += ddsd.lPitch )
for (lWCounter=0 , p_ulDest = p_ulDestLocal ;lWCounter<(long)ddsd.dwWidth;lWCounter++)
{
*p_ulDest = (unsigned long)((((p_cSource[0]>>lScaleRed) <<lShiftRed) &ulMaskRed)
|(((p_cSource[1]>>lScaleGreen)<<lShiftGreen)&ulMaskGreen)
|(((p_cSource[2]>>lScaleBlue) <<lShiftBlue) &ulMaskBlue));
p_ulDest = (unsigned long*)((unsigned char*)p_ulDest + 3);
p_cSource+=4;
}
}
break;
case 32:
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lHCounter,lWCounter;
char *p_cSource;
unsigned long *p_ulDest, *p_ulDestLocal ;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
p_cSource=(char*)hBitmap;
p_ulDest = p_ulDestLocal =(unsigned long *)ddsd.lpSurface;
for (lHCounter=0;lHCounter<(long)ddsd.dwHeight;lHCounter++ , (unsigned char *)p_ulDestLocal += ddsd.lPitch )
for (lWCounter=0 , p_ulDest = p_ulDestLocal ;lWCounter<(long)ddsd.dwWidth;lWCounter++)
{
*p_ulDest = (unsigned long)((((p_cSource[0]>>lScaleRed) <<lShiftRed) &ulMaskRed)
|(((p_cSource[1]>>lScaleGreen)<<lShiftGreen)&ulMaskGreen)
|(((p_cSource[2]>>lScaleBlue) <<lShiftBlue) &ulMaskBlue)
|(((p_cSource[3]>>lScaleAlpha)<<lShiftAlpha)&ulMaskAlpha));
p_ulDest++;
p_cSource+=4;
}
}
break;
}/*end switch*/
}
ddres = p_stDDSurface->lpVtbl->Unlock(p_stDDSurface, ddsd.lpSurface);
return (ddres == DD_OK);
}
/* End G.CLEMENT 28/07/1999 */
/*
=======================================================================================
D3D texture format
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : get good pixel format for given texture caps
----------------------------------------------------------------------------------------
*/
void GLI_fn_vGetPixelFormat( long _lTexCaps, DDPIXELFORMAT *_p_stPixelFormat )
{
if ( g_lFullScreenBpp == 32)
{
if ( _lTexCaps & GLI_C_lPaletteTexture )
GLI_DX6_fn_vGetPixelFormat( GLI_DX6_TexFormatPalette8, _p_stPixelFormat );
else if ( _lTexCaps & (GLI_C_lAlphaTexture | GLI_C_lAlphaTest | GLI_C_lNZFilteredTexture) )
GLI_DX6_fn_vGetPixelFormat( GLI_DX6_TexFormat8888, _p_stPixelFormat );
else
GLI_DX6_fn_vGetPixelFormat( GLI_DX6_TexFormat888, _p_stPixelFormat );
}
else if ( g_lFullScreenBpp == 16)
{
if (_lTexCaps & GLI_C_lPaletteTexture )
GLI_DX6_fn_vGetPixelFormat( GLI_DX6_TexFormatPalette8, _p_stPixelFormat );
else if(_lTexCaps & GLI_C_lAlphaTexture)
GLI_DX6_fn_vGetPixelFormat( GLI_DX6_TexFormat4444, _p_stPixelFormat );
else if (_lTexCaps & (GLI_C_lAlphaTest | GLI_C_lNZFilteredTexture) )
GLI_DX6_fn_vGetPixelFormat( GLI_DX6_TexFormat1555, _p_stPixelFormat );
else
GLI_DX6_fn_vGetPixelFormat( GLI_DX6_TexFormat565, _p_stPixelFormat );
}
}
/*
----------------------------------------------------------------------------------------
Description : get memory for creating a texture
( depend on use of AGP, size of texture, memory left )
----------------------------------------------------------------------------------------
*/
unsigned long GLI_fn_ulGetMemoryFlag( GLI_tdstTexture *_p_stTexture, long _lTextureMode, BOOL _bUseAgp )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned long ulLeftMem, ulTotalMem;
unsigned long ulTextureSize;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*ulTextureSize = (unsigned long) GLI_D3D_lGetSizeOfTexture( _p_stTexture );*/
ulTextureSize = GLI_DRV_lGetSizeOfTexture( _p_stTexture );
if ( ( _lTextureMode == TEX_C_VRAM ) || ( _lTextureMode == TEX_C_VRAMAGP ) || ( _lTextureMode == TEX_C_VRAM4 ) || ( _lTextureMode == TEX_C_VRAM8 ) )
{
/* memoire video*/
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotalMem, &ulLeftMem );
if (ulLeftMem > ulTextureSize + 5 * 1024) /* 5*1024 cache texture*/
return (DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY);
/* memoire AGP*/
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_NONLOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotalMem, &ulLeftMem );
if( _bUseAgp && (ulLeftMem > ulTextureSize ))
return (DDSCAPS_NONLOCALVIDMEM | DDSCAPS_VIDEOMEMORY);
}
else
{
/* memoire AGP*/
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_NONLOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotalMem, &ulLeftMem );
if( _bUseAgp && (ulLeftMem > ulTextureSize ) )
return (DDSCAPS_NONLOCALVIDMEM | DDSCAPS_VIDEOMEMORY);
/* memoire video*/
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotalMem, &ulLeftMem );
if (ulLeftMem > ulTextureSize + 5 * 1024) /* 5*1024 cache texture*/
return (DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY);
}
/* memoire system*/
return DDSCAPS_SYSTEMMEMORY;
}
/*
----------------------------------------------------------------------------------------
Description : when an error occors while downloading texture
----------------------------------------------------------------------------------------
*/
void GLI_DX6_fn_vErrorLoadingTexture( GLI_tdstTexture *_p_stTexture, HRESULT _hError, char *_szErrorText )
{
char szMessage[128];
sprintf(szMessage, "texture.c :%s : %X -> ", _szErrorText, _hError );
GLI_MDRV_vErmPrintMsg(szMessage, _p_stTexture->a255_cFileName);
if (g_p_stD3DT2Temp)
{
do
{
_hError = g_p_stD3DT2Temp->lpVtbl->Release( g_p_stD3DT2Temp );
} while (_hError > 0);
}
else if (g_p_stDDS4Temp)
g_p_stDDS4Temp->lpVtbl->Release( g_p_stDDS4Temp );
if (g_p_stD3DT2New)
{
do
{
_hError = g_p_stD3DT2Temp->lpVtbl->Release( g_p_stD3DT2New );
} while (_hError > 0);
}
else if (g_p_stDDS4New)
g_p_stDDS4New->lpVtbl->Release( g_p_stDDS4New );
}
/* Begin G.CLEMENT 29/07/1999 : new function to set the chromakey with the pixel format of the texture */
/*
-----------------------------------------------------------------------------------------
Description : set the chromakey of the texture to the DDSurface4 with the right format
-----------------------------------------------------------------------------------------
*/
BOOL GLI_DX6_ConvertAndSetChromakey(GLI_tdstTexture *p_stTexture, LPDIRECTDRAWSURFACE4 p_stDDSurface)
{
DDSURFACEDESC2 ddsd;
DDCOLORKEY stColorKey;
HRESULT ddres;
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddres = p_stDDSurface->lpVtbl->GetSurfaceDesc( p_stDDSurface, &ddsd);
if (ddres != DD_OK)
{
return FALSE;
}
/*get the pixel format*/
if (ddsd.ddpfPixelFormat.dwRGBBitCount == 8)
{
/* Dunno what to do ! */
return FALSE;
}
else
{
/* Neat ! Works the same with 16, 24, and 32 bits formats */
long lShiftRed, lScaleRed, lShiftGreen, lScaleGreen, lShiftBlue, lScaleBlue ;
unsigned long ulMaskRed, ulMaskGreen, ulMaskBlue;
unsigned long ulConvertedKey;
char *p_cOriginalKey = (char *)&(p_stTexture->lChromakeyColorRGBA);
ulMaskRed = ddsd.ddpfPixelFormat.dwRBitMask;
ulMaskGreen = ddsd.ddpfPixelFormat.dwGBitMask;
ulMaskBlue = ddsd.ddpfPixelFormat.dwBBitMask;
fn_vGetScaleAndShiftFromMask(ulMaskRed, &lShiftRed, &lScaleRed);
fn_vGetScaleAndShiftFromMask(ulMaskGreen, &lShiftGreen, &lScaleGreen);
fn_vGetScaleAndShiftFromMask(ulMaskBlue, &lShiftBlue, &lScaleBlue);
/* This is done for NZ textures, so we don't care about the alpha part */
ulConvertedKey = (unsigned long)((((p_cOriginalKey[0]>>lScaleRed) <<lShiftRed) & ulMaskRed)
|(((p_cOriginalKey[1]>>lScaleGreen)<<lShiftGreen) & ulMaskGreen)
|(((p_cOriginalKey[2]>>lScaleBlue) <<lShiftBlue) & ulMaskBlue));
stColorKey.dwColorSpaceLowValue = ulConvertedKey;
stColorKey.dwColorSpaceHighValue = ulConvertedKey;
ddres = p_stDDSurface->lpVtbl->SetColorKey( p_stDDSurface, DDCKEY_SRCBLT, &stColorKey);
return (ddres == DD_OK);
}
}
/* End G.CLEMENT 29/07/1999 */
/*
----------------------------------------------------------------------------------------
Description : Download texture
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vDownLoadTextures(long bRestore, long _lTextureMode, BOOL bReloading )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lMipMappingLocalSwitch, lTextureCounter;
GLI_tdstTexture *p_stTexture;
DDSURFACEDESC2 ddsd;
LPDIRECTDRAWSURFACE4 p_stDDSurfaceCurrentTemp;
HRESULT ddres;
DDSCAPS2 ddsCaps;
BOOL bCanUseMipmap;
BOOL bUseAGPMemory;
LPPALETTEENTRY p_stPalette;
unsigned long ulMemoryBefore, ulMemoryAfter, ulTotal, ulLeft;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*GLI_vInitD3DTextureFormat();*/
bCanUseMipmap = g_p_stGliCaps->ulTextureCaps & GLICAPS_TEX_C_ulSupportMipmap;
bUseAGPMemory = g_p_stGliCaps->ulDriverCaps & GLICAPS_DRV_C_ulCanUseAGP;
/* loop on textures*/
for (lTextureCounter = 0; lTextureCounter < GLI_C_lNBMaxOfTextures ; lTextureCounter ++)
{
if ( ( gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] == GLI_TEXIsUnallocated ) || ( (p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter]) == NULL ) )
continue;
g_p_stDDS4Temp = NULL;
g_p_stDDS4New = NULL;
g_p_stD3DT2Temp = NULL;
g_p_stD3DT2New = NULL;
/* Load bitmap*/
GLI_MDRV_xLoadTextureInTexelField(p_stTexture, GLI_gs_p_ConvertBufferMipMapping, bReloading);
/*
* Bench : compute memory before texture creation
*/
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulMemoryBefore );
if (bUseAGPMemory)
{
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_NONLOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulLeft);
ulMemoryBefore += ulLeft;
}
/*
* set surface parameters
*/
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT ;
GLI_fn_vGetPixelFormat( p_stTexture->lTextureCaps, &ddsd.ddpfPixelFormat );
ddsd.dwWidth = p_stTexture->lWidth;
ddsd.dwHeight = p_stTexture->lHeight;
ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_ALLOCONLOAD;
/*
* some more parameters in case of mipmap texture
*/
if( bCanUseMipmap && p_stTexture->lNumberOfLod)
{
ddsd.ddsCaps.dwCaps |= DDSCAPS_MIPMAP | DDSCAPS_COMPLEX;
ddsd.dwFlags |= DDSD_MIPMAPCOUNT;
ddsd.dwMipMapCount = p_stTexture->lNumberOfLod + 1;
}
else
ddsd.dwMipMapCount = 0;
ddsd.ddsCaps.dwCaps |= GLI_fn_ulGetMemoryFlag( p_stTexture, _lTextureMode, bUseAGPMemory );
/*
* create texture surface
*/
ddres = g_pDD4->lpVtbl->CreateSurface( g_pDD4, &ddsd, &g_p_stDDS4New, NULL );
if ( (ddres != DD_OK) || !(g_p_stDDS4New) )
{
GLI_DX6_fn_vErrorLoadingTexture( p_stTexture, ddres, "Create surface failed" );
continue;
}
/* create temporary surface*/
ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_TEXTURE;
if( bCanUseMipmap && p_stTexture->lNumberOfLod)
ddsd.ddsCaps.dwCaps |= DDSCAPS_MIPMAP | DDSCAPS_COMPLEX;
ddres = g_pDD4->lpVtbl->CreateSurface( g_pDD4, &ddsd, &g_p_stDDS4Temp,NULL);
if ( (ddres != DD_OK) || !(g_p_stDDS4Temp) )
{
GLI_DX6_fn_vErrorLoadingTexture( p_stTexture, ddres, "Create surface temp failed" );
continue;
}
/*
* Set palette
*/
if ( p_stTexture->lTextureCaps & GLI_C_lPaletteTexture )
{
LPDIRECTDRAWPALETTE p_stDDPalette;
long lColor;
unsigned char ucSave;
p_stPalette = (LPPALETTEENTRY) p_stTexture->p_vColorTable;
for (lColor = 0; lColor < 256; lColor++)
{
ucSave = p_stPalette[lColor].peRed;
p_stPalette[lColor].peRed = p_stPalette[lColor].peBlue;
p_stPalette[lColor].peBlue = ucSave;
}
ddres = g_pDD4->lpVtbl->CreatePalette( g_pDD4, DDPCAPS_8BIT | DDPCAPS_ALLOW256 | DDPCAPS_INITIALIZE, p_stPalette, &p_stDDPalette, NULL );
ddres = g_p_stDDS4Temp->lpVtbl->SetPalette( g_p_stDDS4Temp, p_stDDPalette );
ddres = g_p_stDDS4New->lpVtbl->SetPalette( g_p_stDDS4New, p_stDDPalette );
ddres = p_stDDPalette->lpVtbl->Release( p_stDDPalette );
}
/* Begin G.CLEMENT 28/07/1999 : reverted chromakey settings and bitmap copy (we need the former in the latter) */
/* Set the color key (chroma key) ([G.CLEMENT] using my new function) */
if(p_stTexture->lTextureCaps & GLI_C_lNZTexture)
{
if (!GLI_DX6_ConvertAndSetChromakey(p_stTexture, g_p_stDDS4New))
{
GLI_DX6_fn_vErrorLoadingTexture( p_stTexture, ddres, "SetColorKey failed" );
continue;
}
}
/* Copy bitmap in the temporary surface*/
if(!GLI_D3D_bCopyBitmapToSurface(p_stTexture->p_vBitMap, g_p_stDDS4Temp,p_stTexture)) /* G.CLEMENT 28/07/1999 : added 'p_stTexture' as an argument */
{
GLI_DX6_fn_vErrorLoadingTexture( p_stTexture, ddres, "Copy bitmap failed" );
continue;
}
/* End G.CLEMENT 28/07/1999 */
/* compute next mipmaping levels*/
if( bCanUseMipmap )
{
unsigned short uwWidth, uwHeight;
uwWidth = p_stTexture->lWidth;
uwHeight = p_stTexture->lHeight;
lMipMappingLocalSwitch = p_stTexture->lNumberOfLod;
p_stDDSurfaceCurrentTemp = g_p_stDDS4Temp;
ddres = DD_OK;
while ( lMipMappingLocalSwitch-- )
{
/* Compute the bitmap from the prev level of mipmaping*/
if ( p_stTexture->lTextureCaps & GLI_C_lPaletteTexture )
GLI_MDRV_vDivideBitmapSurfaceBy2Palette( (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *) p_stPalette, uwHeight, uwWidth );
else if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping, uwHeight, uwWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 29/07/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping, (unsigned long *)GLI_gs_p_ConvertBufferMipMapping, uwHeight, uwWidth );
/* Get the temporary surface of the current mipmaping level*/
ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
ddres = p_stDDSurfaceCurrentTemp->lpVtbl->GetAttachedSurface( p_stDDSurfaceCurrentTemp, &ddsCaps ,&p_stDDSurfaceCurrentTemp);
if(ddres != DD_OK)
{
GLI_DX6_fn_vErrorLoadingTexture( p_stTexture, ddres, "GetAttachedSurface failed" );
break;
}
/* Copy the bitmap in the current temporary surface*/
if(!GLI_D3D_bCopyBitmapToSurface(GLI_gs_p_ConvertBufferMipMapping, p_stDDSurfaceCurrentTemp,p_stTexture)) /* G.CLEMENT 28/07/1999 : added 'p_stTexture' as an argument */
{
GLI_DX6_fn_vErrorLoadingTexture( p_stTexture, ddres, "Copy bitmap level failed" );
break;
}
uwWidth >>= 1;
uwHeight >>= 1;
}
if (ddres != DD_OK)
continue;
}
/* Get the texture interface*/
ddres = g_p_stDDS4New->lpVtbl->QueryInterface( g_p_stDDS4New, &IID_IDirect3DTexture2, (void**) &g_p_stD3DT2New );
if (ddres != DD_OK)
{
GLI_DX6_fn_vErrorLoadingTexture( p_stTexture, ddres, "QueryInterface texture2 failed" );
continue;
}
ddres = g_p_stDDS4Temp->lpVtbl->QueryInterface( g_p_stDDS4Temp , &IID_IDirect3DTexture2, (void**) &g_p_stD3DT2Temp );
if (ddres != DD_OK)
{
GLI_DX6_fn_vErrorLoadingTexture( p_stTexture, ddres, "QueryInterface TempTexture2 failed" );
continue;
}
/* Load temporary texture in the good texture*/
ddres = g_p_stD3DT2New->lpVtbl->Load( g_p_stD3DT2New, g_p_stD3DT2Temp );
if (ddres != DD_OK)
{
GLI_DX6_fn_vErrorLoadingTexture( p_stTexture, ddres, "load failed" );
continue;
}
/* Delete the texture interface*/
do
{
ddres = g_p_stD3DT2Temp->lpVtbl->Release( g_p_stD3DT2Temp );
} while (ddres > 0);
/* Delete the temporary surface*/
p_stTexture->p_stSpecParam = (void *) g_p_stD3DT2New;
p_stTexture->bIsAvailable = 1;
/*
* Bench : compute memory after texture creation
*/
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulMemoryAfter );
if (bUseAGPMemory)
{
GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_NONLOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulLeft);
ulMemoryAfter += ulLeft;
}
GLI_MDRV_TEXBENCH_vSetTextureSize( p_stTexture, 1, ulMemoryBefore - ulMemoryAfter );
}
};
/*
----------------------------------------------------------------------------------------
Description : Compute total memory size available for texture
----------------------------------------------------------------------------------------
*/
#ifdef __old__
long GLI_DRV_lGetHardwareTotalTextureMemorySize( long _lTextureMode )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned long ulTotal, ulLeft;
long lReturn;
HRESULT ddres;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
switch( _lTextureMode )
{
case TEX_C_VRAM:
ddres = GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulLeft );
lReturn = (ddres != DD_OK) ? -1 : (long) ulLeft;
break;
case TEX_C_VRAM4:
case TEX_C_AGP4:
lReturn = 0x400000; /* 4 Mo*/
break;
case TEX_C_VRAM8:
case TEX_C_AGP8:
lReturn = 0x800000; /* 8 Mo */
break;
case TEX_C_VRAMAGP:
case TEX_C_AGP:
ddres = GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulLeft );
lReturn = (ddres != DD_OK) ? -1 : (long) ulLeft;
ddres = GLI_DX6_hGetVideoMemory( g_pDD4, DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY | DDSCAPS_NONLOCALVIDMEM | DDSCAPS_MIPMAP, &ulTotal, &ulLeft );
if (ddres != DD_OK)
lReturn = -1;
else
lReturn += (long) ulLeft;
break;
}
return lReturn;
}
#endif
/*
----------------------------------------------------------------------------------------
Description : recursive callback function to release the mipmap texture surfaces
----------------------------------------------------------------------------------------
*/
//HRESULT WINAPI ReleaseAttachedSurfaceCallback(LPDIRECTDRAWSURFACE7 lpDDSurface, LPDDSURFACEDESC2 lpDDSurfaceDesc, LPVOID lpContext)
//{
// lpDDSurface->lpVtbl->EnumAttachedSurfaces(lpDDSurface, NULL, ReleaseAttachedSurfaceCallback);
// lpDDSurface->lpVtbl->Release(lpDDSurface);
// return DDENUMRET_OK;
//}
/*
/*
----------------------------------------------------------------------------------------
Description : unload textures
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vUnLoadTextures()
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
HRESULT hr;
long lTextureCounter;
LPDIRECT3DTEXTURE2 lpD3DT2;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstTexture *p_stTexture;
//chbani : add this line sinon ca plante dans UnLoadTex (changement de map et display WayPoint)
if( g_pd3dDevice )
g_pd3dDevice->lpVtbl->SetTexture(g_pd3dDevice,0, NULL );
for ( lTextureCounter = 0 ; lTextureCounter < C_lMaxNumberOfTexture ;lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated )
{
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
if (p_stTexture != NULL)
{
if ( (p_stTexture->bIsAvailable) && ( p_stTexture->p_stSpecParam ) )
{
/*lpD3DT2 = ((GLI_tdstTextureD3D *) p_stTexture->p_stSpecParam)->p_stD3DTexture; */
lpD3DT2 = (LPDIRECT3DTEXTURE2) p_stTexture->p_stSpecParam;
if (lpD3DT2 != NULL)
/* Don't forget to release mipmap (attached) textures too */
//lpD3DT2->lpVtbl->EnumAttachedSurfaces(lpD3DT2, NULL, ReleaseAttachedSurfaceCallback);
do
{
hr =lpD3DT2->lpVtbl->Release( lpD3DT2 );
} while (hr > 0);
/*GLI_MDRV_vTmpFree( p_stTexture->p_stSpecParam );*/
p_stTexture->p_stSpecParam = NULL;
p_stTexture->bIsAvailable = 0;
}
}
}
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,36 @@
/*
=======================================================================================
Name : DX6_Caps.h
Author : vincent lhullier Date :30/10/98
Description : capabilities of driver (depend on hardware)
=======================================================================================
*/
#ifndef __DX6_CAPS_H__
#define __DX6_CAPS_H__
#include "d3d.h"
#include "ddraw.h"
#include "DLLCaps.h"
#define GLI_DX6_TexFormat4444 0
#define GLI_DX6_TexFormat1555 1
#define GLI_DX6_TexFormat565 2
#define GLI_DX6_TexFormatPalette8 3
#define GLI_DX6_TexFormat888 4
#define GLI_DX6_TexFormat8888 5
#define GLI_DX6_TexNbFormats 6
HRESULT GLI_DX6_hGetVideoMemory( LPDIRECTDRAW4 _pDD4, long _lDDSCaps, unsigned long *_ulTotal, unsigned long *_ulLeft );
HRESULT GLI_DX6_fn_hGetDriverCaps( tdstGliCaps *_pst_Caps, long _lFlags, LPDIRECTDRAW4 _pDD4 );
HRESULT GLI_DX6_fn_hGetDeviceCaps( tdstGliCaps *_pst_Caps, LPDIRECTDRAW4 _pDD4, D3DDEVICEDESC *_pst_DevDesc );
HRESULT GLI_DX6_fn_hGetPixelFormats( void );
void GLI_DX6_fn_vGetPixelFormat( char _ucFormatAsked, DDPIXELFORMAT *_p_stPixelFormat );
void GLI_DX6_fn_vPrecalculateTextureSize( void );
long GLI_DX6_fn_lGetPrecalculatedTextureSize( char _cTexFormat, char _cMipmap, long _lWidth, long _lHeight );
#endif

View File

@@ -0,0 +1,37 @@
/*
=======================================================================================
Name : DX6_Choose.h
Author : vincent lhullier Date :21/08/98
Description : choose DirectX modes
=======================================================================================
*/
#ifndef __DX6_CHOOSE_H__
#define __DX6_CHOOSE_H__
#include <d3d.h>
#define DX6_C_Dev_Hardware 0x00000001
/*
=======================================================================================
Main function
=======================================================================================
*/
void GLI_fn_vChooseDisplay( void );
/*
=======================================================================================
Access functions
=======================================================================================
*/
/*
* for device
*/
char GLIDX6_fnc_IsHardware( void );
long GLIDX6_fnl_GetDeviceFlag( void );
D3DDEVICEDESC * GLIDX6_fnpst_GetDeviceDesc( void );
#endif /*__DX6_CHOOSE_H__*/

View File

@@ -0,0 +1,15 @@
#ifndef MACROD3D_H
#define MACROD3D_H
#define D3D_M_vRelease(x) if((x)!=NULL) {(x)->lpVtbl->Release(x); (x) = NULL;}
#define IDirect3D0(p,fonction) ( (((p) != NULL) && ((p)->lpVtbl != NULL)) ? (p)->lpVtbl->##fonction##(p) : -1)
#define IDirect3D1(p,fonction,a) ( (((p) != NULL) && ((p)->lpVtbl != NULL)) ? (p)->lpVtbl->##fonction##(p,a) : -1)
#define IDirect3D2(p,fonction,a,b) ( (((p) != NULL) && ((p)->lpVtbl != NULL)) ? (p)->lpVtbl->##fonction##(p,a,b) : -1)
#define IDirect3D3(p,fonction,a,b,c) ( (((p) != NULL) && ((p)->lpVtbl != NULL)) ? (p)->lpVtbl->##fonction##(p,a,b,c) : -1)
#define IDirect3D4(p,fonction,a,b,c,d) ( (((p) != NULL) && ((p)->lpVtbl != NULL)) ? (p)->lpVtbl->##fonction##(p,a,b,c,d) : -1)
#define IDirect3D5(p,fonction,a,b,c,d,e) ( (((p) != NULL) && ((p)->lpVtbl != NULL)) ? (p)->lpVtbl->##fonction##(p,a,b,c,d,e) : -1)
#endif /* MACROD3D_H */

View File

@@ -0,0 +1,23 @@
#ifndef GLI_TEXTUD3D_H
#define GLI_TEXTUD3D_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
typedef struct GLI_tdstTextureD3D_
{
//D3DTEXTUREHANDLE hD3DTexture;
LPDIRECT3DTEXTURE2 p_stD3DTexture;
//LPDIRECTDRAWSURFACE p_stDDSurface;
LPDIRECTDRAWSURFACE4 p_stDDSurface;
} GLI_tdstTextureD3D;
*/
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* GLI_TEXTUD3D_H*/

View File

@@ -0,0 +1,5 @@
SCC = This is a source code control file
[DirectX6.vcproj]
SCC_Aux_Path = "P4SCC#srvperforce-ma:1666##raymandata##Editor"
SCC_Project_Name = Perforce Project

View File

@@ -0,0 +1,214 @@
#include <windows.h>
#include "dllcom.h"
#include "GliBench.h"
#include "TMR.h"
/*
=======================================================================================
Globals
=======================================================================================
*/
tdstGliDriverIdentity g_stGliDrvId;
tdstGliCaps *g_p_stGliCaps = NULL;
/*
* imported object Have to be initialized
*/
GLI_tdst_DllInfos *GLI_gpst_DllInfo; //chbani
GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
long *gs_aDEFTableOfTextureMemoryChannels;
GLI_tdstTexture **gs_aDEFTableOfTextureAlreadyRead;
void *GLI_gs_p_ConvertBufferMipMapping;
long *GLD_p_lRenderingCounter;
void *g_p_vDrawSemaphore;
#ifdef GLI_BENCH
tdstGliBench *GLI_MDRV_g_p_stBench;
#endif
/*
* imported function
*/
/*
* From GLI
*/
void (* GLI_MDRV_vSetGlobalAlpha)( float );
void (* GLI_MDRV_vSerialProjection)( GLI_tdstCamera *, long , GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *);
long (* GLI_MDRV_xIsGliInit)();
void * (* GLI_MDRV_p_vTmpMalloc)( unsigned long );
void (* GLI_MDRV_vTmpFree)( void * );
void (* GLI_MDRV_vErmPrintMsg)( char *, char *);
long (* GLI_MDRV_lComputeTexturesSize)( void );
void (* GLI_MDRV_vCompressTex565) ( GLI_tdstTexture *, void *);
void (* GLI_MDRV_vCompressTex4444 )( GLI_tdstTexture *, void *);
void (* GLI_MDRV_vCompressTex1555) ( GLI_tdstTexture *, void *);
void (* GLI_MDRV_vDivideBitmapSurfaceBy2) (unsigned long *,unsigned long *,long , long );
void (* GLI_MDRV_vDivideBitmapSurfaceBy2NonZero) (unsigned long *,unsigned long *,long , long , unsigned long ); /* G.CLEMENT 29/07/1999 : added chromakey */
void (* GLI_MDRV_vDivideBitmapSurfaceBy2Palette) (unsigned long *,unsigned long *,long , long );
unsigned long (* GLI_MDRV_vVerifyTextureIsRealyAlpha) ( GLI_tdstTexture * );
void (* GLI_MDRV_xLoadTextureInTexelField) (GLI_tdstTexture *, long *, BOOL);
void (* GLI_MDRV_vReloadTextures) (void);
long (* GLI_MDRV_lAddDisplayMode)( long , long , long, long );
//long (* GLI_MDRV_lDoDialogBoxLB)( char *, DLGPROC, long );
void (* GLI_MDRV_vUsePreCalculatedMipMaps) ( GLI_tdstTexture * , void ** , unsigned char *);
/*
* From GAM
*/
void (* GAM_MDRV_vReadInIniFile)( char *, char *, long, char *);
void (* GAM_MDRV_vWriteInIniFile) (char *, char *, char *);
/*
* From GLD
*/
void (* GLD_MDRV_vBlitStretched16b)( long , long , unsigned short *, long , long , long , unsigned short * );
GLD_tdstPixelFormat * (* GLD_MDRV_fn_p_stGetDefinedPixelFormat) ( long );
long (* GLD_MDRV_fn_lAddDefinedPixelFormat)( GLD_tdstPixelFormat * );
long (* GLD_MDRV_fn_lComputeWaitFrameForSmoothSynchro) ();
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifndef RETAIL
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
void (* GAM_MDRV_vShowRasters)();
void (* MMG_MDRV_vAddMemoryInfo)(long , long , void * ); /* Must be called before making a memory allocation*/
/*
* From PRF
*/
long (* PRF_MDRV_lIncIndependantVariable)(unsigned long , long );
void (* PRF_MDRV_vSetIndependantVariable)(unsigned long , long );
long (* PRF_MDRV_lGetIndependantVariable)(unsigned long );
void (* PRF_MDRV_vIncreaseVariable) (unsigned long , void *, unsigned long );
void (* PRF_MDRV_vResetVariable)( unsigned long );
void (* PRF_MDRV_vStopChrono )(unsigned long , void *);
void (* PRF_MDRV_vStartChrono ) (unsigned long , void *);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* BENCH_TEXTURE is defined or not in file TexBench.h
*/
#ifdef BENCH_TEXTURE
void (*GLI_MDRV_TEXBENCH_vSetTextureSize)( GLI_tdstTexture *, char, long);
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
void (* TMR_MDRV_vTimerGetCounter)( short, stTimerCount* );
unsigned long (* TMR_MDRV_ulTimerTickPerSecond)( short );
/*
=======================================================================================
DLL entry point
=======================================================================================
*/
/* specific function define for each display driver DLL*/
void fn_vInitDllIdentity();
BOOL __stdcall DllMain(HANDLE hModule, DWORD ulReasonForCall, LPVOID lpReserved)
{
fn_vInitDllIdentity();
return TRUE;
}
/*
=======================================================================================
Set Gli Common function
=======================================================================================
*/
long GLI_DRV_lGetDllInfo( char *_szName, void *_p_vData )
{
if ( strcmp(_szName, "Name") == 0) strcpy( (char *) _p_vData, g_stGliDrvId.szName );
else if( strcmp(_szName, "Description") == 0) strcpy( (char *) _p_vData, g_stGliDrvId.szDesc );
else if( strcmp(_szName, "Version") == 0) strcpy( (char *) _p_vData, g_stGliDrvId.szVersion );
else if( strcmp(_szName, "Code") == 0) *(unsigned long *)_p_vData = g_stGliDrvId.ulCode;
else
return 0;
return 1;
}
long GLI_DRV_lSetCommonData( char *_szName, void *_p_vData )
{
if ( strcmp(_szName, "GliDllInfo") == 0) GLI_gpst_DllInfo = (GLI_tdst_DllInfos *) _p_vData;//chbani
else if ( strcmp(_szName, "GliBigGlobals") == 0) GLI_BIG_GLOBALS = (GLI_tdstInternalGlobalValuesFor3dEngine *) _p_vData;
else if( strcmp(_szName, "TextureMemoryChannels") == 0) gs_aDEFTableOfTextureMemoryChannels = (long *) _p_vData;
else if( strcmp(_szName, "TextureAlreadyRead") == 0) gs_aDEFTableOfTextureAlreadyRead = (GLI_tdstTexture **) _p_vData;
else if( strcmp(_szName, "ConvertBufferMipMapping") == 0) GLI_gs_p_ConvertBufferMipMapping = _p_vData;
else if( strcmp(_szName, "RenderingCounterPointer") == 0) GLD_p_lRenderingCounter = (long *) _p_vData;
else if( strcmp(_szName, "DrawSem") == 0) g_p_vDrawSemaphore = _p_vData;
else if( strcmp(_szName, "GliCaps") == 0) g_p_stGliCaps = (tdstGliCaps *) _p_vData;
#ifdef GLI_BENCH
else if( strcmp(_szName, "GliBench") == 0) GLI_MDRV_g_p_stBench = (tdstGliBench *) _p_vData;
#endif
else
return 0;
return 1;
}
long GLI_DRV_lSetCommonFct( char *_szName, FARPROC _xFct )
{
if ( strcmp( _szName, "SetGlobalAlpha") == 0) GLI_MDRV_vSetGlobalAlpha = (void (__cdecl *) (float )) _xFct;
else if ( strcmp( _szName, "SerialProjection") == 0) GLI_MDRV_vSerialProjection = (void (__cdecl *) ( GLI_tdstCamera *, long , GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *)) _xFct;
else if ( strcmp( _szName, "IsGliInit") == 0) GLI_MDRV_xIsGliInit = (long (__cdecl *) (void)) _xFct;
else if ( strcmp( _szName, "TmpMalloc") == 0) GLI_MDRV_p_vTmpMalloc = (void *(__cdecl *) (unsigned long)) _xFct;
else if ( strcmp( _szName, "TmpFree") == 0) GLI_MDRV_vTmpFree = (void (__cdecl *) (void *)) _xFct;
else if ( strcmp( _szName, "ErmPrintMessage") == 0) GLI_MDRV_vErmPrintMsg = (void (__cdecl *) (char *, char *)) _xFct;
else if ( strcmp( _szName, "ComputeTextureSize") == 0) GLI_MDRV_lComputeTexturesSize = (long (__cdecl *) (void )) _xFct;
else if ( strcmp( _szName, "CompressTex565") == 0) GLI_MDRV_vCompressTex565 = (void (__cdecl *) (GLI_tdstTexture *, void *)) _xFct;
else if ( strcmp( _szName, "CompressTex4444") == 0) GLI_MDRV_vCompressTex4444 = (void (__cdecl *) (GLI_tdstTexture *, void *)) _xFct;
else if ( strcmp( _szName, "CompressTex1555") == 0) GLI_MDRV_vCompressTex1555 = (void (__cdecl *) (GLI_tdstTexture *, void *)) _xFct;
else if ( strcmp( _szName, "DivideBitmapSurfaceBy2") == 0) GLI_MDRV_vDivideBitmapSurfaceBy2 = (void (__cdecl *) (unsigned long *,unsigned long *,long , long )) _xFct;
else if ( strcmp( _szName, "DivideBitmapSurfaceBy2NonZero") == 0) GLI_MDRV_vDivideBitmapSurfaceBy2NonZero = (void (__cdecl *) (unsigned long *,unsigned long *,long , long , unsigned long )) _xFct;
else if ( strcmp( _szName, "DivideBitmapSurfaceBy2Palette") == 0) GLI_MDRV_vDivideBitmapSurfaceBy2Palette = (void (__cdecl *) (unsigned long *,unsigned long *,long , long )) _xFct;
else if ( strcmp( _szName, "VerifyTextureIsReallyAlpha") == 0) GLI_MDRV_vVerifyTextureIsRealyAlpha = (unsigned long (__cdecl *) (GLI_tdstTexture * )) _xFct;
else if ( strcmp( _szName, "LoadTextureInTexelField") == 0) GLI_MDRV_xLoadTextureInTexelField = (void (__cdecl *) (GLI_tdstTexture *, long *, BOOL)) _xFct;
else if ( strcmp( _szName, "ReloadTextures") == 0) GLI_MDRV_vReloadTextures = (void (__cdecl *) (void)) _xFct;
else if ( strcmp( _szName, "AddDisplayMode") == 0) GLI_MDRV_lAddDisplayMode = (long (__cdecl *)(long, long, long, long)) _xFct;
//else if ( strcmp( _szName, "DoDialogLB") == 0) GLI_MDRV_lDoDialogBoxLB = (long (__cdecl *)(char *, DLGPROC, long)) _xFct;
else if ( strcmp( _szName, "BlitStretched16b") == 0) GLD_MDRV_vBlitStretched16b = (void (__cdecl *) (long , long , unsigned short *, long , long , long , unsigned short *)) _xFct;
else if ( strcmp( _szName, "GetDefinedPixelFormat") == 0) GLD_MDRV_fn_p_stGetDefinedPixelFormat = (GLD_tdstPixelFormat *(__cdecl *) ( long )) _xFct;
else if ( strcmp( _szName, "AddDefinedPixelFormat") == 0) GLD_MDRV_fn_lAddDefinedPixelFormat = (long (__cdecl *) ( GLD_tdstPixelFormat * )) _xFct;
else if ( strcmp( _szName, "ComputeWaitFrameForSmoothSynchro") == 0) GLD_MDRV_fn_lComputeWaitFrameForSmoothSynchro = (long (__cdecl *) ( void )) _xFct;
else if ( strcmp( _szName, "ReadIniString") == 0) GAM_MDRV_vReadInIniFile = (void (__cdecl *) (char *, char *, long, char *)) _xFct;
else if ( strcmp( _szName, "WriteIniString") == 0) GAM_MDRV_vWriteInIniFile = (void (__cdecl *) (char *, char *, char *)) _xFct;
else if ( strcmp( _szName, "UseMipMaps") == 0) GLI_MDRV_vUsePreCalculatedMipMaps = (void (__cdecl *) ( GLI_tdstTexture * , void *, unsigned char * )) _xFct;
#ifndef RETAIL
else if ( strcmp( _szName, "ShowRasters") == 0) GAM_MDRV_vShowRasters = (void (__cdecl *) (void)) _xFct;
else if ( strcmp( _szName, "AddMemoryInfo") == 0) MMG_MDRV_vAddMemoryInfo = (void (__cdecl *) (long, long, void *)) _xFct;
else if ( strcmp( _szName, "IncIndependantVariable") == 0) PRF_MDRV_lIncIndependantVariable = (long (__cdecl *) (unsigned long, long)) _xFct;
else if ( strcmp( _szName, "SetIndependantVariable") == 0) PRF_MDRV_vSetIndependantVariable = (void (__cdecl *) (unsigned long, long)) _xFct;
else if ( strcmp( _szName, "GetIndependantVariable") == 0) PRF_MDRV_lGetIndependantVariable = (long (__cdecl *) (unsigned long)) _xFct;
else if ( strcmp( _szName, "IncreaseVariable") == 0) PRF_MDRV_vIncreaseVariable = (void (__cdecl *) (unsigned long , void *, unsigned long)) _xFct;
else if ( strcmp( _szName, "ResetVariable") == 0) PRF_MDRV_vResetVariable = (void (__cdecl *) (unsigned long)) _xFct;
else if ( strcmp( _szName, "StopChrono") == 0) PRF_MDRV_vStopChrono = (void (__cdecl *) (unsigned long , void *)) _xFct;
else if ( strcmp( _szName, "StartChrono") == 0) PRF_MDRV_vStartChrono = (void (__cdecl *) (unsigned long , void *)) _xFct;
#endif
#ifdef BENCH_TEXTURE
else if (strcmp( _szName, "TexBenchSetTextureSize") == 0 ) GLI_MDRV_TEXBENCH_vSetTextureSize = (void (__cdecl *) (GLI_tdstTexture *, char, long) ) _xFct;
#endif
else if(strcmp( _szName, "TimerGetCounter") == 0 ) TMR_MDRV_vTimerGetCounter = (void (__cdecl *) ( short, stTimerCount* ) ) _xFct;
else if(strcmp( _szName, "TimerTickPerSecond") == 0 ) TMR_MDRV_ulTimerTickPerSecond = (unsigned long (__cdecl *) ( short ) ) _xFct;
else
return 0;
return 1;
}

View File

@@ -0,0 +1,171 @@
#ifndef __DLL_H__
#define __DLL_H__
#define GLI_INTERFACE_FUNC(a) a
#include "vertex.h"
#include "PvObj_st.h"
#include "Camera.h"
#include "DLLCaps.h"
#include "TexBench.h"
#include "TMR.h"
/*
=======================================================================================
DLL identity structure
=======================================================================================
*/
typedef struct tdstGliDriverIdentity_
{
char szName[64];
char szDesc[256];
char szVersion[16];
unsigned long ulCode;
} tdstGliDriverIdentity;
/*
=======================================================================================
Globals
=======================================================================================
*/
extern tdstGliDriverIdentity g_stGliDrvId;
extern tdstGliCaps *g_p_stGliCaps;
typedef struct GLI_tdst_DllInfos_
{
HINSTANCE h_Module;
char sz_Name[64];
char sz_Desc[256];
char sz_Version[16];
unsigned long ul_Code;
char sz_FileName[ _MAX_PATH ];
char sz_DriverName[ 32 ];
char sz_DeviceName[ 32 ];
long l_InitWidth;
long l_InitHeight;
long l_InitFullScreen;
long l_InitBpp;
long l_RealWidth;
long l_RealHeight;
float f_WidthRatio;
float f_HeightRatio;
} GLI_tdst_DllInfos;
extern GLI_tdst_DllInfos GLI_gst_DllInfo; //chbani
/*
=======================================================================================
imported object (Have to be initialized)
=======================================================================================
*/
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
extern long *gs_aDEFTableOfTextureMemoryChannels;
extern GLI_tdstTexture **gs_aDEFTableOfTextureAlreadyRead;
extern void *GLI_gs_p_ConvertBufferMipMapping;
extern long *GLD_p_lRenderingCounter;
extern void *g_p_vDrawSemaphore;
/*
=======================================================================================
imported function (Have to be initialized)
=======================================================================================
*/
/*
* From GLI
*/
extern void (* GLI_MDRV_vSetGlobalAlpha)( float );
extern void (* GLI_MDRV_vSerialProjection)( GLI_tdstCamera *, long , GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *);
extern long (* GLI_MDRV_xIsGliInit)();
extern void *(*GLI_MDRV_p_vTmpMalloc)( unsigned long );
extern void (*GLI_MDRV_vTmpFree)( void * );
extern void (* GLI_MDRV_vErmPrintMsg)( char *, char *);
extern long (* GLI_MDRV_lComputeTexturesSize)( void );
extern void (* GLI_MDRV_vCompressTex565) ( GLI_tdstTexture *, void *);
extern void (* GLI_MDRV_vCompressTex4444 )( GLI_tdstTexture *, void *);
extern void (* GLI_MDRV_vCompressTex1555) ( GLI_tdstTexture *, void *);
extern void (* GLI_MDRV_vDivideBitmapSurfaceBy2) (unsigned long *,unsigned long *,long , long );
extern void (* GLI_MDRV_vDivideBitmapSurfaceBy2NonZero) (unsigned long *,unsigned long *,long , long , unsigned long);
extern void (* GLI_MDRV_vDivideBitmapSurfaceBy2Palette) (unsigned long *,unsigned long *,long , long );
extern unsigned long (* GLI_MDRV_vVerifyTextureIsRealyAlpha) ( GLI_tdstTexture * );
extern void (* GLI_MDRV_xLoadTextureInTexelField) (GLI_tdstTexture *, long *, BOOL);
extern void (* GLI_MDRV_vReloadTextures) (void);
extern long (* GLI_MDRV_lAddDisplayMode)( long , long , long, long );
//extern long (* GLI_MDRV_lDoDialogBoxLB)( char *, DLGPROC, long );
extern void (* GLI_MDRV_vUsePreCalculatedMipMaps)( GLI_tdstTexture * , void **, unsigned char *);
/*
* From GLD
*/
extern void (* GLD_MDRV_vBlitStretched16b)( long , long , unsigned short *, long , long , long , unsigned short * );
extern GLD_tdstPixelFormat * (* GLD_MDRV_fn_p_stGetDefinedPixelFormat) ( long );
extern long (* GLD_MDRV_fn_lAddDefinedPixelFormat)( GLD_tdstPixelFormat * );
extern long (* GLD_MDRV_fn_lComputeWaitFrameForSmoothSynchro) ();
/*
* From GAM
*/
extern void (* GAM_MDRV_vReadInIniFile)( char *, char *, long, char *);
extern void (* GAM_MDRV_vWriteInIniFile) (char *, char *, char *);
extern void (* TMR_MDRV_vTimerGetCounter)( short, stTimerCount* );
extern unsigned long (* TMR_MDRV_ulTimerTickPerSecond)( short );
/*
=======================================================================================
imported function for Not retail version
=======================================================================================
*/
#ifndef RETAIL
extern void (* GAM_MDRV_vShowRasters)();
extern void (* MMG_MDRV_vAddMemoryInfo)(long , long , void * ); /* Must be called before making a memory allocation*/
/*
* From PRF
*/
extern long (* PRF_MDRV_lIncIndependantVariable)(unsigned long , long );
extern void (* PRF_MDRV_vSetIndependantVariable)(unsigned long , long );
extern long (* PRF_MDRV_lGetIndependantVariable)(unsigned long );
extern void (* PRF_MDRV_vIncreaseVariable) (unsigned long , void *, unsigned long );
extern void (* PRF_MDRV_vResetVariable)( unsigned long );
extern void (* PRF_MDRV_vStopChrono )(unsigned long , void *);
extern void (* PRF_MDRV_vStartChrono ) (unsigned long , void *);
#else
#define GAM_MDRV_vShowRasters()
#define MMG_MDRV_vAddMemoryInfo(a, b, c )
#define PRF_MDRV_lIncIndependantVariable(a,b)
#define PRF_MDRV_vSetIndependantVariable(a,b)
#define PRF_MDRV_lGetIndependantVariable(a) 0
#define PRF_MDRV_vIncreaseVariable(a,b,c)
#define PRF_MDRV_vResetVariable(a)
#define PRF_MDRV_vStopChrono(a,b)
#define PRF_MDRV_vStartChrono(a,b)
#endif
/*
* BENCH_TEXTURE is defined or not in file TexBench.h
*/
#ifdef BENCH_TEXTURE
extern void (*GLI_MDRV_TEXBENCH_vSetTextureSize)( GLI_tdstTexture *, char, long);
#else
#define GLI_MDRV_TEXBENCH_vSetTextureSize(a,b,c)
#endif /* BENCH_TEXTURE */
#endif /*__DLL_H__*/

View File

@@ -0,0 +1,218 @@
# Microsoft Developer Studio Project File - Name="Glide2" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=Glide2 - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Glide2.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Glide2.mak" CFG="Glide2 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Glide2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Glide2 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Glide2 - Win32 Retail" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""$/cpa/tempgrp/GliGlou/Drivers/GLIDE2", MVPAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "Glide2 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "temp\Release"
# PROP Intermediate_Dir "temp\Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /I "t:\mssdk\include" /D "NDEBUG" /D "_WINDOWS" /D "USE_PROFILER" /D "GLIDE2" /D "WIN32" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"x:\cpa\exe\main\dll\GliVD1vr.dll"
!ELSEIF "$(CFG)" == "Glide2 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "temp\Debug"
# PROP Intermediate_Dir "temp\Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /I "t:\mssdk\include" /D "_DEBUG" /D "VISUAL" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /D "GLIDE2" /D "WIN32" /U "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /U "x:\cpa\public" /U "x:\cpa\public\gli" /U "x:\cpa\public\geo" /U "inc" /U "x:\cpa\tempgrp\gliglou\multidrv\inc" /U "..\\" /U "t:\mssdk\include" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"x:\cpa\exe\main\dll\GliVD1vd.dll" /pdbtype:sept
!ELSEIF "$(CFG)" == "Glide2 - Win32 Retail"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Glide2__"
# PROP BASE Intermediate_Dir "Glide2__"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Temp\Retail"
# PROP Intermediate_Dir "Temp\Retail"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /D "NDEBUG" /D "_WINDOWS" /D "RETAIL" /D "GLIDE2" /D "WIN32" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"x:\cpa\exe\main\dll\GliVd1vf.dll"
!ENDIF
# Begin Target
# Name "Glide2 - Win32 Release"
# Name "Glide2 - Win32 Debug"
# Name "Glide2 - Win32 Retail"
# Begin Group "Src"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Acces_ALL.c
!IF "$(CFG)" == "Glide2 - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "Glide2 - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "Glide2 - Win32 Retail"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\Src\Acces_GLIDE2.c
!IF "$(CFG)" == "Glide2 - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "Glide2 - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "Glide2 - Win32 Retail"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\ClipTRIANGLES.c
# End Source File
# Begin Source File
SOURCE=..\DllCom.c
# End Source File
# Begin Source File
SOURCE=.\Src\Domat_GLIDE2.c
# End Source File
# Begin Source File
SOURCE=.\Src\Glide2_Dll.c
# End Source File
# Begin Source File
SOURCE=..\GliDLL.def
# End Source File
# Begin Source File
SOURCE=.\Src\HdwTx_GL2.c
# End Source File
# Begin Source File
SOURCE=.\Src\Init_Glide2.c
# End Source File
# End Group
# Begin Group "inc"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\DllCom.h
# End Source File
# Begin Source File
SOURCE=.\inc\TextuDFX.h
# End Source File
# End Group
# Begin Group "lib"
# PROP Default_Filter ""
# Begin Source File
SOURCE=T:\dxsdk\sdk\lib\ddraw.lib
# End Source File
# Begin Source File
SOURCE=T:\3Dfx\Glide\Lib\Win32\glide2x.lib
# End Source File
# End Group
# Begin Source File
SOURCE=.\Glide2.mak
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Glide2", "Glide2.vcproj", "{56221F12-25E8-4E3F-9531-D243ABEB657C}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SourceCodeControl) = preSolution
SccNumberOfProjects = 1
SccProjectUniqueName0 = Glide2.vcproj
SccProjectName0 = \u0022$/cpa/tempgrp/GliGlou/Drivers/GLIDE2\u0022,\u0020MVPAAAAA
SccLocalPath0 = .
SccProvider0 = MSSCCI:NXN\u0020alienbrain
EndGlobalSection
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
Retail = Retail
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{56221F12-25E8-4E3F-9531-D243ABEB657C}.Debug.ActiveCfg = Debug|Win32
{56221F12-25E8-4E3F-9531-D243ABEB657C}.Debug.Build.0 = Debug|Win32
{56221F12-25E8-4E3F-9531-D243ABEB657C}.Release.ActiveCfg = Release|Win32
{56221F12-25E8-4E3F-9531-D243ABEB657C}.Release.Build.0 = Release|Win32
{56221F12-25E8-4E3F-9531-D243ABEB657C}.Retail.ActiveCfg = Retail|Win32
{56221F12-25E8-4E3F-9531-D243ABEB657C}.Retail.Build.0 = Retail|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

Binary file not shown.

View File

@@ -0,0 +1,472 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="Glide2"
ProjectGUID="{56221F12-25E8-4E3F-9531-D243ABEB657C}"
SccProjectName="&quot;$/cpa/tempgrp/GliGlou/Drivers/GLIDE2&quot;, MVPAAAAA"
SccLocalPath=".">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\temp\Debug"
IntermediateDirectory=".\temp\Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="c:\3dFX\GLIDE\SRC\SST1\INCLUDE,x:\cpa\public,x:\cpa\public\gli,x:\cpa\public\geo,inc,x:\cpa\tempgrp\gliglou\multidrv\inc,..\"
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;GLIDE2;WIN32"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\temp\Debug/Glide2.pch"
AssemblerListingLocation=".\temp\Debug/"
ObjectFile=".\temp\Debug/"
ProgramDataBaseFileName=".\temp\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"
UndefinePreprocessorDefinitions="t:\3dFX\GLIDE\SRC\SST1\INCLUDE,x:\cpa\public,x:\cpa\public\gli,x:\cpa\public\geo,inc,x:\cpa\tempgrp\gliglou\multidrv\inc,..\,t:\mssdk\include"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ddraw.lib glide2x.lib"
OutputFile="x:\cpa\exe\main\dll\GliVD1vd.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="C:\3Dfx\Glide\Lib\Win32"
ModuleDefinitionFile="..\GliDLL.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\temp\Debug/GliVD1vd.pdb"
SubSystem="2"
ImportLibrary=".\temp\Debug/GliVD1vd.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\temp\Debug/Glide2.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\temp\Release"
IntermediateDirectory=".\temp\Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="t:\3dFX\GLIDE\SRC\SST1\INCLUDE,x:\cpa\public,x:\cpa\public\gli,x:\cpa\public\geo,inc,x:\cpa\tempgrp\gliglou\multidrv\inc,..\,t:\mssdk\include"
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;GLIDE2;WIN32"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\temp\Release/Glide2.pch"
AssemblerListingLocation=".\temp\Release/"
ObjectFile=".\temp\Release/"
ProgramDataBaseFileName=".\temp\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="x:\cpa\exe\main\dll\GliVD1vr.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile="..\GliDLL.def"
ProgramDatabaseFile=".\temp\Release/GliVD1vr.pdb"
SubSystem="2"
ImportLibrary=".\temp\Release/GliVD1vr.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\temp\Release/Glide2.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Retail|Win32"
OutputDirectory=".\Temp\Retail"
IntermediateDirectory=".\Temp\Retail"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="t:\3dFX\GLIDE\SRC\SST1\INCLUDE,x:\cpa\public,x:\cpa\public\gli,x:\cpa\public\geo,inc,x:\cpa\tempgrp\gliglou\multidrv\inc,..\"
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;GLIDE2;WIN32"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Temp\Retail/Glide2.pch"
AssemblerListingLocation=".\Temp\Retail/"
ObjectFile=".\Temp\Retail/"
ProgramDataBaseFileName=".\Temp\Retail/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="x:\cpa\exe\main\dll\GliVd1vf.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile="..\GliDLL.def"
ProgramDatabaseFile=".\Temp\Retail/GliVd1vf.pdb"
SubSystem="2"
ImportLibrary=".\Temp\Retail/GliVd1vf.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Temp\Retail/Glide2.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Src"
Filter="">
<File
RelativePath="..\Acces_ALL.c">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;GLIDE2;WIN32;$(NoInherit)"
UndefinePreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="Src\Acces_GLIDE2.c">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;GLIDE2;WIN32;$(NoInherit)"
UndefinePreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="..\ClipTRIANGLES.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;GLIDE2;WIN32;$(NoInherit)"
UndefinePreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="..\DllCom.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;GLIDE2;WIN32;$(NoInherit)"
UndefinePreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="Src\Domat_GLIDE2.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;GLIDE2;WIN32;$(NoInherit)"
UndefinePreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="Src\Glide2_Dll.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;GLIDE2;WIN32;$(NoInherit)"
UndefinePreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="..\GliDLL.def">
</File>
<File
RelativePath="Src\HdwTx_GL2.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;GLIDE2;WIN32;$(NoInherit)"
UndefinePreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
</File>
<File
RelativePath="Src\Init_Glide2.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_DEBUG;VISUAL;USE_PROFILER;MTH_CHECK;CPA_WANTS_EXPORT;GLIDE2;WIN32;$(NoInherit)"
UndefinePreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;USE_PROFILER;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Retail|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="NDEBUG;_WINDOWS;RETAIL;GLIDE2;WIN32;$(NoInherit)"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="inc"
Filter="">
<File
RelativePath="..\DllCom.h">
</File>
<File
RelativePath="inc\TextuDFX.h">
</File>
</Filter>
<Filter
Name="lib"
Filter="">
</Filter>
<File
RelativePath="Glide2.mak">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,838 @@
/*
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Macro and function that manage with Glide2 vertex
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
#define __MSC__
#include <GLIDE.H>
#include "TextuDFX.h"
#include "PRF.h"
#include "GliBench.h"
/* #include "drawflags.h" */
/* Globals */
#define GLI_GLIDE1_CurrentTmu 0
GrChipID_t GLI_GLIDE1_xTmuNumber = 0;
void GLI_DRV_xSendSpriteToClip_TRIANGLES
(
GLI_tdstAligned2DVector *a4_st2DVertex,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT
);
#define GLI_tdScreenVertx GrVertex
GrVertex CurrentDestXYZ[4];
#define GLI_C_3dfxBugConstant 65536.0f * 8.0f
/* Vertex Access Macros */
/*
===================================================================================================
GET
===================================================================================================
*/
#define GetX(a) a.x
#define GetY(a) a.y
#define GetZ(a) a.oow
#define GetPackedColor(a) * (unsigned long *) &a.r
#define GetPackedSpecular(a, b)
#define GetU(a) a.tmuvtx[GLI_GLIDE1_xTmuNumber].sow
#define GetV(a) a.tmuvtx[GLI_GLIDE1_xTmuNumber].tow
/*
===================================================================================================
SET
===================================================================================================
*/
#define SetX(a, b) a.x = b
#define SetY(a, b) a.y = b
#define SetZ(a, b) a.oow = b
#define SetPackedColor(a, b) * (unsigned long *) &a.r = b
/*$F #define SetPackedSpecular(a,b) *(unsigned long *)&a.g = b */
#define SetPackedSpecular(a, b)
#define SetU(a, b) a.tmuvtx[GLI_GLIDE1_xTmuNumber].sow = b
#define SetV(a, b) a.tmuvtx[GLI_GLIDE1_xTmuNumber].tow = b
#define SetU_Cpy(a, b) (*(unsigned long *) &a.tmuvtx[GLI_GLIDE1_xTmuNumber].sow = *(unsigned long *) &b)
#define SetV_Cpy(a, b) (*(unsigned long *) &a.tmuvtx[GLI_GLIDE1_xTmuNumber].tow = *(unsigned long *) &b)
/* Constante <20> ne d<>finir que pour d<>bugger ou pour anti_bug temporaire */
/* #define GLI_DEBUG_TESTALLVERTICES */
#ifdef GLI_BENCH
void BENCH_M_Triangle( GrVertex *a, GrVertex *b, GrVertex *c )
{
/*
* compute triangle surface
*/
float xb, xc, yb, yc;
long surface;
xb = GetX( (*b) ) - GetX( (*a) );
yb = GetY( (*b) ) - GetY( (*a) );
xc = GetX( (*c) ) - GetX( (*a) );
yc = GetY( (*c) ) - GetY( (*a) );
surface = (long) ceil((fabs( (xb * yc) - (xc * yb) ) / 2));
if (surface> 1023)
surface= 1023;
GLI_MDRV_g_p_stBench->lTrianglePerSurface[ surface ]++;
}
#else
#define BENCH_M_Triangle(a,b,c)
#endif
#if defined(USE_PROFILER) && !defined(PRESS_DEMO)
#define M_grDrawTriangle(a, b, c) \
{ \
BENCH_M_Triangle( (a), (b), (c) );\
grDrawTriangle((a), (b), (c)); \
PRF_MDRV_vSetIndependantVariable(PRF_C_ulIdpDisplayedTriangle, 1); \
}
#else
#define M_grDrawTriangle grDrawTriangle
#endif
#define GLI_M_RestoreCW()
/*
===================================================================================================
function called before displayind severall triangle with same render states
===================================================================================================
*/
void GLI_BeforeDraw(void)
{
};
/*
===================================================================================================
function called after displaying severall triangle with same render states
===================================================================================================
*/
void GLI_AfterDraw(void)
{
}
#define GLI_M_Correct3DFXBug2(a) \
{ \
a.x -= GLI_C_3dfxBugConstant; \
a.y -= GLI_C_3dfxBugConstant; \
}
#define GLI_M_Correct3DFXBug1(a) \
{ \
a.x += GLI_C_3dfxBugConstant; \
a.y += GLI_C_3dfxBugConstant; \
}
/*
===================================================================================================
Correct Glide 2 bug
===================================================================================================
*/
void GLI_fn_vCorrect3DFXBug1(GrVertex *a)
{
a->x += GLI_C_3dfxBugConstant;
a->y += GLI_C_3dfxBugConstant;
}
#define GLI_M_Restore3DFXColor(P) \
{ \
P.g = (float) ((unsigned char *) &(P.r))[1]; \
P.b = (float) ((unsigned char *) &(P.r))[0]; \
P.a = (float) ((unsigned char *) &(P.r))[3]; \
P.r = (float) ((unsigned char *) &(P.r))[2]; \
P.tmuvtx[GLI_GLIDE1_xTmuNumber].sow *= P.oow * GLI_BIG_GLOBALS->fMulV; \
P.tmuvtx[GLI_GLIDE1_xTmuNumber].tow *= P.oow * GLI_BIG_GLOBALS->fMulU; \
}
/*
===================================================================================================
Draw normal triangle
===================================================================================================
*/
GLI_FuncNodeBegin(GLI_vDrawTriangle)
{
/* 3DFX BUG */
GLI_M_Correct3DFXBug2(CurrentDestXYZ[0]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[1]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[2]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[0]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[1]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[2]);
#ifdef GLI_DEBUG_TESTALLVERTICES
if
(
(CurrentDestXYZ[0].y < 0.0f) ||
(CurrentDestXYZ[1].y < 0.0f) ||
(CurrentDestXYZ[2].y < 0.0f) ||
(CurrentDestXYZ[0].y > 480.0f) ||
(CurrentDestXYZ[1].y > 480.0f) ||
(CurrentDestXYZ[2].y > 480.0f) ||
(CurrentDestXYZ[0].x < 0.0f) ||
(CurrentDestXYZ[1].x < 0.0f) ||
(CurrentDestXYZ[2].x < 0.0f) ||
(CurrentDestXYZ[0].x > 640.0f) ||
(CurrentDestXYZ[1].x > 640.0f) ||
(CurrentDestXYZ[2].x > 640.0f)
) return;
#endif
M_grDrawTriangle(&CurrentDestXYZ[0], &CurrentDestXYZ[1], &CurrentDestXYZ[2]);
}
/*
===================================================================================================
draw wired triangle
===================================================================================================
*/
GLI_FuncNodeBegin(GLI_vDrawWiredTriangle)
{
/* 3DFX BUG */
GLI_M_Correct3DFXBug2(CurrentDestXYZ[0]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[1]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[2]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[0]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[1]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[2]);
#ifdef GLI_DEBUG_TESTALLVERTICES
if
(
(CurrentDestXYZ[0].y < 0.0f) ||
(CurrentDestXYZ[1].y < 0.0f) ||
(CurrentDestXYZ[2].y < 0.0f) ||
(CurrentDestXYZ[0].y > 480.0f) ||
(CurrentDestXYZ[1].y > 480.0f) ||
(CurrentDestXYZ[2].y > 480.0f) ||
(CurrentDestXYZ[0].x < 0.0f) ||
(CurrentDestXYZ[1].x < 0.0f) ||
(CurrentDestXYZ[2].x < 0.0f) ||
(CurrentDestXYZ[0].x > 640.0f) ||
(CurrentDestXYZ[1].x > 640.0f) ||
(CurrentDestXYZ[2].x > 640.0f)
) return;
#endif
grDrawLine(&CurrentDestXYZ[0], &CurrentDestXYZ[1]);
grDrawLine(&CurrentDestXYZ[1], &CurrentDestXYZ[2]);
grDrawLine(&CurrentDestXYZ[0], &CurrentDestXYZ[2]);
}
/*
===================================================================================================
correct Glide2 bug
===================================================================================================
*/
GLI_FuncNodeBegin(GLI_vCorrect3DFXBug1)
{
/* 3DFX BUG */
GLI_M_Correct3DFXBug1(CurrentDestXYZ[0]);
GLI_M_Correct3DFXBug1(CurrentDestXYZ[1]);
GLI_M_Correct3DFXBug1(CurrentDestXYZ[2]);
GLI_M_CallNextFunc();
}
/*
===================================================================================================
sort translucent triangle
===================================================================================================
*/
GLI_FuncNodeBegin(GLI_vZSortTriangle)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
float ZMax;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if
(
(unsigned long) GLI_BIG_GLOBALS->p_TheZListe->p_CurrentPoint >
(unsigned long) GLI_BIG_GLOBALS->p_TheZListe->p_TableOfPoints + ((3L << GLI_MaxZListeTrianglesPO2) * sizeof(GrVertex)) - 3L * sizeof(GrVertex)
)
return;
/* 3DFX BUG */
GLI_M_Correct3DFXBug2(CurrentDestXYZ[0]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[1]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[2]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[0]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[1]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[2]);
memcpy(GLI_BIG_GLOBALS->p_TheZListe->p_CurrentPoint, CurrentDestXYZ, sizeof(GrVertex) * 3L);
if(*(unsigned long *) &GetZ(CurrentDestXYZ[0]) < *(unsigned long *) &GetZ(CurrentDestXYZ[1]))
*(unsigned long *) &ZMax = *(unsigned long *) &GetZ(CurrentDestXYZ[0]);
else
*(unsigned long *) &ZMax = *(unsigned long *) &GetZ(CurrentDestXYZ[1]);
if(*(unsigned long *) &ZMax > *(unsigned long *) &GetZ(CurrentDestXYZ[2]))
*(unsigned long *) &ZMax = *(unsigned long *) &GetZ(CurrentDestXYZ[2]);
GLI_v_AddNodeInZList(ZMax);
(unsigned long) GLI_BIG_GLOBALS->p_TheZListe->p_CurrentPoint += sizeof(GrVertex) * 3L;
#if !defined(PRESS_DEMO)
PRF_MDRV_vSetIndependantVariable(PRF_C_ulIdpDisplayedTriangle, 1);
#endif /* PRESS_DEMO */
}
/*$F
===================================================================================================
Description:: draw a quad stored in CurrentDestXYZ array or add it in Z list
1 0
| /| Send two triangle:: 0 1 2 and 3 2 0
| / |
|/ |
2 3
===================================================================================================
*/
void GLI_DrawQuad(void)
{
/* Draw 2 triangles */
GLI_fn_vCorrect3DFXBug1(&CurrentDestXYZ[0]);
GLI_fn_vCorrect3DFXBug1(&CurrentDestXYZ[1]);
GLI_fn_vCorrect3DFXBug1(&CurrentDestXYZ[2]);
GLI_fn_vCorrect3DFXBug1(&CurrentDestXYZ[3]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[0]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[1]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[2]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[3]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[0]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[1]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[2]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[3]);
if(GLI_BIG_GLOBALS->lClippingModeMask & GLI_C_TrianglesMustBeSorted)
{
GLI_BIG_GLOBALS->lCurrentDrawMask &= ~GLI_C_lIsGouraud;
if
(
(unsigned long) GLI_BIG_GLOBALS->p_TheZListe->p_CurrentPoint >
(unsigned long) GLI_BIG_GLOBALS->p_TheZListe->p_TableOfPoints + ((3L << GLI_MaxZListeTrianglesPO2) * sizeof(GrVertex)) - 4L * sizeof(GrVertex)
)
return;
memcpy(GLI_BIG_GLOBALS->p_TheZListe->p_CurrentPoint, CurrentDestXYZ, sizeof(GrVertex) * 4L);
GLI_v_AddNodeInZList(GetZ(CurrentDestXYZ[0]));
(unsigned long) GLI_BIG_GLOBALS->p_TheZListe->p_CurrentPoint += sizeof(GrVertex) * 4L;
}
else
{
#ifdef GLI_DEBUG_TESTALLVERTICES
if
(
(CurrentDestXYZ[0].y < 0.0f) ||
(CurrentDestXYZ[1].y < 0.0f) ||
(CurrentDestXYZ[2].y < 0.0f) ||
(CurrentDestXYZ[3].y < 0.0f) ||
(CurrentDestXYZ[0].y > 480.0f) ||
(CurrentDestXYZ[1].y > 480.0f) ||
(CurrentDestXYZ[2].y > 480.0f) ||
(CurrentDestXYZ[3].y > 480.0f) ||
(CurrentDestXYZ[0].x < 0.0f) ||
(CurrentDestXYZ[1].x < 0.0f) ||
(CurrentDestXYZ[2].x < 0.0f) ||
(CurrentDestXYZ[3].x < 0.0f) ||
(CurrentDestXYZ[0].x > 640.0f) ||
(CurrentDestXYZ[1].x > 640.0f) ||
(CurrentDestXYZ[2].x > 640.0f) ||
(CurrentDestXYZ[3].x > 640.0f)
) return;
#endif
M_grDrawTriangle(&CurrentDestXYZ[0], &CurrentDestXYZ[1], &CurrentDestXYZ[2]);
M_grDrawTriangle(&CurrentDestXYZ[3], &CurrentDestXYZ[2], &CurrentDestXYZ[0]);
#if !defined(PRESS_DEMO)
PRF_MDRV_vIncreaseVariable
(
PRF_C_ulVarFaces + PRF_MDRV_lGetIndependantVariable(PRF_C_ulIdpDynOrSta),
PRF_C_pvDisplayed,
2
);
PRF_MDRV_vSetIndependantVariable(PRF_C_ulIdpDisplayedFaces, 1);
#endif /* PRESS_DEMO */
}
}
/*
===================================================================================================
Description:: Draw a line
===================================================================================================
*/
void GLI_DrawLine(void)
{
GLI_fn_vCorrect3DFXBug1(&CurrentDestXYZ[0]);
GLI_fn_vCorrect3DFXBug1(&CurrentDestXYZ[1]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[0]);
GLI_M_Correct3DFXBug2(CurrentDestXYZ[1]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[0]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[1]);
#ifdef GLI_DEBUG_TESTALLVERTICES
if
(
(CurrentDestXYZ[0].y < 0.0f) ||
(CurrentDestXYZ[1].y < 0.0f) ||
(CurrentDestXYZ[0].y > 480.0f) ||
(CurrentDestXYZ[1].y > 480.0f) ||
(CurrentDestXYZ[0].x < 0.0f) ||
(CurrentDestXYZ[1].x < 0.0f) ||
(CurrentDestXYZ[0].x > 640.0f) ||
(CurrentDestXYZ[1].x > 640.0f)
) return;
#endif
grDrawLine(&CurrentDestXYZ[0], &CurrentDestXYZ[1]);
}
/*
===================================================================================================
Description:: draw Zsorted triangle
===================================================================================================
*/
void GLI_vDrawZSortedTriangle(void *p_3Point)
{
#ifdef GLI_DEBUG_TESTALLVERTICES
if
(
(((GrVertex *) p_3Point)->y < 0.0f) ||
(((GrVertex *) p_3Point + 1)->y < 0.0f) ||
(((GrVertex *) p_3Point + 2)->y < 0.0f) ||
(((GrVertex *) p_3Point)->y > 480.0f) ||
(((GrVertex *) p_3Point + 1)->y > 480.0f) ||
(((GrVertex *) p_3Point + 2)->y > 480.0f) ||
(((GrVertex *) p_3Point)->x < 0.0f) ||
(((GrVertex *) p_3Point + 1)->x < 0.0f) ||
(((GrVertex *) p_3Point + 2)->x < 0.0f) ||
(((GrVertex *) p_3Point)->x > 640.0f) ||
(((GrVertex *) p_3Point + 1)->x > 640.0f) ||
(((GrVertex *) p_3Point + 2)->x > 640.0f)
) return;
#endif
//grDrawTriangle((GrVertex *) p_3Point, ((GrVertex *) p_3Point) + 1, ((GrVertex *) p_3Point) + 2);
M_grDrawTriangle((GrVertex *) p_3Point, ((GrVertex *) p_3Point) + 1, ((GrVertex *) p_3Point) + 2);
}
/*
===================================================================================================
Description:: draw ZSorted quad
===================================================================================================
*/
void GLI_vDrawZSortedQuad(void *p_3Point)
{
#ifdef GLI_DEBUG_TESTALLVERTICES
if
(
(((GrVertex *) p_3Point)->y < 0.0f) ||
(((GrVertex *) p_3Point + 1)->y < 0.0f) ||
(((GrVertex *) p_3Point + 2)->y < 0.0f) ||
(((GrVertex *) p_3Point + 3)->y < 0.0f) ||
(((GrVertex *) p_3Point)->y > 480.0f) ||
(((GrVertex *) p_3Point + 1)->y > 480.0f) ||
(((GrVertex *) p_3Point + 2)->y > 480.0f) ||
(((GrVertex *) p_3Point + 3)->y > 480.0f) ||
(((GrVertex *) p_3Point)->x < 0.0f) ||
(((GrVertex *) p_3Point + 1)->x < 0.0f) ||
(((GrVertex *) p_3Point + 2)->x < 0.0f) ||
(((GrVertex *) p_3Point + 3)->x < 0.0f) ||
(((GrVertex *) p_3Point)->x > 640.0f) ||
(((GrVertex *) p_3Point + 1)->x > 640.0f) ||
(((GrVertex *) p_3Point + 2)->x > 640.0f) ||
(((GrVertex *) p_3Point + 3)->x > 640.0f)
) return;
#endif
M_grDrawTriangle((GrVertex *) p_3Point, ((GrVertex *) p_3Point) + 1, ((GrVertex *) p_3Point) + 2);
M_grDrawTriangle
(
((GrVertex *) p_3Point) + 3,
((GrVertex *) p_3Point) + 2,
((GrVertex *) p_3Point) + 0
);
}
/*
===================================================================================================
Description:: choose good drawing function
===================================================================================================
*/
void GLI_vAddDrawFunc(void)
{
GLI_M_AddFunc(GLI_vCorrect3DFXBug1);
ulFuncMask |= Flag_GLI_vCorrect3DFXBug1;
if(GLI_BIG_GLOBALS->lClippingModeMask & GLI_C_TrianglesMustBeSorted)
{
GLI_M_AddFunc(GLI_vZSortTriangle);
ulFuncMask |= Flag_GLI_vZSortTriangle;
}
else if((GLI_BIG_GLOBALS->lCurrentDrawMask & GLI_C_lIsNotWired) == 0)
{
GLI_M_AddFunc(GLI_vDrawWiredTriangle);
ulFuncMask |= Flag_GLI_vDrawWiredTriangle;
}
else
{
GLI_M_AddFunc(GLI_vDrawTriangle);
ulFuncMask |= Flag_GLI_vDrawTriangle;
}
}
/*
===================================================================================================
Description:: compute clipping mask
===================================================================================================
*/
void GLI_ReComputeClippingMask(void)
{
*(float *) &fX_CMP_Optimize = GLI_BIG_GLOBALS->fXMaxClipping;
*(float *) &fY_CMP_Optimize = GLI_BIG_GLOBALS->fYMaxClipping;
*(float *) &fXMin_CLIP_Optimize = GLI_BIG_GLOBALS->fXMinClipping;
*(float *) &fYMin_CLIP_Optimize = GLI_BIG_GLOBALS->fYMinClipping;
*(float *) &fXMax_CLIP_Optimize = GLI_BIG_GLOBALS->fXMaxClipping;
*(float *) &fYMax_CLIP_Optimize = GLI_BIG_GLOBALS->fYMaxClipping;
GLI_BIG_GLOBALS->lClippingModeMask |= (GLI_BIG_GLOBALS->lClippingModeMask & GLI_C_lCLIP_ALL) << 4;
}
/*
===================================================================================================
Description:: clip a sprite
===================================================================================================
*/
void GLI_DRV_vSendSpriteToClip
(
GLI_tdstAligned2DVector *a4_st2DVertex,
MTH_tdxReal xZ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
float fClipYMax, fClipYMin, fClipXMax, fClipXMin;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if(*(long *) &GLI_BIG_GLOBALS->xWaterPlaneDistance != 0)
{
GLI_DRV_xSendSpriteToClip_TRIANGLES(a4_st2DVertex, p_stGlobaleMT);
return;
}
GLI_BeforeDraw();
if(a4_st2DVertex[0].xY == a4_st2DVertex[1].xY) /* Aligned sprite */
{
/* If (xZ < 0) */
/* Return; */
GLI_ReComputeClippingMask();
if
(
(*(long *) &a4_st2DVertex[0].xY > fYMax_CLIP_Optimize) ||
(*(long *) &a4_st2DVertex[2].xY < fYMin_CLIP_Optimize) ||
(*(long *) &a4_st2DVertex[0].xX < fXMin_CLIP_Optimize) ||
(*(long *) &a4_st2DVertex[1].xX > fXMax_CLIP_Optimize)
) return;
/* Clip xMax */
if(*(long *) &a4_st2DVertex[0].xX > fXMax_CLIP_Optimize)
{
fClipXMax = (GLI_BIG_GLOBALS->fXMaxClipping - a4_st2DVertex[1].xX) /
(a4_st2DVertex[0].xX - a4_st2DVertex[1].xX);
a4_st2DVertex[0].xX = a4_st2DVertex[3].xX = GLI_BIG_GLOBALS->fXMaxClipping;
}
else
fClipXMax = 1.0f;
/* Clip xMin */
if(*(long *) &a4_st2DVertex[1].xX < fXMin_CLIP_Optimize)
{
fClipXMin = (fClipXMax * (GLI_BIG_GLOBALS->fXMinClipping - a4_st2DVertex[1].xX)) /
(a4_st2DVertex[0].xX - a4_st2DVertex[1].xX);
a4_st2DVertex[1].xX = a4_st2DVertex[2].xX = GLI_BIG_GLOBALS->fXMinClipping;
}
else
fClipXMin = 0.0f;
/* Clip yMin */
if(*(long *) &a4_st2DVertex[0].xY < fYMin_CLIP_Optimize)
{
fClipYMin = (GLI_BIG_GLOBALS->fYMinClipping - a4_st2DVertex[2].xY) /
(a4_st2DVertex[0].xY - a4_st2DVertex[2].xY);
a4_st2DVertex[0].xY = a4_st2DVertex[1].xY = GLI_BIG_GLOBALS->fYMinClipping;
}
else
fClipYMin = 1.0f;
/* Clip yMax */
if(*(long *) &a4_st2DVertex[2].xY > fYMax_CLIP_Optimize)
{
fClipYMax = (fClipYMin * (GLI_BIG_GLOBALS->fYMaxClipping - a4_st2DVertex[2].xY)) /
(a4_st2DVertex[0].xY - a4_st2DVertex[2].xY);
a4_st2DVertex[2].xY = a4_st2DVertex[3].xY = GLI_BIG_GLOBALS->fYMaxClipping;
}
else
fClipYMax = 0.0f;
}
else
{
if
(
(a4_st2DVertex[0].xY < 0.0f) ||
(a4_st2DVertex[1].xY < 0.0f) ||
(a4_st2DVertex[2].xY < 0.0f) ||
(a4_st2DVertex[3].xY < 0.0f)
) return;
if
(
(a4_st2DVertex[0].xX < 0.0f) ||
(a4_st2DVertex[1].xX < 0.0f) ||
(a4_st2DVertex[2].xX < 0.0f) ||
(a4_st2DVertex[3].xX < 0.0f)
) return;
if
(
(a4_st2DVertex[0].xY > 480.0f) ||
(a4_st2DVertex[1].xY > 480.0f) ||
(a4_st2DVertex[2].xY > 480.0f) ||
(a4_st2DVertex[3].xY > 480.0f)
) return;
if
(
(a4_st2DVertex[0].xX > 640.0f) ||
(a4_st2DVertex[1].xX > 640.0f) ||
(a4_st2DVertex[2].xX > 640.0f) ||
(a4_st2DVertex[3].xX > 640.0f)
) return;
fClipXMin = fClipYMax = 0.0f;
fClipYMin = fClipXMax = 1.0f;
}
GLI_M_InitSprite();
SetU(CurrentDestXYZ[0], fClipXMax);
SetV(CurrentDestXYZ[0], fClipYMin);
SetU(CurrentDestXYZ[1], fClipXMin);
SetV(CurrentDestXYZ[1], fClipYMin);
SetU(CurrentDestXYZ[2], fClipXMin);
SetV(CurrentDestXYZ[2], fClipYMax);
SetU(CurrentDestXYZ[3], fClipXMax);
SetV(CurrentDestXYZ[3], fClipYMax);
GLI_DrawQuad();
GLI_AfterDraw();
}
/*
===================================================================================================
Description:: clip a sprite that have UV coordinates (it seems to be unused)
===================================================================================================
*/
void GLI_DRV_vSendSpriteToClipWithUV
(
GLI_tdstAligned2DVector *a4_st2DVertex,
MTH_tdxReal *a8_stUVVertex,
MTH_tdxReal xZ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT
)
{
GLI_BeforeDraw();
GLI_M_InitSprite();
if(a4_st2DVertex[0].xY < 0.0f) return;
if(a4_st2DVertex[1].xY < 0.0f) return;
if(a4_st2DVertex[2].xY < 0.0f) return;
if(a4_st2DVertex[3].xY < 0.0f) return;
if(a4_st2DVertex[0].xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if(a4_st2DVertex[1].xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if(a4_st2DVertex[2].xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if(a4_st2DVertex[3].xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if ( p_stGlobaleMT->p_stCurrentTexture->lIncrementIsEnable )
{
float fAddU, fAddV;
fAddU = p_stGlobaleMT-> p_stCurrentTexture -> fAddU;
fAddV = p_stGlobaleMT-> p_stCurrentTexture -> fAddV;
SetU(CurrentDestXYZ[2], a8_stUVVertex[4] + fAddU );
SetV(CurrentDestXYZ[2], a8_stUVVertex[4 + 1] + fAddV);
SetU(CurrentDestXYZ[3], a8_stUVVertex[6] + fAddU);
SetV(CurrentDestXYZ[3], a8_stUVVertex[6 + 1] + fAddV);
SetU(CurrentDestXYZ[0], a8_stUVVertex[0] + fAddU);
SetV(CurrentDestXYZ[0], a8_stUVVertex[0 + 1] + fAddV);
SetU(CurrentDestXYZ[1], a8_stUVVertex[2] + fAddU);
SetV(CurrentDestXYZ[1], a8_stUVVertex[2 + 1] + fAddV);
}
else
{
SetU(CurrentDestXYZ[2], a8_stUVVertex[4]);
SetV(CurrentDestXYZ[2], a8_stUVVertex[4 + 1]);
SetU(CurrentDestXYZ[3], a8_stUVVertex[6]);
SetV(CurrentDestXYZ[3], a8_stUVVertex[6 + 1]);
SetU(CurrentDestXYZ[0], a8_stUVVertex[0]);
SetV(CurrentDestXYZ[0], a8_stUVVertex[0 + 1]);
SetU(CurrentDestXYZ[1], a8_stUVVertex[2]);
SetV(CurrentDestXYZ[1], a8_stUVVertex[2 + 1]);
}
GLI_DrawQuad();
GLI_AfterDraw();
}
/*
===================================================================================================
Description:: clip a line and draw it.
===================================================================================================
*/
void GLI_DRV_vSendSingleLineToClip
(
GLD_tdstViewportAttributes *p_stVpt,
GLI_tdstAligned3DVector *p_stVertex1,
GLI_tdstAligned2DVector *p_st2DVertex1,
GLI_tdstAligned3DVector *p_stVertex2,
GLI_tdstAligned2DVector *p_st2DVertex2,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT,
long lDrawModeMask,
GEO_tdstColor *p_stColor
)
{
#ifdef _DEBUG
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstAligned2DVector stP1, stP2;
GLI_tdstAligned3DVector st3DP1, st3DP2;
float fFactor;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
guColorCombineFunction( GR_COLORCOMBINE_ITRGB );
/* Z clipping */
if( p_st2DVertex1->xOoZ < p_st2DVertex2->xOoZ )
{
stP1 = *p_st2DVertex1;
st3DP1 = *p_stVertex1;
stP2 = *p_st2DVertex2;
st3DP2 = *p_stVertex2;
}
else
{
stP2 = *p_st2DVertex1;
st3DP2 = *p_stVertex1;
stP1 = *p_st2DVertex2;
st3DP1 = *p_stVertex2;
}
if ( (*(unsigned long *)&stP2.xOoZ & 0x80000000) )
return;
// At least one point out ?
if ( (*(unsigned long *)&stP1.xOoZ & 0x80000000) )
{
// The point 1 (smallest xOoZ) is out.
fFactor = ( p_stGlobaleMT->p_stCurrentCamera->xNear - st3DP2.xZ ) / (st3DP1.xZ - st3DP2.xZ);
st3DP1.xX = st3DP2.xX + (st3DP1.xX - st3DP2.xX) * fFactor;
st3DP1.xY = st3DP2.xY + (st3DP1.xY - st3DP2.xY) * fFactor;
st3DP1.xZ = GLI_BIG_GLOBALS -> fZClipping;
GLI_MDRV_vSerialProjection( GLI_BIG_GLOBALS -> p_stCurrentCamera , 1 , &st3DP1 , &stP1 );
}
/* XClipping */
if(stP1.xX < stP2.xX)
{
p_st2DVertex1 = &stP1;
p_stVertex1 = &st3DP1;
p_st2DVertex2 = &stP2;
p_stVertex2 = &st3DP2;
}
else
{
p_st2DVertex1 = &stP2;
p_stVertex1 = &st3DP2;
p_st2DVertex2 = &stP1;
p_stVertex2 = &st3DP1;
}
if((p_st2DVertex2->xX < GLI_BIG_GLOBALS->fXMinClipping) || (p_st2DVertex1->xX > GLI_BIG_GLOBALS->fXMaxClipping)) return;
if(p_st2DVertex1->xX < GLI_BIG_GLOBALS->fXMinClipping)
{
fFactor = (p_st2DVertex2->xX - GLI_BIG_GLOBALS->fXMinClipping) / (p_st2DVertex2->xX - p_st2DVertex1->xX);
p_st2DVertex1->xY = p_st2DVertex2->xY - (p_st2DVertex2->xY - p_st2DVertex1->xY) * fFactor;
p_stVertex1->xZ = p_stVertex2->xZ - (p_stVertex2->xY - p_stVertex1->xY) * fFactor;
p_st2DVertex1->xX = GLI_BIG_GLOBALS->fXMinClipping;
}
if(p_st2DVertex2->xX > GLI_BIG_GLOBALS->fXMaxClipping)
{
fFactor = (p_st2DVertex1->xX - GLI_BIG_GLOBALS->fXMaxClipping) / (p_st2DVertex2->xX - p_st2DVertex1->xX);
p_st2DVertex2->xY = p_st2DVertex1->xY - (p_st2DVertex2->xY - p_st2DVertex1->xY) * fFactor;
p_stVertex2->xZ = p_stVertex1->xZ - (p_stVertex2->xY - p_stVertex1->xY) * fFactor;
p_st2DVertex2->xX = GLI_BIG_GLOBALS->fXMaxClipping;
}
/* YClipping */
if(stP1.xY < stP2.xY)
{
p_st2DVertex1 = &stP1;
p_stVertex1 = &st3DP1;
p_st2DVertex2 = &stP2;
p_stVertex2 = &st3DP2;
}
else
{
p_st2DVertex1 = &stP2;
p_stVertex1 = &st3DP2;
p_st2DVertex2 = &stP1;
p_stVertex2 = &st3DP1;
}
if((p_st2DVertex2->xY < GLI_BIG_GLOBALS->fYMinClipping) || (p_st2DVertex1->xY > GLI_BIG_GLOBALS->fYMaxClipping)) return;
if(p_st2DVertex1->xY < GLI_BIG_GLOBALS->fYMinClipping)
{
fFactor = ( p_st2DVertex2->xY - GLI_BIG_GLOBALS->fYMinClipping )/ (p_st2DVertex2->xY - p_st2DVertex1->xY);
p_st2DVertex1->xX = p_st2DVertex2->xX - (p_st2DVertex2->xX - p_st2DVertex1->xX) * fFactor;
p_stVertex1->xZ = p_stVertex2->xZ - (p_stVertex2->xZ - p_stVertex1->xZ) * fFactor;
p_st2DVertex1->xY = GLI_BIG_GLOBALS->fYMinClipping;
}
if(p_st2DVertex2->xY > GLI_BIG_GLOBALS->fYMaxClipping)
{
fFactor = (p_st2DVertex1->xY - GLI_BIG_GLOBALS->fYMaxClipping) / (p_st2DVertex2->xY - p_st2DVertex1->xY);
p_st2DVertex2->xX = p_st2DVertex1->xX - (p_st2DVertex2->xX - p_st2DVertex1->xX) * fFactor;
p_stVertex2->xZ = p_stVertex1->xZ - (p_stVertex2->xZ - p_stVertex1->xZ) * fFactor;
p_st2DVertex2->xY = GLI_BIG_GLOBALS->fYMaxClipping;
}
#else
if(p_st2DVertex1->xX < 0) return;
if(p_st2DVertex1->xY < 0) return;
if(p_st2DVertex1->xX > 640.0f) return;
if(p_st2DVertex1->xY > 480.0f) return;
if(p_st2DVertex2->xX < 0) return;
if(p_st2DVertex2->xY < 0) return;
if(p_st2DVertex2->xX > 640.0f) return;
if(p_st2DVertex2->xY > 480.0f) return;
#endif
GLI_M_InitLine();
GLI_BeforeDraw();
GLI_DrawLine();
GLI_AfterDraw();
}

View File

@@ -0,0 +1,834 @@
/******************************************************************************************
FILE : DoMat Glide2
Do render parameters settings for texture/material/fog
Dispay black triangles for window smaller than screen
*******************************************************************************************/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "Gli_st.h"
#include "GLI_Defn.h"
#include "polygon.h"
#include "mater_st.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "Liste.h"
#include "watrplan.h"
#include "proj.h"
#include "vpt3D.h"
#include "camera.h"
#include "material.h"
#include "texture.h"
#include "TEX.h"
#include "light.h"
#include "GliBench.h"
#define __MSC__
#include <GLIDE.H>
#include "TextuDFX.h"
#include "DLLCom.h"
#include "PRF.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Globals
=======================================================================================
*/
/*
* render parameters
*/
static long bIsWriteEnable = 1;
static ACP_tdxIndex xSaveFogIsOn = 0;
static GrChipID_t xSaveTmuNumber = -1;
static unsigned char ucSaveCyclingMode[2] = {-1, -1};
static unsigned char ucSaveFunction = -1;
static unsigned long gs_ulDepthBufferTestEnabled = 0;
/*
* Fog table
*/
GrFog_t Gli_C_xFogTable[ GR_FOG_TABLE_SIZE ];
float GLI_ga_fFogDist[ GR_FOG_TABLE_SIZE ];
/*
* Black triangles
*/
GrVertex g_stBlackTriangle[16];
long g_lNumberOfBlackTriangles = 0;
/*
=======================================================================================
Special function for displaying black polygon
it's for cinematic scene to hide non black for color
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : reinit list of black triangles
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vNoBlackPolygon()
{
g_lNumberOfBlackTriangles = 0;
}
/*
----------------------------------------------------------------------------------------
Description : Add a black triangles to list
Assume that list is large enough (no test)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vAddBlackPolygon( long _lLeft, long _lTop, long _lRight, long _lBottom )
{
GrVertex *p_stVertex;
p_stVertex = g_stBlackTriangle + g_lNumberOfBlackTriangles;
memset( p_stVertex, 0, 4 * sizeof( GrVertex ) );
g_lNumberOfBlackTriangles += 4;
p_stVertex->x = (float) _lLeft;
p_stVertex->y = (float) _lBottom;
p_stVertex->oow = .8f;
p_stVertex++;
p_stVertex->x = (float) _lLeft;
p_stVertex->y = (float) _lTop;
p_stVertex->oow = .8f;
p_stVertex++;
p_stVertex->x = (float) _lRight;
p_stVertex->y = (float) _lTop;
p_stVertex->oow = .8f;
p_stVertex++;
p_stVertex->x = (float) _lRight;
p_stVertex->y = (float) _lBottom;
p_stVertex->oow = .8f;
}
/*
----------------------------------------------------------------------------------------
Description : Draw black triangles
----------------------------------------------------------------------------------------
*/
void GLI_vSendBlackPolygon()
{
GrVertex *p_stVertex, *p_stLastVertex;
if (g_lNumberOfBlackTriangles == 0)
return;
p_stVertex = g_stBlackTriangle;
p_stLastVertex = p_stVertex + g_lNumberOfBlackTriangles;
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);/* */
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
guColorCombineFunction( GR_COLORCOMBINE_ITRGB );
grFogMode( GR_FOG_DISABLE);
xSaveFogIsOn = 0;
for ( ; p_stVertex < p_stLastVertex; p_stVertex += 4)
{
grDrawTriangle( p_stVertex, p_stVertex + 1, p_stVertex + 2 );
grDrawTriangle( p_stVertex + 2, p_stVertex + 3, p_stVertex );
}
}
/*
=======================================================================================
Function for Fog
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Set render parameter for given fog parameters
----------------------------------------------------------------------------------------
*/
void GLI_vSetFogParams( tdstFogParams *_p_stFogParams )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
float *p_fFogDist, *p_fLast;
long GlideColor;
float xCoefOfCalculation;
GrFog_t *p_xFog;
unsigned char ucFogDensityStart, ucFogDensityEnd;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
xCoefOfCalculation = _p_stFogParams->xDepthEnd - _p_stFogParams->xDepthStart;
if ( xCoefOfCalculation )
xCoefOfCalculation = ( _p_stFogParams->xBlendEnd - _p_stFogParams->xBlendStart) / xCoefOfCalculation;
p_fFogDist = GLI_ga_fFogDist;
p_fLast = p_fFogDist + GR_FOG_TABLE_SIZE;
p_xFog = Gli_C_xFogTable;
ucFogDensityStart = (unsigned char) MTH_M_xRealToLong(_p_stFogParams->xBlendStart);
ucFogDensityEnd = (unsigned char) MTH_M_xRealToLong(_p_stFogParams->xBlendEnd);
while ( (p_fFogDist < p_fLast) && (*p_fFogDist < _p_stFogParams->xDepthStart) )
{
*p_xFog++ = ucFogDensityStart;
p_fFogDist++;
}
while ( (p_fFogDist < p_fLast) && (*p_fFogDist < _p_stFogParams->xDepthEnd) )
{
*p_xFog++ = (unsigned char)MTH_M_xRealToLong((xCoefOfCalculation * (*p_fFogDist++ - _p_stFogParams->xDepthStart)) + _p_stFogParams->xBlendStart);
}
while ( (p_fFogDist < p_fLast) && (*p_fFogDist < _p_stFogParams->xInfinite) )
{
*p_xFog++ = ucFogDensityEnd;
p_fFogDist++;
}
while ( p_fFogDist < p_fLast )
{
*p_xFog++ = 255;
p_fFogDist++;
}
grFogTable( Gli_C_xFogTable );
GlideColor = (long)(_p_stFogParams->stColor.xR * 255.f) +((long)(_p_stFogParams->stColor.xG * 255.f)<<8) +((long)(_p_stFogParams->stColor.xB * 255.f)<<16) ;
grFogColorValue(GlideColor);
}
/*
----------------------------------------------------------------------------------------
Description : compute fog effect on vertex color (nothing to do for Glide2)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vComputeFogEffect(GLI_tdstInternalGlobalValuesFor3dEngine *p_stBG )
{
}
/*
=======================================================================================
ZBuffer function
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : To enable write to ZBuffer
----------------------------------------------------------------------------------------
*/
static void GLI_fn_vEnableWriteToZBuffer()
{
if (bIsWriteEnable)
return;
grDepthMask(FXTRUE);
bIsWriteEnable = 1;
}
/*
----------------------------------------------------------------------------------------
Description : To disable write to ZBuffer
----------------------------------------------------------------------------------------
*/
static void GLI_fn_vDisableWriteToZBuffer()
{
if (!bIsWriteEnable)
return;
grDepthMask(FXFALSE);
bIsWriteEnable = 0;
}
/*
----------------------------------------------------------------------------------------
Description : To manage use of ZBuffer
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vEnableDepthTest()
{
if( gs_ulDepthBufferTestEnabled )
return;
grDepthBufferFunction( GR_CMP_LESS );
gs_ulDepthBufferTestEnabled = 1;
}
void GLI_DRV_vDisableDepthTest()
{
if( ! gs_ulDepthBufferTestEnabled )
return;
grDepthBufferFunction( GR_CMP_ALWAYS );
gs_ulDepthBufferTestEnabled = 0;
}
/*
=======================================================================================
Main render parameter setting functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Macro to set chromakey
CB : La valeur de chromakey doit etre <20>gale <20> : 5 bits de poids fort, plus les 3 bits de poids fort copi<70>s dans les bits de poids faible.... !!!
VL : sauf pour la composante G : 6 bit de poids fort + 2 bit de poids fort copi<70>s dans les bits de poids faible !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
----------------------------------------------------------------------------------------
*/
#define M_vChromakey()\
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lNZTexture)\
{\
unsigned long ulChromakey;\
grChromakeyMode( GR_CHROMAKEY_ENABLE );\
ulChromakey = (p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x00F800F8) | ((p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x00E000E0) >> 5);\
ulChromakey|= (p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x0000FC00) | ((p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x0000C000) >> 6);\
grChromakeyValue( ulChromakey );\
}\
else\
{\
grChromakeyMode( GR_CHROMAKEY_DISABLE );\
}
/*
----------------------------------------------------------------------------------------
Description : Macro to change fog rendering
----------------------------------------------------------------------------------------
*/
#define M_vFog()\
if (GLI_BIG_GLOBALS->xFogIsOn == 1)\
{\
if ( GLI_BIG_GLOBALS->p_stLastComputedFog != GLI_BIG_GLOBALS->p_stActiveFog )\
{\
GLI_vSetFogParams( GLI_BIG_GLOBALS->p_stActiveFog );\
GLI_BIG_GLOBALS->p_stLastComputedFog = GLI_BIG_GLOBALS->p_stActiveFog;\
}\
if (xSaveFogIsOn != 1)\
{\
grFogMode( GR_FOG_WITH_TABLE);\
xSaveFogIsOn = 1;\
}\
}\
else if (GLI_BIG_GLOBALS->xFogIsOn == 2)\
{\
if( xSaveFogIsOn != 2 ) \
{ \
grFogMode( GR_FOG_WITH_ITERATED_ALPHA ); \
xSaveFogIsOn = 2; \
} \
}\
else if (xSaveFogIsOn)\
{\
grFogMode( GR_FOG_DISABLE);\
xSaveFogIsOn = 0;\
}
/*
----------------------------------------------------------------------------------------
Description : Set init parameter as none set
----------------------------------------------------------------------------------------
*/
void GLI_fn_vInitRenderParameters( void )
{
bIsWriteEnable = 1;
xSaveFogIsOn = 0;
xSaveTmuNumber = -1;
ucSaveCyclingMode[0] = ucSaveCyclingMode[1] = -1;
ucSaveFunction = -1;
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters that will work for all faces which are not
transparent
----------------------------------------------------------------------------------------
*/
void GLI_fn_vSetRenderParametersBeforeOpaqueFace( void ) {
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
grAlphaTestFunction( GR_CMP_ALWAYS );
grAlphaTestReferenceValue( 0xC0 );
ucSaveFunction = 4;
GLI_fn_vEnableWriteToZBuffer();
}
/*
----------------------------------------------------------------------------------------
Description : called before the rendering of any triangle
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bBeginScene()
{
GLI_BIG_GLOBALS->GLD_RenderingCounter = *GLD_p_lRenderingCounter;
GLI_vSendBlackPolygon();
grAlphaTestFunction( GR_CMP_LESS );
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
grAlphaTestFunction( GR_CMP_ALWAYS );
grAlphaTestReferenceValue( 0xC0 );
ucSaveFunction = 4;
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : called after the rendering of all triangles
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bEndScene()
{
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : Called for all object before drawn.
Set some general parameters and set render parameter for opaque texture only
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vDoOpaqueTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstTextureDFX *p_stSpecParam;
BOOL bTexture;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
if (*GLD_p_lRenderingCounter != p_stGlobaleMT->GLD_RenderingCounter)
{
p_stGlobaleMT->GLD_RenderingCounter = *GLD_p_lRenderingCounter;
GLI_vSendBlackPolygon();
grAlphaTestFunction( GR_CMP_LESS );
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
grAlphaTestFunction( GR_CMP_ALWAYS );
grAlphaTestReferenceValue( 0xC0 );
ucSaveFunction = 4;
}
*/
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsWriteZBuffer)
GLI_fn_vEnableWriteToZBuffer();
else
GLI_fn_vDisableWriteToZBuffer();
// GLI_fn_vEnableWriteToZBuffer();
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
GLI_DRV_vEnableDepthTest();
else
GLI_DRV_vDisableDepthTest();
bTexture = (p_stGlobaleMT->p_stCurrentTexture != NULL) && (p_stGlobaleMT->p_stCurrentTexture->bIsAvailable);
if (bTexture)
{
p_stSpecParam = p_stGlobaleMT -> p_stCurrentTexture -> p_stSpecParam;
GLI_GLIDE1_xTmuNumber = p_stSpecParam->xTmuNumber;
/*
* UV multiplier
*/
p_stGlobaleMT -> fMulU = p_stSpecParam -> lMultiplyHeight;
p_stGlobaleMT -> fMulV = p_stSpecParam -> lMultiplyWidth;
}
/*
* test if triangle will be transparent if so do not set render parameters
*/
if (GLI_BIG_GLOBALS->lAMirrorIsDetected)
GLI_BIG_GLOBALS->lAMirrorIsDetected = 3;
if (
( !(GLI_BIG_GLOBALS->lAMirrorIsDetected) && bTexture && (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTexture | GLI_C_lNZFilteredTexture | GLI_C_lAddTransparencyTexture) ) )
|| (!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))
)
{
p_stGlobaleMT -> lClippingModeMask |= GLI_C_TrianglesMustBeSorted;
return;
}
p_stGlobaleMT -> lClippingModeMask &= 0xffffffff - GLI_C_TrianglesMustBeSorted;
/*
* fog
*/
M_vFog();
{
if ( bTexture )
{
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAlphaTest)
{
if (ucSaveFunction != 5)
{
if ( ucSaveFunction == 2 )
GLI_fn_vSetRenderParametersBeforeOpaqueFace() ;
grAlphaTestFunction( GR_CMP_GEQUAL );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
ucSaveFunction = 5;
}
}
else if (GLI_BIG_GLOBALS->lAMirrorIsDetected & 2)
{
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE ,GR_BLEND_ZERO );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
ucSaveFunction = 2;
}
else
{
if (ucSaveFunction != 4)
{
if ( ucSaveFunction == 2 )
GLI_fn_vSetRenderParametersBeforeOpaqueFace() ;
grAlphaTestFunction( GR_CMP_ALWAYS );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
ucSaveFunction = 4;
}
}
/*
* Chromakey
*/
M_vChromakey();
/*
* uv cycling mode
*/
if ( p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode != ucSaveCyclingMode[ GLI_GLIDE1_xTmuNumber ] )
{
switch ( ucSaveCyclingMode[ GLI_GLIDE1_xTmuNumber ] = p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode )
{
case 0:
/*NO CYCLING*/
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_CLAMP,GR_TEXTURECLAMP_CLAMP);
break;
case GLI_C_lCylingUV:
/*CYCLING*/
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_WRAP,GR_TEXTURECLAMP_WRAP);
break;
case GLI_C_lCylingU:
/*CYCLING V*/
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_CLAMP,GR_TEXTURECLAMP_WRAP);
break;
case GLI_C_lCylingV:
/*CYCLING U*/
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_WRAP , GR_TEXTURECLAMP_CLAMP);
break;
}
}
/*
* texture Tmu
*/
if (GLI_GLIDE1_xTmuNumber != xSaveTmuNumber)
{
grTexCombineFunction((GLI_GLIDE1_xTmuNumber+1) & 0x1, GR_TEXTURECOMBINE_OTHER);
grTexCombineFunction(GLI_GLIDE1_xTmuNumber, GR_TEXTURECOMBINE_DECAL);
xSaveTmuNumber = GLI_GLIDE1_xTmuNumber;
}
grTexSource( GLI_GLIDE1_xTmuNumber, p_stSpecParam -> xStartAddress, p_stSpecParam -> xEvenOdd, &p_stSpecParam -> stInfoBitmapGlide);
if (p_stGlobaleMT->p_stCurrentTexture->lTextureCaps & GLI_C_lPaletteTexture)
{
grTexDownloadTable( GLI_GLIDE1_xTmuNumber, GR_TEXTABLE_PALETTE, p_stGlobaleMT->p_stCurrentTexture->p_vColorTable );
}
}
else /* gouraud */
{
if (ucSaveFunction != 0)
{
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
grAlphaTestFunction( GR_CMP_ALWAYS );
guColorCombineFunction( GR_COLORCOMBINE_ITRGB );
ucSaveFunction = 0;
}
}
}
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters that will work for all transparency faces
----------------------------------------------------------------------------------------
*/
void GLI_fn_vSetRenderParametersBeforeTransparencyFace( void )
{
grAlphaTestFunction( GR_CMP_ALWAYS );
GLI_fn_vDisableWriteToZBuffer();
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters for transparent triangles
----------------------------------------------------------------------------------------
*/
void GLI_vDoTransparentTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_tdstTextureDFX *p_stSpecParam;
/*grAlphaTestFunction( GR_CMP_ALWAYS );*/
/*
* write to Z buffer ?
*/
/*
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsWriteZBuffer)
GLI_fn_vEnableWriteToZBuffer();
else
GLI_fn_vDisableWriteToZBuffer();
*/
/* Test Z-Buffer ? */
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
GLI_DRV_vEnableDepthTest();
else
GLI_DRV_vDisableDepthTest();
/*
* fog
*/
M_vFog();
/*
* mirror
*/
if (p_stGlobaleMT->lAMirrorIsDetected & 2)
{
if ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))
{
}
else
{
}
}
/*
* not a mirror
*/
else
{
if ((p_stGlobaleMT -> p_stCurrentTexture != NULL) && (p_stGlobaleMT -> p_stCurrentTexture -> bIsAvailable))
{
p_stSpecParam = p_stGlobaleMT -> p_stCurrentTexture -> p_stSpecParam;
GLI_GLIDE1_xTmuNumber = p_stSpecParam->xTmuNumber;
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTest | GLI_C_lAlphaTexture | GLI_C_lNZFilteredTexture | GLI_C_lAddTransparencyTexture) )
{
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAddTransparencyTexture)
{
/* Trans ADD*/
if (ucSaveFunction != 1)
{
grAlphaBlendFunction( GR_BLEND_ONE,GR_BLEND_ONE,GR_BLEND_ZERO ,GR_BLEND_ZERO );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA);
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
ucSaveFunction = 1;
}
/* No fog With This;*/
if (xSaveFogIsOn)
{
grFogMode( GR_FOG_DISABLE);
xSaveFogIsOn = 0;
}
}
/*VL AAA texture*/
/*
else if (p_stGlobaleMT->p_stCurrentTexture->lTextureCaps & GLI_C_lAAATexture )
{
if (ucSaveFunction != 6)
{
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE ,GR_BLEND_ZERO );
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_TEXTURE, FXFALSE );
grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_CONSTANT, FXFALSE );
ucSaveFunction = 6;
}
//test
{
unsigned long ulColor;
ulColor = (long) (p_stGlobaleMT->hCurrentMaterial->stAmbient.xR * 255) & 0xFF;
ulColor |= ((long) (p_stGlobaleMT->hCurrentMaterial->stAmbient.xG * 255) & 0xFF) << 8;
ulColor |= ((long) (p_stGlobaleMT->hCurrentMaterial->stAmbient.xB * 255) & 0xFF) << 16;
grConstantColorValue( ulColor );
}
}
*/
else if (ucSaveFunction != 2)
{
/* Trans ALPHA*/
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE ,GR_BLEND_ZERO );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
ucSaveFunction = 2;
}
}
else /*if ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (xGlobaLAlpha < 0.98f))*/
{
/* Trans ALPHA ITERATED*/
if (ucSaveFunction != 3)
{
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE,GR_BLEND_ZERO );
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);/* */
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
ucSaveFunction = 3;
}
}
/*
* Chromakey
*/
M_vChromakey();
/*
* uv cycling mode
*/
if ( p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode != ucSaveCyclingMode[ GLI_GLIDE1_xTmuNumber ] )
{
switch ( ucSaveCyclingMode[ GLI_GLIDE1_xTmuNumber ] = p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode )
{
case 0:
/*NO CYCLING*/
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_CLAMP,GR_TEXTURECLAMP_CLAMP);
break;
case GLI_C_lCylingUV:
/*CYCLING*/
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_WRAP,GR_TEXTURECLAMP_WRAP);
break;
case GLI_C_lCylingU:
/*CYCLING V*/
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_CLAMP,GR_TEXTURECLAMP_WRAP);
break;
case GLI_C_lCylingV:
/*CYCLING U*/
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_WRAP , GR_TEXTURECLAMP_CLAMP);
break;
}
}
/*
* texture Tmu
*/
if (GLI_GLIDE1_xTmuNumber != xSaveTmuNumber)
{
grTexCombineFunction((GLI_GLIDE1_xTmuNumber + 1) & 0x1, GR_TEXTURECOMBINE_OTHER);
grTexCombineFunction(GLI_GLIDE1_xTmuNumber, GR_TEXTURECOMBINE_DECAL);
xSaveTmuNumber = GLI_GLIDE1_xTmuNumber;
}
grTexSource( GLI_GLIDE1_xTmuNumber, p_stSpecParam -> xStartAddress, p_stSpecParam -> xEvenOdd, &p_stSpecParam -> stInfoBitmapGlide);
}
else
{
/* GOURAUD*/
if (((p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided) == 0) && (p_stGlobaleMT->xGlobalAlpha < 0.98f) )
{
/* alpha iterated transparency*/
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE,GR_BLEND_ZERO );
grAlphaCombine(GR_COMBINE_FUNCTION_BLEND, GR_COMBINE_FACTOR_LOCAL_ALPHA,GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_NONE,FXFALSE);/* */
guAlphaSource(GR_ALPHASOURCE_ITERATED_ALPHA);
p_stGlobaleMT -> lClippingModeMask |= GLI_C_TrianglesMustBeSorted;
}
else
{
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);/* */
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
}
guColorCombineFunction( GR_COLORCOMBINE_ITRGB );
ucSaveFunction = 0;
}
}
}
/*
=======================================================================================
Write bitmap into backbuffer
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : write bitmap part into backbuffer
----------------------------------------------------------------------------------------
*/
void GLI_fn_vWriteRegion3DFX(long X, long Y, long l, long h, unsigned char *p_ucSrc, long SrcPitch , GrLfbInfo_t *p_info)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lPitch;
long *p_sourceptr , *p_sourceptrLast , *p_destptr ,lYCounterLocal;
short *p_Src;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
p_Src = (unsigned short *)p_ucSrc;
lPitch = p_info->strideInBytes/4;
for (lYCounterLocal = 0; lYCounterLocal < h ; lYCounterLocal++)
{
p_destptr = ((unsigned long *)p_info->lfbPtr) + (X>>1) + lPitch * (Y + lYCounterLocal);
p_sourceptr = ((unsigned long *)p_Src + lYCounterLocal * (SrcPitch >>2)) ;
p_sourceptrLast = p_sourceptr + (l>>1);
for (;p_sourceptr < p_sourceptrLast ;p_sourceptr ++,p_destptr ++)
*p_destptr = *p_sourceptr ;
}
}
/*
----------------------------------------------------------------------------------------
Description : Write a 16 bit bitmap in the back buffer
_p_vSourceBuffer -> bitmap
_lWidth, _lHeight -> dimension of bitmap
_lDestX, _lDestY -> where the bitmap have to be copied in the backbuffer
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vWrite16bBitmapToBackBuffer( void *_p_vSourceBuffer, long _lWidth, long _lHeight, long _lDestLeft, long _lDestTop, long _lDestRight, long _lDestBottom )
{
GrLfbInfo_t info;
unsigned short *puw_Tgt, *puw_Src;
info.size = sizeof( GrLfbInfo_t );
if ( !grLfbLock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER, GR_LFBWRITEMODE_565 , GR_ORIGIN_UPPER_LEFT, FXFALSE , &info) )
return;
puw_Tgt = (unsigned short *) info.lfbPtr;
puw_Tgt += (info.strideInBytes>> 1) * _lDestTop + _lDestLeft;
puw_Src = (unsigned short *) _p_vSourceBuffer;
GLD_MDRV_vBlitStretched16b( _lDestRight - _lDestLeft + 1, _lDestBottom - _lDestTop + 1, puw_Tgt, info.strideInBytes >> 1, _lWidth, _lHeight, puw_Src );
grLfbUnlock( GR_LFB_WRITE_ONLY , GR_BUFFER_BACKBUFFER);
}
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@@ -0,0 +1,27 @@
/*
=======================================================================================
Name : Glide2_Dll.c
Author : vincent lhullier Date :16/09/98
Description : specific DLL fonction
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "init_gli.h"
#include "DLLCom.h"
#include "DLLCaps.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tdstGliDriverIdentity stGlide2Id =
{
"Glide2",
"Driver for Voodoo1 and voodoo2 graphic card",
"1.0.0",
0,
};
void fn_vInitDllIdentity( void )
{
memcpy( &g_stGliDrvId, &stGlide2Id, sizeof( tdstGliDriverIdentity ) );
}

View File

@@ -0,0 +1,482 @@
#include "GLD.h"
#include "GEO.h"
#include "TEX.h"
#include "gli_st.h"
#include "textu_st.h"
#include "texture.h"
#include "FIL.h"
#define __MSC__
#include <glide.h>
#include "TextuDFX.h"
#include "DLLCom.h"
extern GrHwConfiguration hwconfig;
extern long GLI_gl_MaxTmuAvailable;
short TEXTURETWIDDLED[1024L*1024L];
/*
----------------------------------------------------------------------------------------
Structure for texture memory block (use to load texture into VRam)
----------------------------------------------------------------------------------------
*/
typedef struct tdstTextureMemoryBlock_
{
long lTmu;
long lStart;
long lCurrent;
long lEnd;
} tdstTextureMemoryBlock;
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
long GLI_fn_lGetTotalTextureMemorySize( void )
{
long i,lSize;
lSize = 0;
for (i = 0 ; i < GLI_gl_MaxTmuAvailable; i++)
lSize += grTexMaxAddress( i ) - grTexMinAddress( i );
return (lSize);
}
/*
----------------------------------------------------------------------------------------
Description : get video memory size taken by a given texture
----------------------------------------------------------------------------------------
*/
long GLI_DRV_lGetSizeOfTexture( GLI_tdstTexture *p_stTexture )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lTextureSize;
long lRef, lSize;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
lTextureSize = p_stTexture->lHeight * p_stTexture->lWidth;
/*
* If aspect ratio is too big, texture will waste memory (8:1 is the max aspect ratio for voodoo)
*/
{
unsigned long ulRatio;
if( p_stTexture->lHeight > p_stTexture->lWidth )
ulRatio = p_stTexture->lHeight / p_stTexture->lWidth;
else
ulRatio = p_stTexture->lWidth / p_stTexture->lHeight;
if( ulRatio > 8 )
lTextureSize <<= ulRatio >> 4;
}
/*
* 8 bits
*/
if (!(p_stTexture->lTextureCaps & GLI_C_lPaletteTexture))
lTextureSize <<= 1;
/*
* mipmap
*/
if (p_stTexture ->lNumberOfLod)
{
lRef = (p_stTexture->lWidth > p_stTexture->lHeight) ? p_stTexture->lHeight : p_stTexture->lWidth;
lSize = lTextureSize;
while ( lRef )
{
lSize >>= 2;
lRef >>= 1;
lTextureSize += lSize;
}
}
/*
* alignment
*/
if ( lTextureSize & 0x7 )
{
lTextureSize += 8 - (lTextureSize & 0x7);
}
GLI_MDRV_TEXBENCH_vSetTextureSize( p_stTexture, TEXBENCH_C_cComputedSize, lTextureSize );
return lTextureSize;
}
/*
----------------------------------------------------------------------------------------
Description : get correspondante GRLOd constant
----------------------------------------------------------------------------------------
*/
static long GLI_lFindGrLOD(long lvalue)
{
if (lvalue == 256) return GR_LOD_256;
if (lvalue == 128) return GR_LOD_128;
if (lvalue == 64) return GR_LOD_64;
if (lvalue == 32) return GR_LOD_32;
if (lvalue == 16) return GR_LOD_16;
if (lvalue == 8) return GR_LOD_8;
if (lvalue == 4) return GR_LOD_4;
if (lvalue == 2) return GR_LOD_2;
if (lvalue == 1) return GR_LOD_1;
return 0;
}
/*
----------------------------------------------------------------------------------------
Description : compute texture aspect ration
----------------------------------------------------------------------------------------
*/
long GLI_lFindAspectRatioAndMultiplySize(GLI_tdstTexture *p_stTexture)
{
long lValue1,lValue2;
GLI_tdstTextureDFX *p_stSpecParam;
p_stSpecParam=p_stTexture->p_stSpecParam;
lValue1 = p_stTexture -> lWidth;
lValue2 = p_stTexture -> lHeight;
if ((lValue1>>3) == lValue2)
{
p_stSpecParam -> lMultiplyWidth = 255.0f;
p_stSpecParam -> lMultiplyHeight = 31.0f;
return GR_ASPECT_8x1;
}
if ((lValue1>>2) == lValue2)
{
p_stSpecParam -> lMultiplyWidth = 255.0f;
p_stSpecParam -> lMultiplyHeight = 63.0f;
return GR_ASPECT_4x1;
}
if ((lValue1>>1) == lValue2)
{
p_stSpecParam -> lMultiplyWidth = 255.0f;
p_stSpecParam -> lMultiplyHeight =127.0f;
return GR_ASPECT_2x1;
}
if ((lValue1) == (lValue2))
{
p_stSpecParam -> lMultiplyWidth = 255.0f;
p_stSpecParam -> lMultiplyHeight =255.0f;
return GR_ASPECT_1x1;
}
if ((lValue1) == (lValue2>>1))
{
p_stSpecParam -> lMultiplyWidth = 127.0f;
p_stSpecParam -> lMultiplyHeight =255.0f;
return GR_ASPECT_1x2;
}
if ((lValue1) == (lValue2>>2))
{
p_stSpecParam -> lMultiplyWidth = 63.0f;
p_stSpecParam -> lMultiplyHeight =255.0f;
return GR_ASPECT_1x4;
}
if ((lValue1) == (lValue2>>3))
{
p_stSpecParam -> lMultiplyWidth = 31.0f;
p_stSpecParam -> lMultiplyHeight =255.0f;
return GR_ASPECT_1x8;
}
return 0; /* GROS BUG */
}
/*
----------------------------------------------------------------------------------------
Description : Compress texture and compute mip map levels
----------------------------------------------------------------------------------------
*/
static void GLI_vCompressTex ( GLI_tdstTexture *p_stTexture , GrTexInfo *p_stTexInfo )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lCurrentDecalTextureForMipMapping,Verify;
unsigned short *p_Destination;
unsigned char *p_ucDest;
unsigned long *p_ulPalette;
long lNbLod;
unsigned short lWidth, lHeight;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (p_stTexture == NULL )
return;
lCurrentDecalTextureForMipMapping = 0;
p_Destination = TEXTURETWIDDLED;
p_stTexture->p_vBitMap = GLI_gs_p_ConvertBufferMipMapping;
/*
* load texture
*/
GLI_MDRV_xLoadTextureInTexelField(p_stTexture, GLI_gs_p_ConvertBufferMipMapping, TRUE);
/*
* check for alpha texture
*/
if ((p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture) || (p_stTexture -> lTextureCaps & GLI_C_lNZFilteredTexture))
{
Verify = GLI_MDRV_vVerifyTextureIsRealyAlpha(p_stTexture);
if ((Verify & 0xE0000000) == 0xE0000000)
p_stTexture -> lTextureCaps &= 0xffffffff - GLI_C_lAlphaTexture;
if ((Verify & 0x80000000) == 0x80000000)
p_stTexture -> lTextureCaps &= 0xffffffff - GLI_C_lNZFilteredTexture;
}
p_stTexture->p_vBitMap = GLI_gs_p_ConvertBufferMipMapping;
lNbLod = p_stTexture->lNumberOfLod;
lWidth = p_stTexture->lWidth;
lHeight = p_stTexture->lHeight;
if ( p_stTexture->lTextureCaps & GLI_C_lPaletteTexture )
{
p_ucDest = (char *) p_Destination;
p_ulPalette = (unsigned long *) p_stTexture->p_vColorTable;
((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_P_8;
memcpy( p_ucDest, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth );
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
GLI_MDRV_vDivideBitmapSurfaceBy2Palette( (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_ulPalette, p_stTexture->lHeight, p_stTexture->lWidth );
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
memcpy( p_ucDest + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth );
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
/* TEST sur nouveau traitement sur texture NZ : marche pas bien pour l'instant */
else if ( p_stTexture->lTextureCaps & GLI_C_lAlphaTest )
{
((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_1555;
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination)) ;
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture->lHeight, p_stTexture->lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else if ((!(p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)) && (p_stTexture -> lTextureCaps & GLI_C_lNZFilteredTexture))
{
((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_1555;
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination)) ;
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth);
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else if (p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)
{
((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_4444;
GLI_MDRV_vCompressTex4444( p_stTexture , (void *)(p_Destination)) ;
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight , p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight , p_stTexture -> lWidth );
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
GLI_MDRV_vCompressTex4444( p_stTexture , (void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else
{
((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_RGB_565;
GLI_MDRV_vCompressTex565( p_stTexture , (void *)(p_Destination)) ;
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth);
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
GLI_MDRV_vCompressTex565 ( p_stTexture , (void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
p_stTexture->lWidth = lWidth;
p_stTexture->lHeight = lHeight;
}
/*
----------------------------------------------------------------------------------------
Description : adjust Tex info parameters
----------------------------------------------------------------------------------------
*/
static void GLI_vComputeGrTexInfo ( GLI_tdstTexture *p_stTexture , GrTexInfo *p_stTexInfo )
{
if (p_stTexture -> lHeight >= p_stTexture -> lWidth)
{
p_stTexInfo -> smallLod = GLI_lFindGrLOD(p_stTexture -> lHeight >> p_stTexture -> lNumberOfLod);
p_stTexInfo -> largeLod = GLI_lFindGrLOD(p_stTexture -> lHeight );
} else
{
p_stTexInfo -> smallLod = GLI_lFindGrLOD(p_stTexture -> lWidth >> p_stTexture -> lNumberOfLod);
p_stTexInfo -> largeLod = GLI_lFindGrLOD(p_stTexture -> lWidth );
}
p_stTexInfo -> aspectRatio = GLI_lFindAspectRatioAndMultiplySize(p_stTexture);
p_stTexInfo -> data = TEXTURETWIDDLED;
}
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vDownLoadTextures(long bRestore, long _lTextureMode, BOOL bReloading )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tdstTextureMemoryBlock st_TexMemBlock[6];
tdstTextureMemoryBlock *pst_TexMemBlock;
long lNbTexMemBlocks;
long i;
long lMemoryNeeded;
long lTextureCounter;
GLI_tdstTexture *p_stTexture;
GLI_tdstTextureDFX *p_stSpecParam;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* init texture block;
*/
lNbTexMemBlocks = 0;
for ( i = 0; i < GLI_gl_MaxTmuAvailable; i++)
{
st_TexMemBlock[ lNbTexMemBlocks ].lTmu = i;
st_TexMemBlock[ lNbTexMemBlocks ].lStart = grTexMinAddress( i );
st_TexMemBlock[ lNbTexMemBlocks ].lCurrent = st_TexMemBlock[ lNbTexMemBlocks ].lStart;
lMemoryNeeded = grTexMaxAddress( i );
if (lMemoryNeeded > 2097152 )
{
st_TexMemBlock[ lNbTexMemBlocks++ ].lEnd = 2097152;
st_TexMemBlock[ lNbTexMemBlocks ].lTmu = i;
st_TexMemBlock[ lNbTexMemBlocks ].lStart = 2097152;
st_TexMemBlock[ lNbTexMemBlocks ].lCurrent = st_TexMemBlock[ lNbTexMemBlocks ].lStart;
}
st_TexMemBlock[ lNbTexMemBlocks++ ].lEnd = lMemoryNeeded;
}
grTexMipMapMode( GR_TMU0, GR_MIPMAP_NEAREST_DITHER, FXFALSE);
grTexMipMapMode( GR_TMU1, GR_MIPMAP_NEAREST_DITHER, FXFALSE);
/*
* load all textures
*/
for (lTextureCounter = 0; lTextureCounter < GLI_C_lNBMaxOfTextures ; lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] == GLI_TEXIsUnallocated )
continue;
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
if (p_stTexture == NULL)
continue;
p_stTexture->p_stSpecParam = (GLI_tdstTextureDFX *) GLI_MDRV_p_vTmpMalloc( sizeof(GLI_tdstTextureDFX) );
p_stSpecParam = p_stTexture->p_stSpecParam;
p_stTexture -> bIsAvailable = 0;
p_stSpecParam -> lMultiplyWidth = 0.0f;
p_stSpecParam -> lMultiplyHeight = 0.0f;
p_stSpecParam -> xEvenOdd = GR_MIPMAPLEVELMASK_BOTH ;
GLI_vComputeGrTexInfo( p_stTexture , &p_stSpecParam->stInfoBitmapGlide ) ;
GLI_vCompressTex( p_stTexture , &p_stSpecParam->stInfoBitmapGlide ) ;
lMemoryNeeded = grTexTextureMemRequired( p_stSpecParam -> xEvenOdd , &p_stSpecParam -> stInfoBitmapGlide );
/*
* search a block that accept current texture
*/
pst_TexMemBlock = st_TexMemBlock;
for ( i = 0; i < lNbTexMemBlocks; i++, pst_TexMemBlock++ )
{
if (lMemoryNeeded < pst_TexMemBlock->lEnd - pst_TexMemBlock->lCurrent )
break;
}
if ( i == lNbTexMemBlocks)
continue;
/* bench texture size */
GLI_MDRV_TEXBENCH_vSetTextureSize( p_stTexture, 1, lMemoryNeeded );
p_stTexture -> bIsAvailable = 1;
p_stSpecParam->xTmuNumber = pst_TexMemBlock->lTmu;
p_stSpecParam->xStartAddress = pst_TexMemBlock->lCurrent;
pst_TexMemBlock->lCurrent += lMemoryNeeded;
grTexDownloadMipMap (p_stSpecParam -> xTmuNumber,p_stSpecParam -> xStartAddress ,p_stSpecParam -> xEvenOdd ,&p_stSpecParam -> stInfoBitmapGlide );
}
}
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vUnLoadTextures()
{
long lTextureCounter;
GLI_tdstTexture *p_stTexture;
for ( lTextureCounter = 0 ; lTextureCounter < C_lMaxNumberOfTexture ;lTextureCounter ++)
{
if ( gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated )
{
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
if (p_stTexture != NULL)
{
if (p_stTexture->bIsAvailable)
{
if (p_stTexture-> p_stSpecParam)
GLI_MDRV_vTmpFree( (void *) p_stTexture-> p_stSpecParam );
p_stTexture->bIsAvailable = 0;
}
}
}
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,26 @@
#ifndef GLI_TEXTUDFX_H
#define GLI_TEXTUDFX_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern GrChipID_t GLI_GLIDE1_xTmuNumber;
typedef struct GLI_tdstTextureDFX_
{
float lMultiplyHeight;
float lMultiplyWidth;
long lMultiplyHeightPowerOf2;
long lMultiplyWidthPowerOf2;
GrChipID_t xTmuNumber;
FxU32 xStartAddress;
FxU32 xEvenOdd;
GrTexInfo stInfoBitmapGlide;
} GLI_tdstTextureDFX;
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* GLI_TEXTUDFX_H*/

View File

@@ -0,0 +1,74 @@
/* only macros needed to get/set attributes of a screen vertex*/
#ifndef GLI_VTX_GLIDE2
#define __MSC__
#include <GLIDE.H>
#include "drawflags.h"
#define GLI_GLIDE1_CurrentTmu 0
/* GET*/
#define GetX(a) a->x
#define GetY(a) a->y
#define GetZ(a) a->oow
#define GetPackedColor(a) *(unsigned long *)&(a->r)
#define GetPackedSpecular(a,b)
#define GetU(a) a->tmuvtx[GLI_GLIDE1_CurrentTmu].sow
#define GetV(a) a->tmuvtx[GLI_GLIDE1_CurrentTmu].tow
#define GetRed(pVtx) pVtx->r
#define GetGreen(pVtx) pVtx->g
#define GetBlue(pVtx) pVtx->b
#define GetAlpha(pVtx) pVtx->a
/* SET*/
#define SetX(a,b) a->x = b
#define SetY(a,b) a->y = b
#define SetZ(a,b) a->oow = b
#define SetPackedColor(a,b) *(unsigned long *)&(a->r) = b
/* don't bother packing and unpacking colors*/
#define SetRGBA(pVtx, red, green, bleu, alpha) \
pVtx->r = (float) red; \
pVtx->g = (float) green; \
pVtx->b = (float) bleu; \
pVtx->a = (float) alpha;
#define SetPackedSpecular(a,b)
#define SetU(a,b) a->tmuvtx[GLI_GLIDE1_CurrentTmu].sow = b
#define SetV(a,b) a->tmuvtx[GLI_GLIDE1_CurrentTmu].tow = b
#define SetU_Cpy(a,b) *(unsigned long *)&a->tmuvtx[GLI_GLIDE1_CurrentTmu].sow = *(unsigned long *)&b
#define SetV_Cpy(a,b) *(unsigned long *)&a->tmuvtx[GLI_GLIDE1_CurrentTmu].tow = *(unsigned long *)&b
/* GET*/
#define GetXSt(a) a.x
#define GetYSt(a) a.y
#define GetZSt(a) a.oow
#define GetPackedColorSt(a) *(unsigned long *)&(a.r)
#define GetPackedSpecularSt(a,b)
#define GetUSt(a) a.tmuvtx[GLI_GLIDE1_CurrentTmu].sow
#define GetVSt(a) a.tmuvtx[GLI_GLIDE1_CurrentTmu].tow
#define GetRedSt(pVtx) pVtx.r
#define GetGreenSt(pVtx) pVtx.g
#define GetBlueSt(pVtx) pVtx.b
#define GetAlphaSt(pVtx) pVtx.a
/* SET*/
#define SetXSt(a,b) a.x = b
#define SetYSt(a,b) a.y = b
#define SetZSt(a,b) a.oow = b
#define SetPackedColorSt(a,b) *(unsigned long *)&(a.r) = b
/* don't bother packing and unpacking colors*/
#define SetRGBASt(pVtx, red, green, bleu, alpha) \
pVtx.r = (float) red; \
pVtx.g = (float) green; \
pVtx.b = (float) bleu; \
pVtx.a = (float) alpha;
#define SetPackedSpecularSt(a,b)
#define SetUSt(a,b) a.tmuvtx[GLI_GLIDE1_CurrentTmu].sow = b
#define SetVSt(a,b) a.tmuvtx[GLI_GLIDE1_CurrentTmu].tow = b
#define SetU_CpySt(a,b) *(unsigned long *)&a.tmuvtx[GLI_GLIDE1_CurrentTmu].sow = *(unsigned long *)&b
#define SetV_CpySt(a,b) *(unsigned long *)&a.tmuvtx[GLI_GLIDE1_CurrentTmu].tow = *(unsigned long *)&b
/* Fond de roulement GLIDE1*/
/* GLOBALS*/
#define GLI_tdScreenVertx GrVertex
#endif /* GLI_VTX_GLIDE2*/

View File

@@ -0,0 +1,5 @@
SCC = This is a source code control file
[Glide2.vcproj]
SCC_Aux_Path = "P4SCC#srvperforce-ma:1666##raymandata##Editor"
SCC_Project_Name = Perforce Project

View File

@@ -0,0 +1,212 @@
# Microsoft Developer Studio Project File - Name="Glide3" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=Glide3 - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Glide3.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Glide3.mak" CFG="Glide3 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Glide3 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Glide3 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Glide3 - Win32 Retail" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""$/cpa/tempgrp/GliGlou/Drivers/Glide3", MVPAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "Glide3 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "temp\Release"
# PROP Intermediate_Dir "temp\Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "t:\mssdk\include" /I "t:\3dFX\sdk\GLIDE3x\SRC\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /D "NDEBUG" /D "_WINDOWS" /D "USE_PROFILER" /D "WIN32" /D "GLIDE3" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"x:\cpa\exe\main\dll\GliVD2vr.dll"
!ELSEIF "$(CFG)" == "Glide3 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "temp\Debug"
# PROP Intermediate_Dir "temp\Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "t:\mssdk\include" /I "t:\3dFX\sdk\GLIDE3x\SRC\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /D "_DEBUG" /D "VISUAL" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /D "WIN32" /D "GLIDE3" /U "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /U "x:\cpa\public" /U "x:\cpa\public\gli" /U "x:\cpa\public\geo" /U "inc" /U "x:\cpa\tempgrp\gliglou\multidrv\inc" /U "..\\" /U "t:\mssdk\include" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"x:\cpa\exe\main\dll\GliVD2vd.dll" /pdbtype:sept
!ELSEIF "$(CFG)" == "Glide3 - Win32 Retail"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Glide3__"
# PROP BASE Intermediate_Dir "Glide3__"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Temp\Retail"
# PROP Intermediate_Dir "Temp\Retail"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "t:\3dFX\sdk\GLIDE3x\SRC\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /D "NDEBUG" /D "_WINDOWS" /D "RETAIL" /D "WIN32" /D "GLIDE3" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"x:\cpa\exe\main\dll\GliVD2vf.dll"
!ENDIF
# Begin Target
# Name "Glide3 - Win32 Release"
# Name "Glide3 - Win32 Debug"
# Name "Glide3 - Win32 Retail"
# Begin Group "Src"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Acces_ALL.c
!IF "$(CFG)" == "Glide3 - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "Glide3 - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "Glide3 - Win32 Retail"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\ClipTRIANGLES.c
# End Source File
# Begin Source File
SOURCE=..\DllCom.c
# End Source File
# Begin Source File
SOURCE=.\Src\Glide3_Acces.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\Src\Glide3_Dll.c
# End Source File
# Begin Source File
SOURCE=.\Src\Glide3_Domat.c
# End Source File
# Begin Source File
SOURCE=.\Src\Glide3_HdwTx.c
# End Source File
# Begin Source File
SOURCE=.\Src\Glide3_Init.c
# End Source File
# Begin Source File
SOURCE=..\GliDLL.def
# End Source File
# End Group
# Begin Group "inc"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\DllCom.h
# End Source File
# Begin Source File
SOURCE=.\inc\Glide2To3.h
# End Source File
# Begin Source File
SOURCE=.\inc\TextuDFX.h
# End Source File
# End Group
# Begin Group "lib"
# PROP Default_Filter ""
# Begin Source File
SOURCE=T:\mssdk\lib\ddraw.lib
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\ddraw.lib
# End Source File
# Begin Source File
SOURCE=T:\3Dfx\Sdk\Glide3x\Src\Lib\Win32\glide3x.lib
# End Source File
# End Group
# Begin Source File
SOURCE=.\Glide3.mak
# End Source File
# End Target
# End Project

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,508 @@
#define __MSC__
#include <GLIDE.H>
#include "TextuDFX.h"
#include "PRF.h"
#include "drawflags.h"
#include "Glide2To3.h"
//#define GLI_GLIDE1_CurrentTmu 0
GrChipID_t GLI_GLIDE1_xTmuNumber = 0;
// GET
#define GetX(a) a.x
#define GetY(a) a.y
#define GetZ(a) a.oow
#define GetPackedColor(a) *(unsigned long *)&a.r
#define GetPackedSpecular(a,b)
#define GetU(a) a.tmuvtx[GLI_GLIDE1_xTmuNumber].sow
#define GetV(a) a.tmuvtx[GLI_GLIDE1_xTmuNumber].tow
// SET
#define SetX(a,b) a.x = b
#define SetY(a,b) a.y = b
#define SetZ(a,b) a.oow = b
#define SetPackedColor(a,b) *(unsigned long *)&a.r = b
//#define SetPackedSpecular(a,b) *(unsigned long *)&a.g = b
#define SetPackedSpecular(a,b)
#define SetU(a,b) a.tmuvtx[GLI_GLIDE1_xTmuNumber].sow = b
#define SetV(a,b) a.tmuvtx[GLI_GLIDE1_xTmuNumber].tow = b
#define SetU_Cpy(a,b) *(unsigned long *)&a.tmuvtx[GLI_GLIDE1_xTmuNumber].sow = *(unsigned long *)&b
#define SetV_Cpy(a,b) *(unsigned long *)&a.tmuvtx[GLI_GLIDE1_xTmuNumber].tow = *(unsigned long *)&b
// constante <20> ne d<>finir que pour d<>bugger ou pour anti_bug temporaire
//#define GLI_DEBUG_TESTALLVERTICES
#if defined(USE_PROFILER) // MT {
#define M_grDrawTriangle(a,b,c)\
{\
grDrawTriangle((a),(b),(c));\
PRF_MDRV_vSetIndependantVariable( PRF_C_ulIdpDisplayedTriangle , 1 );\
}
#else
#define M_grDrawTriangle grDrawTriangle
#endif // MT }
// Fond de roulement GLIDE1
// GLOBALS
GLI_tdScreenVertx CurrentDestXYZ[4];
#define GLI_M_RestoreCW()
void GLI_BeforeDraw()
{
};
void GLI_AfterDraw()
{\
}
#define GLI_M_Restore3DFXColor(P)\
{\
P . g = (float)((unsigned char *)&(P.r))[1];\
P . b = (float)((unsigned char *)&(P.r))[0];\
P . a = (float)((unsigned char *)&(P.r))[3];\
P . r = (float)((unsigned char *)&(P.r))[2];\
P . tmuvtx[GLI_GLIDE1_xTmuNumber].sow *= P . oow * GLI_BIG_GLOBALS -> fMulV;\
P . tmuvtx[GLI_GLIDE1_xTmuNumber].tow *= P . oow * GLI_BIG_GLOBALS -> fMulU;\
}
GLI_FuncNodeBegin(GLI_vDrawTriangle)
{
GLI_M_Restore3DFXColor(CurrentDestXYZ[0]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[1]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[2]);
#ifdef GLI_DEBUG_TESTALLVERTICES
if (
(CurrentDestXYZ[0].y < 0.0f) || (CurrentDestXYZ[1].y < 0.0f) || (CurrentDestXYZ[2].y < 0.0f) || (CurrentDestXYZ[0].y > 480.0f) || (CurrentDestXYZ[1].y > 480.0f) || (CurrentDestXYZ[2].y > 480.0f) ||
(CurrentDestXYZ[0].x < 0.0f) || (CurrentDestXYZ[1].x < 0.0f) || (CurrentDestXYZ[2].x < 0.0f) || (CurrentDestXYZ[0].x > 640.0f) || (CurrentDestXYZ[1].x > 640.0f) || (CurrentDestXYZ[2].x > 640.0f)
)
return;
#endif
M_grDrawTriangle( &CurrentDestXYZ[0], &CurrentDestXYZ[1], &CurrentDestXYZ[2]);
}
GLI_FuncNodeBegin(GLI_vDrawWiredTriangle)
{
GLI_M_Restore3DFXColor(CurrentDestXYZ[0]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[1]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[2]);
#ifdef GLI_DEBUG_TESTALLVERTICES
if (
(CurrentDestXYZ[0].y < 0.0f) || (CurrentDestXYZ[1].y < 0.0f) || (CurrentDestXYZ[2].y < 0.0f) || (CurrentDestXYZ[0].y > 480.0f) || (CurrentDestXYZ[1].y > 480.0f) || (CurrentDestXYZ[2].y > 480.0f) ||
(CurrentDestXYZ[0].x < 0.0f) || (CurrentDestXYZ[1].x < 0.0f) || (CurrentDestXYZ[2].x < 0.0f) || (CurrentDestXYZ[0].x > 640.0f) || (CurrentDestXYZ[1].x > 640.0f) || (CurrentDestXYZ[2].x > 640.0f)
)
return;
#endif
grDrawLine( &CurrentDestXYZ[0], &CurrentDestXYZ[1] );
grDrawLine( &CurrentDestXYZ[1], &CurrentDestXYZ[2] );
grDrawLine( &CurrentDestXYZ[0], &CurrentDestXYZ[2] );
}
GLI_FuncNodeBegin(GLI_vZSortTriangle)
{
/* draw */
float ZMax;
if ((unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint > (unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_TableOfPoints + ((3L << GLI_MaxZListeTrianglesPO2)* sizeof (GLI_tdScreenVertx)) - 3L * sizeof(GLI_tdScreenVertx))
return;
GLI_M_Restore3DFXColor(CurrentDestXYZ[0]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[1]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[2]);
memcpy(GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint , CurrentDestXYZ , sizeof(GLI_tdScreenVertx) * 3L);
if (*(unsigned long *)&GetZ(CurrentDestXYZ[0]) < *(unsigned long *)&GetZ(CurrentDestXYZ[1]))
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[0]);
else
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[1]);
if (*(unsigned long *)&ZMax > *(unsigned long *)&GetZ(CurrentDestXYZ[2]))
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[2]);
GLI_v_AddNodeInZList(ZMax);
(unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint += sizeof(GLI_tdScreenVertx) * 3L;
PRF_MDRV_vSetIndependantVariable( PRF_C_ulIdpDisplayedTriangle , 1 );
}
void GLI_DrawQuad(void)
{
/* draw 2 triangles */
GLI_M_Restore3DFXColor(CurrentDestXYZ[0]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[1]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[2]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[3]);
if ( GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_TrianglesMustBeSorted )
{
GLI_BIG_GLOBALS -> lCurrentDrawMask &= ~GLI_C_lIsGouraud;
if ((unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint > (unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_TableOfPoints + ((3L << GLI_MaxZListeTrianglesPO2)* sizeof (GLI_tdScreenVertx)) - 4L * sizeof(GLI_tdScreenVertx))
return;
memcpy(GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint , CurrentDestXYZ , sizeof(GLI_tdScreenVertx) * 4L);
GLI_v_AddNodeInZList(GetZ(CurrentDestXYZ[0]));
(unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint += sizeof(GLI_tdScreenVertx) * 4L;
}
else
{
#ifdef GLI_DEBUG_TESTALLVERTICES
if (
(CurrentDestXYZ[0].y < 0.0f) || (CurrentDestXYZ[1].y < 0.0f) || (CurrentDestXYZ[2].y < 0.0f) || (CurrentDestXYZ[3].y < 0.0f) || (CurrentDestXYZ[0].y > 480.0f) || (CurrentDestXYZ[1].y > 480.0f) || (CurrentDestXYZ[2].y > 480.0f) || (CurrentDestXYZ[3].y > 480.0f) ||
(CurrentDestXYZ[0].x < 0.0f) || (CurrentDestXYZ[1].x < 0.0f) || (CurrentDestXYZ[2].x < 0.0f) || (CurrentDestXYZ[3].x < 0.0f) || (CurrentDestXYZ[0].x > 640.0f) || (CurrentDestXYZ[1].x > 640.0f) || (CurrentDestXYZ[2].x > 640.0f) || (CurrentDestXYZ[3].x > 640.0f)
)
return;
#endif
M_grDrawTriangle( &CurrentDestXYZ[0], &CurrentDestXYZ[1], &CurrentDestXYZ[2]);
M_grDrawTriangle( &CurrentDestXYZ[3], &CurrentDestXYZ[2], &CurrentDestXYZ[0]);
PRF_MDRV_vIncreaseVariable( PRF_C_ulVarFaces + PRF_MDRV_lGetIndependantVariable( PRF_C_ulIdpDynOrSta ), PRF_C_pvDisplayed, 2 );
PRF_MDRV_vSetIndependantVariable( PRF_C_ulIdpDisplayedFaces, 1 );
}
}
void GLI_DrawLine(void)
{
GLI_M_Restore3DFXColor(CurrentDestXYZ[0]);
GLI_M_Restore3DFXColor(CurrentDestXYZ[1]);
#ifdef GLI_DEBUG_TESTALLVERTICES
if(
(CurrentDestXYZ[0].y < 0.0f) || (CurrentDestXYZ[1].y < 0.0f) || (CurrentDestXYZ[0].y > 480.0f) || (CurrentDestXYZ[1].y > 480.0f) ||
(CurrentDestXYZ[0].x < 0.0f) || (CurrentDestXYZ[1].x < 0.0f) || (CurrentDestXYZ[0].x > 640.0f) || (CurrentDestXYZ[1].x > 640.0f)
)
return;
#endif
grDrawLine ( &CurrentDestXYZ[0], &CurrentDestXYZ[1] );
}
void GLI_vDrawZSortedTriangle(void *p_3Point)
{
#ifdef GLI_DEBUG_TESTALLVERTICES
if (
( ((GLI_tdScreenVertx *)p_3Point)->y < 0.0f) || (((GLI_tdScreenVertx *)p_3Point+1)->y < 0.0f) || (((GLI_tdScreenVertx *)p_3Point+2)->y < 0.0f) || (((GLI_tdScreenVertx *)p_3Point)->y > 480.0f) || (((GLI_tdScreenVertx *)p_3Point+1)->y > 480.0f) || (((GLI_tdScreenVertx *)p_3Point+2)->y > 480.0f) ||
( ((GLI_tdScreenVertx *)p_3Point)->x < 0.0f) || (((GLI_tdScreenVertx *)p_3Point+1)->x < 0.0f) || (((GLI_tdScreenVertx *)p_3Point+2)->x < 0.0f) || (((GLI_tdScreenVertx *)p_3Point)->x > 640.0f) || (((GLI_tdScreenVertx *)p_3Point+1)->x > 640.0f) || (((GLI_tdScreenVertx *)p_3Point+2)->x > 640.0f)
)
return;
#endif
grDrawTriangle( (GLI_tdScreenVertx *)p_3Point, ((GLI_tdScreenVertx *)p_3Point) + 1, ((GLI_tdScreenVertx *)p_3Point) + 2);
}
void GLI_vDrawZSortedQuad(void *p_3Point)
{
#ifdef GLI_DEBUG_TESTALLVERTICES
if (
( ((GLI_tdScreenVertx *)p_3Point)->y < 0.0f) || (((GLI_tdScreenVertx *)p_3Point+1)->y < 0.0f) || (((GLI_tdScreenVertx *)p_3Point+2)->y < 0.0f) || (((GLI_tdScreenVertx *)p_3Point+3)->y < 0.0f) || (((GLI_tdScreenVertx *)p_3Point)->y > 480.0f) || (((GLI_tdScreenVertx *)p_3Point+1)->y > 480.0f) || (((GLI_tdScreenVertx *)p_3Point+2)->y > 480.0f) || (((GLI_tdScreenVertx *)p_3Point+3)->y > 480.0f) ||
( ((GLI_tdScreenVertx *)p_3Point)->x < 0.0f) || (((GLI_tdScreenVertx *)p_3Point+1)->x < 0.0f) || (((GLI_tdScreenVertx *)p_3Point+2)->x < 0.0f) || (((GLI_tdScreenVertx *)p_3Point+3)->x < 0.0f) || (((GLI_tdScreenVertx *)p_3Point)->x > 640.0f) || (((GLI_tdScreenVertx *)p_3Point+1)->x > 640.0f) || (((GLI_tdScreenVertx *)p_3Point+2)->x > 640.0f) || (((GLI_tdScreenVertx *)p_3Point+3)->x > 640.0f)
)
return;
#endif
grDrawTriangle( (GLI_tdScreenVertx *)p_3Point, ((GLI_tdScreenVertx *)p_3Point) + 1, ((GLI_tdScreenVertx *)p_3Point) + 2);
grDrawTriangle( ((GLI_tdScreenVertx *)p_3Point) + 3, ((GLI_tdScreenVertx *)p_3Point) + 2, ((GLI_tdScreenVertx *)p_3Point) + 0);
}
void GLI_vAddDrawFunc()
{
if (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_TrianglesMustBeSorted)
{
GLI_M_AddFunc(GLI_vZSortTriangle);
ulFuncMask |= Flag_GLI_vZSortTriangle;
}
else if ( (GLI_BIG_GLOBALS->lCurrentDrawMask & GLI_C_lIsNotWired) == 0 )
{
GLI_M_AddFunc(GLI_vDrawWiredTriangle);
ulFuncMask |= Flag_GLI_vDrawWiredTriangle;
}
else
{
GLI_M_AddFunc(GLI_vDrawTriangle);
ulFuncMask |= Flag_GLI_vDrawTriangle;
}
}
void GLI_ReComputeClippingMask()
{
*(float *)&fX_CMP_Optimize = GLI_BIG_GLOBALS->fXMaxClipping;
*(float *)&fY_CMP_Optimize = GLI_BIG_GLOBALS->fYMaxClipping;
*(float *)&fXMin_CLIP_Optimize = GLI_BIG_GLOBALS->fXMinClipping;
*(float *)&fYMin_CLIP_Optimize = GLI_BIG_GLOBALS->fYMinClipping;
*(float *)&fXMax_CLIP_Optimize = GLI_BIG_GLOBALS->fXMaxClipping; // - 1.0f;
*(float *)&fYMax_CLIP_Optimize = GLI_BIG_GLOBALS->fYMaxClipping; // - 1.0f;
GLI_BIG_GLOBALS -> lClippingModeMask |= (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_lCLIP_ALL) << 4;
}
//********************************************************************************************
// Name: GLI_DRV_vSendSpriteToClip
// Goal: draw a sprite
// Code: Philippe Vimont
// OPTIMMIZED : No
//********************************************************************************************
void GLI_DRV_vSendSpriteToClip
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT
)
{
float fClipYMax, fClipYMin, fClipXMax, fClipXMin;
GLI_BeforeDraw();
if (a4_st2DVertex[0].xY == a4_st2DVertex[1].xY) /* Aligned sprite */
{
GLI_ReComputeClippingMask();
if ( ( *(long *) &a4_st2DVertex[0].xY > fYMax_CLIP_Optimize) || (*(long *) &a4_st2DVertex[2].xY < fYMin_CLIP_Optimize) || (*(long *) &a4_st2DVertex[0].xX < fXMin_CLIP_Optimize) || (*(long *) &a4_st2DVertex[1].xX > fXMax_CLIP_Optimize) )
return;
/*
* clip xMax
*/
if ( *(long *) &a4_st2DVertex[0].xX > fXMax_CLIP_Optimize )
{
fClipXMax = (GLI_BIG_GLOBALS->fXMaxClipping - a4_st2DVertex[1].xX) / ( a4_st2DVertex[0].xX - a4_st2DVertex[1].xX );
a4_st2DVertex[0].xX = a4_st2DVertex[3].xX = GLI_BIG_GLOBALS->fXMaxClipping;
}
else
fClipXMax = 1.0f;
/*
* clip xMin
*/
if ( *(long *) &a4_st2DVertex[1].xX < fXMin_CLIP_Optimize )
{
fClipXMin = (fClipXMax * ( GLI_BIG_GLOBALS->fXMinClipping - a4_st2DVertex[1].xX) ) / ( a4_st2DVertex[0].xX - a4_st2DVertex[1].xX );
a4_st2DVertex[1].xX = a4_st2DVertex[2].xX = GLI_BIG_GLOBALS->fXMinClipping;
}
else
fClipXMin = 0.0f;
/*
* clip yMin
*/
if ( *(long *) &a4_st2DVertex[0].xY < fYMin_CLIP_Optimize )
{
fClipYMin = (GLI_BIG_GLOBALS->fYMinClipping - a4_st2DVertex[2].xY) / ( a4_st2DVertex[0].xY - a4_st2DVertex[2].xY );
a4_st2DVertex[0].xY = a4_st2DVertex[1].xY = GLI_BIG_GLOBALS->fYMinClipping;
}
else
fClipYMin = 1.0f;
/*
* clip yMax
*/
if ( *(long *) &a4_st2DVertex[2].xY > fYMax_CLIP_Optimize )
{
fClipYMax = (fClipYMin * ( GLI_BIG_GLOBALS->fYMaxClipping - a4_st2DVertex[2].xY ) ) / ( a4_st2DVertex[0].xY - a4_st2DVertex[2].xY );
a4_st2DVertex[2].xY = a4_st2DVertex[3].xY = GLI_BIG_GLOBALS->fYMaxClipping;
}
else
fClipYMax = 0.0f;
}
else
{
if ( (a4_st2DVertex [0] . xY < 0.0f) || (a4_st2DVertex [1] . xY < 0.0f) || (a4_st2DVertex [2] . xY < 0.0f) || (a4_st2DVertex [3] . xY < 0.0f) ) return;
if ( (a4_st2DVertex [0] . xX < 0.0f) || (a4_st2DVertex [1] . xX < 0.0f) || (a4_st2DVertex [2] . xX < 0.0f) || (a4_st2DVertex [3] . xX < 0.0f) ) return;
if ( (a4_st2DVertex [0] . xY > 480.0f) || (a4_st2DVertex [1] . xY > 480.0f) || (a4_st2DVertex [2] . xY > 480.0f) || (a4_st2DVertex [3] . xY > 480.0f) ) return;
if ( (a4_st2DVertex [0] . xX > 640.0f) || (a4_st2DVertex [1] . xX > 640.0f) || (a4_st2DVertex [2] . xX > 640.0f) || (a4_st2DVertex [3] . xX > 640.0f) ) return;
fClipXMin = fClipYMax = 0.0f;
fClipYMin = fClipXMax = 1.0f;
}
GLI_M_InitSprite();
SetU(CurrentDestXYZ[0], fClipXMax );
SetV(CurrentDestXYZ[0], fClipYMin );
SetU(CurrentDestXYZ[1], fClipXMin );
SetV(CurrentDestXYZ[1], fClipYMin );
SetU(CurrentDestXYZ[2], fClipXMin );
SetV(CurrentDestXYZ[2], fClipYMax );
SetU(CurrentDestXYZ[3], fClipXMax );
SetV(CurrentDestXYZ[3], fClipYMax );
GLI_DrawQuad();
GLI_AfterDraw();
}
//********************************************************************************************
// Name: GLI_DRV_vSendSpriteToClipWithUV 1.0
// Goal:
// Code: Philippe Vimont / 1.0
// REM:
// OPTIMMIZED : No
//********************************************************************************************
void GLI_DRV_vSendSpriteToClipWithUV
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal *a8_stUVVertex,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_BeforeDraw();
GLI_M_InitSprite();
if (a4_st2DVertex [0] . xY < 0.0f) return;
if (a4_st2DVertex [1] . xY < 0.0f) return;
if (a4_st2DVertex [2] . xY < 0.0f) return;
if (a4_st2DVertex [3] . xY < 0.0f) return;
if (a4_st2DVertex [0] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [1] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [2] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [3] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if ( p_stGlobaleMT->p_stCurrentTexture->lIncrementIsEnable )
{
float fAddU, fAddV;
fAddU = p_stGlobaleMT-> p_stCurrentTexture -> fAddU;
fAddV = p_stGlobaleMT-> p_stCurrentTexture -> fAddV;
SetU(CurrentDestXYZ[2], a8_stUVVertex[4] + fAddU );
SetV(CurrentDestXYZ[2], a8_stUVVertex[4 + 1] + fAddV);
SetU(CurrentDestXYZ[3], a8_stUVVertex[6] + fAddU);
SetV(CurrentDestXYZ[3], a8_stUVVertex[6 + 1] + fAddV);
SetU(CurrentDestXYZ[0], a8_stUVVertex[0] + fAddU);
SetV(CurrentDestXYZ[0], a8_stUVVertex[0 + 1] + fAddV);
SetU(CurrentDestXYZ[1], a8_stUVVertex[2] + fAddU);
SetV(CurrentDestXYZ[1], a8_stUVVertex[2 + 1] + fAddV);
}
else
{
SetU(CurrentDestXYZ[2], a8_stUVVertex[4]);
SetV(CurrentDestXYZ[2], a8_stUVVertex[4 + 1]);
SetU(CurrentDestXYZ[3], a8_stUVVertex[6]);
SetV(CurrentDestXYZ[3], a8_stUVVertex[6 + 1]);
SetU(CurrentDestXYZ[0], a8_stUVVertex[0]);
SetV(CurrentDestXYZ[0], a8_stUVVertex[0 + 1]);
SetU(CurrentDestXYZ[1], a8_stUVVertex[2]);
SetV(CurrentDestXYZ[1], a8_stUVVertex[2 + 1]);
}
GLI_DrawQuad();
GLI_AfterDraw();
}
//********************************************************************************************
// Name: GLI_DRV_vSendSingleLineToClip
// Goal: draw a line
// Code: Vincent Lhullier
// OPTIMMIZED : No
//********************************************************************************************
void GLI_DRV_vSendSingleLineToClip
(
GLD_tdstViewportAttributes *p_stVpt ,
GLI_tdstAligned3DVector *p_stVertex1 ,
GLI_tdstAligned2DVector *p_st2DVertex1 ,
GLI_tdstAligned3DVector *p_stVertex2 ,
GLI_tdstAligned2DVector *p_st2DVertex2 ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT,
long lDrawModeMask, GEO_tdstColor *p_stColor
)
{
#ifdef _DEBUG
GLI_tdstAligned2DVector stP1, stP2;
GLI_tdstAligned3DVector st3DP1, st3DP2;
float fFactor;
p_st2DVertex1->ulPackedColor = 0xFFFFFFFF;
p_st2DVertex2->ulPackedColor = 0xFFFFFFFF;
/* xClipping */
if (p_st2DVertex1->xX < p_st2DVertex2->xX)
{
stP1 = *p_st2DVertex1;
st3DP1 = *p_stVertex1;
stP2 = *p_st2DVertex2;
st3DP2 = *p_stVertex2;
}
else
{
stP1 = *p_st2DVertex2;
st3DP1 = *p_stVertex2;
stP2 = *p_st2DVertex1;
st3DP2 = *p_stVertex1;
}
if (( stP2.xX < 0.0f) || ( stP1.xX > 640.0f ) )
return;
if ( stP1.xX < 0.0f )
{
fFactor = stP2.xX / (stP2.xX - stP1.xX );
stP1.xY = stP2.xY - ( stP2.xY - stP1.xY) * fFactor;
st3DP1.xZ = st3DP2.xZ - ( st3DP2.xY - st3DP1.xY) * fFactor;
stP1.xX = 0.0f;
}
if ( stP2.xX > 640.0f)
{
fFactor = (stP1.xX - 640.0f) / (stP2.xX - stP1.xX );
stP2.xY = stP1.xY - ( stP2.xY - stP1.xY) * fFactor;
st3DP2.xZ = st3DP1.xZ - ( st3DP2.xY - st3DP1.xY) * fFactor;
stP2.xX = 640.0f;
}
/* yClipping */
if ( stP1.xY < stP2.xY)
{
p_st2DVertex1 = &stP1;
p_stVertex1 = &st3DP1;
p_st2DVertex2 = &stP2;
p_stVertex2 = &st3DP2;
}
else
{
p_st2DVertex1 = &stP2;
p_stVertex1 = &st3DP2;
p_st2DVertex2 = &stP1;
p_stVertex2 = &st3DP1;
}
if (( p_st2DVertex2->xY < 0.0f) || ( p_st2DVertex1->xY > 480.0f ) )
return;
if ( p_st2DVertex1->xY < 0.0f )
{
fFactor = p_st2DVertex2->xY / (p_st2DVertex2->xY - p_st2DVertex1->xY );
p_st2DVertex1->xX = p_st2DVertex2->xX - ( p_st2DVertex2->xX - p_st2DVertex1->xX) * fFactor;
p_stVertex1->xZ = p_stVertex2->xZ - ( p_stVertex2->xZ - p_stVertex1->xZ) * fFactor;
p_st2DVertex1->xY = 0.0f;
}
if ( p_st2DVertex2->xY > 480.0f)
{
fFactor = (p_st2DVertex1->xY - 480.0f) / (p_st2DVertex2->xY - p_st2DVertex1->xY );
p_st2DVertex2->xX = p_st2DVertex1->xX - ( p_st2DVertex2->xX - p_st2DVertex1->xX) * fFactor;
p_stVertex2->xZ = p_stVertex1->xZ - ( p_stVertex2->xZ - p_stVertex1->xZ) * fFactor;
p_st2DVertex2->xY = 480.0f;
}
#else
if (p_st2DVertex1->xX < 0) return;
if (p_st2DVertex1->xY < 0) return;
if (p_st2DVertex1->xX > 640.0f) return;
if (p_st2DVertex1->xY > 480.0f) return;
if (p_st2DVertex2->xX < 0) return;
if (p_st2DVertex2->xY < 0) return;
if (p_st2DVertex2->xX > 640.0f) return;
if (p_st2DVertex2->xY > 480.0f) return;
#endif
GLI_M_InitLine();
GLI_BeforeDraw();
GLI_DrawLine();
GLI_AfterDraw();
}

View File

@@ -0,0 +1,27 @@
/*
=======================================================================================
Name : Glide2_Dll.c
Author : vincent lhullier Date :16/09/98
Description : specific DLL fonction
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "init_gli.h"
#include "DLLCom.h"
#include "DLLCaps.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tdstGliDriverIdentity stGlide2Id =
{
"Glide3",
"Driver for voodoo2 graphic card",
"1.0.0",
GLI_C_VersionGlide3
};
void fn_vInitDllIdentity( void )
{
memcpy( &g_stGliDrvId, &stGlide2Id, sizeof( tdstGliDriverIdentity ) );
}

View File

@@ -0,0 +1,729 @@
/******************************************************************************************
FILE : CLIPDomat.C
VERS : 1.00 \ Marc Villemain - version directX5
0.00 \ Philippe Vimont
DATE : 15.05.97
Select materials
*******************************************************************************************/
#include "Gli_st.h"
#include "GLI_Defn.h"
#include "polygon.h"
#include "mater_st.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "Liste.h"
#include "watrplan.h"
#include "proj.h"
#include "vpt3D.h"
#include "camera.h"
#include "material.h"
#include "texture.h"
#include "light.h"
#include "GliBench.h"
#include "TEX.h"
#define __MSC__
#include <GLIDE.H>
#include "TextuDFX.h"
#include "DLLCom.h"
#include "PRF.h"
#include "Glide2To3.h"
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef ZARMA
}
#endif
extern long GLI_g_lNumberOfFogTableEntries;
extern long GLI_g_lWDepthMinMaxValue[2];
GrFog_t Gli_C_xFogTable[ 64 ];
float GLI_ga_fFogDist[ 64 ];
static unsigned long gs_ulDepthBufferTestEnabled = 0;
void GLI_vSetFogParams( tdstFogParams *_p_stFogParams );
/*
=======================================================================================
Special function for displaying black polygon
it's for cinematic scene to hide non black for color
=======================================================================================
*/
GLI_tdScreenVertx g_stBlackTriangle[16];
long g_lNumberOfBlackTriangles = 0;
void GLI_DRV_vNoBlackPolygon()
{
g_lNumberOfBlackTriangles = 0;
}
void GLI_DRV_vAddBlackPolygon( long _lLeft, long _lTop, long _lRight, long _lBottom )
{
GLI_tdScreenVertx *p_stVertex;
p_stVertex = g_stBlackTriangle + g_lNumberOfBlackTriangles;
memset( p_stVertex, 0, 4 * sizeof( GLI_tdScreenVertx ) );
g_lNumberOfBlackTriangles += 4;
p_stVertex->x = (float) _lLeft;
p_stVertex->y = (float) _lBottom;
p_stVertex->oow = .8f;
p_stVertex++;
p_stVertex->x = (float) _lLeft;
p_stVertex->y = (float) _lTop;
p_stVertex->oow = .8f;
p_stVertex++;
p_stVertex->x = (float) _lRight;
p_stVertex->y = (float) _lTop;
p_stVertex->oow = .8f;
p_stVertex++;
p_stVertex->x = (float) _lRight;
p_stVertex->y = (float) _lBottom;
p_stVertex->oow = .8f;
}
void GLI_vSendBlackPolygon()
{
GLI_tdScreenVertx *p_stVertex, *p_stLastVertex;
if (g_lNumberOfBlackTriangles == 0)
return;
p_stVertex = g_stBlackTriangle;
p_stLastVertex = p_stVertex + g_lNumberOfBlackTriangles;
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);//*/
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grColorCombine(GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_ZERO,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_CONSTANT,FALSE);
for ( ; p_stVertex < p_stLastVertex; p_stVertex += 4)
{
grDrawTriangle( p_stVertex, p_stVertex + 1, p_stVertex + 2 );
grDrawTriangle( p_stVertex + 2, p_stVertex + 3, p_stVertex );
}
}
//********************************************************************************************
// Name: GLI_vDoTextureSelection
// Goal:
// Code: Philippe Vimont
// OPTIMMIZED : No
//********************************************************************************************
static long bIsWriteEnable = 1;
void GLI_ZBufferClearNearestAndCompareInverted()
{
grColorMask(FXFALSE, FXFALSE);
grBufferClear( 0, 0, GLI_g_lWDepthMinMaxValue[0]);
grDepthBufferFunction(GR_CMP_GREATER);
grColorMask(FXTRUE, FXTRUE);
}
void GLI_ZBufferCompareRestored()
{
grDepthBufferFunction(GR_CMP_LESS);
}
void GLI_DFX_ClearZBufferRegion(long lXStart,long lXEnd,long lYStart,long lYEnd)
{
grColorMask(FXFALSE, FXFALSE);
grBufferClear( 0, 0, GLI_g_lWDepthMinMaxValue[1]);
grDepthBufferFunction(GR_CMP_LESS);
grColorMask(FXTRUE, FXTRUE);
}
void GLI_DFX_EnableWriteToZBuffer()
{
if (bIsWriteEnable) return;
grDepthMask(FXTRUE);
bIsWriteEnable = 1;
}
void GLI_DFX_DisableWriteToZBuffer()
{
if (!bIsWriteEnable) return;
grDepthMask(FXFALSE);
bIsWriteEnable = 0;
}
/*
----------------------------------------------------------------------------------------
Description : To manage use of ZBuffer
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vEnableDepthTest()
{
if( gs_ulDepthBufferTestEnabled )
return;
grDepthBufferFunction( GR_CMP_LESS );
gs_ulDepthBufferTestEnabled = 1;
}
void GLI_DRV_vDisableDepthTest()
{
if( ! gs_ulDepthBufferTestEnabled )
return;
grDepthBufferFunction( GR_CMP_ALWAYS );
gs_ulDepthBufferTestEnabled = 0;
}
static ACP_tdxIndex xSaveFogIsOn = 0;
static GrChipID_t xSaveTmuNumber = -1;
static unsigned char ucSaveCyclingMode[2] = {-1, -1};
static unsigned char ucSaveFunction = -1;
/*
----------------------------------------------------------------------------------------
Description : called before the rendering of any triangle
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bBeginScene()
{
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : called after the rendering of all triangles
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bEndScene()
{
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : Set init parameter as none set
----------------------------------------------------------------------------------------
*/
void GLI_fn_vInitRenderParameters( void )
{
bIsWriteEnable = 1;
xSaveFogIsOn = 0;
xSaveTmuNumber = -1;
ucSaveCyclingMode[0] = ucSaveCyclingMode[1] = -1;
ucSaveFunction = -1;
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters that will work for all faces which are not
transparent
----------------------------------------------------------------------------------------
*/
void GLI_fn_vSetRenderParametersBeforeOpaqueFace( void )
{
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
grColorCombine(GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_ZERO,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_CONSTANT,FALSE);
grAlphaTestFunction( GR_CMP_ALWAYS );
grAlphaTestReferenceValue( 0xC0 );
ucSaveFunction = 4;
GLI_DFX_EnableWriteToZBuffer();
}
void GLI_DRV_vDoOpaqueTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_tdstTextureDFX *p_stSpecParam;
BOOL bTexture;
if (*GLD_p_lRenderingCounter != p_stGlobaleMT->GLD_RenderingCounter)
{
p_stGlobaleMT->GLD_RenderingCounter = *GLD_p_lRenderingCounter;
GLI_vSendBlackPolygon();
GLI_DFX_EnableWriteToZBuffer();
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FALSE);
ucSaveFunction = 4;
}
bTexture = (p_stGlobaleMT->p_stCurrentTexture != NULL) && (p_stGlobaleMT->p_stCurrentTexture->bIsAvailable);
if (bTexture)
{
p_stSpecParam = p_stGlobaleMT -> p_stCurrentTexture -> p_stSpecParam;
GLI_GLIDE1_xTmuNumber = p_stSpecParam->xTmuNumber;
/*
* UV multiplier
*/
p_stGlobaleMT -> fMulU = p_stSpecParam -> lMultiplyHeight;
p_stGlobaleMT -> fMulV = p_stSpecParam -> lMultiplyWidth;
}
if (
(bTexture && (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTexture | GLI_C_lNZFilteredTexture | GLI_C_lAddTransparencyTexture) ) )
|| (!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))
)
{
p_stGlobaleMT -> lClippingModeMask |= GLI_C_TrianglesMustBeSorted;
return;
}
p_stGlobaleMT -> lClippingModeMask &= 0xffffffff - GLI_C_TrianglesMustBeSorted;
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
GLI_DRV_vEnableDepthTest();
else
GLI_DRV_vDisableDepthTest();
/*
* fog
*/
if (GLI_BIG_GLOBALS->xFogIsOn)
{
if ( GLI_BIG_GLOBALS->p_stLastComputedFog != GLI_BIG_GLOBALS->p_stActiveFog )
{
GLI_vSetFogParams( GLI_BIG_GLOBALS->p_stActiveFog );
GLI_BIG_GLOBALS->p_stLastComputedFog = GLI_BIG_GLOBALS->p_stActiveFog;
}
if (!xSaveFogIsOn)
{
grFogMode( GR_FOG_WITH_TABLE_ON_Q );
xSaveFogIsOn = 1;
}
}
else if (xSaveFogIsOn)
{
// FOG OFF
grFogMode( GR_FOG_DISABLE);
xSaveFogIsOn = 0;
}
/*
* mirror
*/
if (GLI_BIG_GLOBALS->lAMirrorIsDetected & 2)
{
}
/*
* not a mirror
*/
else
{
if ( bTexture )
{
/*
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAlphaTest)
{
if (ucSaveFunction != 5)
{
static unsigned char ucalpha = 0xD0;
grAlphaTestFunction( GR_CMP_GEQUAL );
grAlphaTestReferenceValue( ucalpha );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
ucSaveFunction = 5;
}
}
else
*/
{
if (ucSaveFunction != 4)
{
//grAlphaTestFunction( GR_CMP_ALWAYS );
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FALSE);
ucSaveFunction = 4;
}
}
/*
* Chromakey
*/
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lNZTexture)
{
unsigned long ulChromakey;
grChromakeyMode( GR_CHROMAKEY_ENABLE );
/*
* CB : La valeur de chromakey doit etre <20>gale <20> : 5 bits de poids fort, plus les 3 bits de poids fort copi<70>s dans les bits de poids faible.... !!!
* VL : sauf pour la composante G : 6 bit de poids fort + 2 bit de poids fort copi<70>s dans les bits de poids faible !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
ulChromakey = (p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x00F800F8) | ((p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x00E000E0) >> 5);
ulChromakey|= (p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x0000FC00) | ((p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x0000C000) >> 6);
grChromakeyValue( ulChromakey );
}
else
{
grChromakeyMode( GR_CHROMAKEY_DISABLE );
}
/*
* uv cycling mode
*/
if ( p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode != ucSaveCyclingMode[ GLI_GLIDE1_xTmuNumber ] )
{
switch ( ucSaveCyclingMode[ GLI_GLIDE1_xTmuNumber ] = p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode )
{
case 0:
//NO CYCLING
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_CLAMP,GR_TEXTURECLAMP_CLAMP);
break;
case GLI_C_lCylingUV:
//CYCLING
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_WRAP,GR_TEXTURECLAMP_WRAP);
break;
case GLI_C_lCylingU:
//CYCLING V
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_CLAMP,GR_TEXTURECLAMP_WRAP);
break;
case GLI_C_lCylingV:
//CYCLING U
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_WRAP , GR_TEXTURECLAMP_CLAMP);
break;
}
}
/*
* texture Tmu
*/
if (GLI_GLIDE1_xTmuNumber != xSaveTmuNumber)
{
grTexCombine((GLI_GLIDE1_xTmuNumber+1) & 0x1,GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,FALSE,FALSE);
grTexCombine(GLI_GLIDE1_xTmuNumber,GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,FXFALSE, FXFALSE );
xSaveTmuNumber = GLI_GLIDE1_xTmuNumber;
}
grTexSource( GLI_GLIDE1_xTmuNumber, p_stSpecParam -> xStartAddress, p_stSpecParam -> xEvenOdd, &p_stSpecParam -> stInfoBitmapGlide);
if (p_stGlobaleMT->p_stCurrentTexture->lTextureCaps & GLI_C_lPaletteTexture)
{
grTexDownloadTable( GR_TEXTABLE_PALETTE, p_stGlobaleMT->p_stCurrentTexture->p_vColorTable );
}
}
else /* gouraud */
{
if (ucSaveFunction != 0)
{
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grAlphaTestFunction( GR_CMP_ALWAYS );
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);
grColorCombine(GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_NONE, FXFALSE);
ucSaveFunction = 0;
}
}
}
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters that will work for all transparency faces
----------------------------------------------------------------------------------------
*/
void GLI_fn_vSetRenderParametersBeforeTransparencyFace( void )
{
grAlphaTestFunction( GR_CMP_ALWAYS );
GLI_DFX_DisableWriteToZBuffer();
}
void GLI_vDoTransparentTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_tdstTextureDFX *p_stSpecParam;
/*
* write to Z buffer ?
*/
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsWriteZBuffer)
GLI_DFX_EnableWriteToZBuffer();
else
GLI_DFX_DisableWriteToZBuffer();
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
GLI_DRV_vEnableDepthTest();
else
GLI_DRV_vDisableDepthTest();
/*
* fog
*/
if (GLI_BIG_GLOBALS->xFogIsOn)
{
if ( GLI_BIG_GLOBALS->p_stLastComputedFog != GLI_BIG_GLOBALS->p_stActiveFog )
{
GLI_vSetFogParams( GLI_BIG_GLOBALS->p_stActiveFog );
GLI_BIG_GLOBALS->p_stLastComputedFog = GLI_BIG_GLOBALS->p_stActiveFog;
}
if (!xSaveFogIsOn)
{
grFogMode( GLI_g_lNumberOfFogTableEntries );
xSaveFogIsOn = 1;
}
}
else if (xSaveFogIsOn)
{
// FOG OFF
grFogMode( GR_FOG_DISABLE);
xSaveFogIsOn = 0;
}
/*
* mirror
*/
if (p_stGlobaleMT->lAMirrorIsDetected & 2)
{
if ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))
{
}
else
{
}
}
/*
* not a mirror
*/
else
{
if ((p_stGlobaleMT -> p_stCurrentTexture != NULL) && (p_stGlobaleMT -> p_stCurrentTexture -> bIsAvailable))
{
p_stSpecParam = p_stGlobaleMT -> p_stCurrentTexture -> p_stSpecParam;
GLI_GLIDE1_xTmuNumber = p_stSpecParam->xTmuNumber;
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTexture | GLI_C_lNZFilteredTexture | GLI_C_lAddTransparencyTexture) )
{
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAddTransparencyTexture)
{
// Trans ADD
if (ucSaveFunction != 1)
{
grAlphaBlendFunction( GR_BLEND_ONE,GR_BLEND_ONE,GR_BLEND_ZERO ,GR_BLEND_ZERO );
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL_ALPHA,GR_COMBINE_LOCAL_CONSTANT,GR_COMBINE_OTHER_TEXTURE,FALSE);
ucSaveFunction = 1;
}
// No fog With This;
if (xSaveFogIsOn)
{
grFogMode( GR_FOG_DISABLE);
xSaveFogIsOn = 0;
}
}
else if (ucSaveFunction != 2)
{
// Trans ALPHA
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE ,GR_BLEND_ZERO );
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE );
ucSaveFunction = 2;
}
}
else //if ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (xGlobaLAlpha < 0.98f))
{
// Trans ALPHA ITERATED
if (ucSaveFunction != 3)
{
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE,GR_BLEND_ZERO );
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);//*/
grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE );
ucSaveFunction = 3;
}
}
/*
* Chromakey
*/
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lNZTexture)
{
unsigned long ulChromakey;
grChromakeyMode( GR_CHROMAKEY_ENABLE );
/*
* CB : La valeur de chromakey doit etre <20>gale <20> : 5 bits de poids fort, plus les 3 bits de poids fort copi<70>s dans les bits de poids faible.... !!!
* VL : sauf pour la composante G : 6 bit de poids fort + 2 bit de poids fort copi<70>s dans les bits de poids faible !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
ulChromakey = (p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x00F800F8) | ((p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x00E000E0) >> 5);
ulChromakey|= (p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x0000FC00) | ((p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x0000C000) >> 6);
grChromakeyValue( ulChromakey );
}
else
{
grChromakeyMode( GR_CHROMAKEY_DISABLE );
}
/*
* uv cycling mode
*/
if ( p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode != ucSaveCyclingMode[ GLI_GLIDE1_xTmuNumber ] )
{
switch ( ucSaveCyclingMode[ GLI_GLIDE1_xTmuNumber ] = p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode )
{
case 0:
//NO CYCLING
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_CLAMP,GR_TEXTURECLAMP_CLAMP);
break;
case GLI_C_lCylingUV:
//CYCLING
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_WRAP,GR_TEXTURECLAMP_WRAP);
break;
case GLI_C_lCylingU:
//CYCLING V
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_CLAMP,GR_TEXTURECLAMP_WRAP);
break;
case GLI_C_lCylingV:
//CYCLING U
grTexClampMode(GLI_GLIDE1_xTmuNumber, GR_TEXTURECLAMP_WRAP , GR_TEXTURECLAMP_CLAMP);
break;
}
}
/*
* texture Tmu
*/
if (GLI_GLIDE1_xTmuNumber != xSaveTmuNumber)
{
grTexCombine((GLI_GLIDE1_xTmuNumber+1) & 0x1,GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,FALSE,FALSE);
grTexCombine(GLI_GLIDE1_xTmuNumber,GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,FXFALSE, FXFALSE );
xSaveTmuNumber = GLI_GLIDE1_xTmuNumber;
}
grTexSource( GLI_GLIDE1_xTmuNumber, p_stSpecParam -> xStartAddress, p_stSpecParam -> xEvenOdd, &p_stSpecParam -> stInfoBitmapGlide);
}
else
{
// GOURAUD
if (((p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided) == 0) && (p_stGlobaleMT->xGlobalAlpha < 0.98f) )
{
// alpha iterated transparency
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE,GR_BLEND_ZERO );
grAlphaCombine(GR_COMBINE_FUNCTION_BLEND, GR_COMBINE_FACTOR_LOCAL_ALPHA,GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_NONE,FXFALSE);
p_stGlobaleMT -> lClippingModeMask |= GLI_C_TrianglesMustBeSorted;
}
else
{
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
}
grColorCombine(GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_NONE, FXFALSE);
ucSaveFunction = 0;
}
}
}
void GLI_WriteRegion3DFX(long X, long Y, long l, long h, unsigned char *p_ucSrc, long SrcPitch , GrLfbInfo_t *p_info)
{
long *p_sourceptr , *p_sourceptrLast , *p_destptr ,lYCounterLocal;
short *p_Src;
long lPitch = p_info->strideInBytes / 4;
p_Src = (unsigned short *)p_ucSrc;
for (lYCounterLocal = 0; lYCounterLocal < h ; lYCounterLocal++)
{
p_destptr = ((unsigned long *)p_info->lfbPtr) + (X>>1) + lPitch * (Y + lYCounterLocal);
p_sourceptr = ((unsigned long *)p_Src + lYCounterLocal * (SrcPitch >>2)) ;
p_sourceptrLast = p_sourceptr + (l>>1);
for (;p_sourceptr < p_sourceptrLast ;p_sourceptr ++,p_destptr ++)
*p_destptr = *p_sourceptr ;
}
}
void GLI_DRV_vWrite16bBitmapToBackBuffer( void *_p_vSourceBuffer, long _lWidth, long _lHeight, long _lDestLeft, long _lDestTop, long _lDestRight, long _lDestBottom )
{
GrLfbInfo_t info;
unsigned short *puw_Tgt, *puw_Src;
info.size = sizeof( GrLfbInfo_t );
if ( !grLfbLock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER, GR_LFBWRITEMODE_565 , GR_ORIGIN_UPPER_LEFT, FXFALSE , &info) )
return;
puw_Tgt = (unsigned short *) info.lfbPtr;
puw_Tgt += (info.strideInBytes>> 1) * _lDestTop + _lDestLeft;
puw_Src = (unsigned short *) _p_vSourceBuffer;
GLD_MDRV_vBlitStretched16b( _lDestRight - _lDestLeft + 1, _lDestBottom - _lDestTop + 1, puw_Tgt, info.strideInBytes >> 1, _lWidth, _lHeight, puw_Src );
grLfbUnlock( GR_LFB_WRITE_ONLY , GR_BUFFER_BACKBUFFER);
}
void GLI_vSetFogParams( tdstFogParams *_p_stFogParams )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
float *p_fFogDist, *p_fLast;
long GlideColor;
float xCoefOfCalculation;
GrFog_t *p_xFog;
unsigned char ucFogDensityStart, ucFogDensityEnd;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
xCoefOfCalculation = _p_stFogParams->xDepthEnd - _p_stFogParams->xDepthStart;
if ( xCoefOfCalculation )
xCoefOfCalculation = ( _p_stFogParams->xBlendEnd - _p_stFogParams->xBlendStart) / xCoefOfCalculation;
p_fFogDist = GLI_ga_fFogDist;
p_fLast = p_fFogDist + GLI_g_lNumberOfFogTableEntries;
p_xFog = Gli_C_xFogTable;
ucFogDensityStart = (unsigned char) MTH_M_xRealToLong(_p_stFogParams->xBlendStart);
ucFogDensityEnd = (unsigned char) MTH_M_xRealToLong(_p_stFogParams->xBlendEnd);
while ( (p_fFogDist < p_fLast) && (*p_fFogDist < _p_stFogParams->xDepthStart) )
{
*p_xFog++ = ucFogDensityStart;
p_fFogDist++;
}
while ( (p_fFogDist < p_fLast) && (*p_fFogDist < _p_stFogParams->xDepthEnd) )
{
*p_xFog++ = (unsigned char)MTH_M_xRealToLong((xCoefOfCalculation * (*p_fFogDist++ - _p_stFogParams->xDepthStart)) + _p_stFogParams->xBlendStart);
}
while ( (p_fFogDist < p_fLast) && (*p_fFogDist < _p_stFogParams->xInfinite) )
{
*p_xFog++ = ucFogDensityEnd;
p_fFogDist++;
}
while ( p_fFogDist < p_fLast )
{
*p_xFog++ = 255;
p_fFogDist++;
}
grFogTable( Gli_C_xFogTable );
GlideColor = (long)(_p_stFogParams->stColor.xR * 255.f) +((long)(_p_stFogParams->stColor.xG * 255.f)<<8) +((long)(_p_stFogParams->stColor.xB * 255.f)<<16) ;
grFogColorValue(GlideColor);
}
void GLI_DRV_vComputeFogEffect(GLI_tdstInternalGlobalValuesFor3dEngine *p_stBG )
{
}
#ifdef __cplusplus
} //extern "C"
#endif

View File

@@ -0,0 +1,460 @@
#include "GLD.h"
#include "GEO.h"
#include "TEX.h"
#include "gli_st.h"
#include "textu_st.h"
#include "texture.h"
#define __MSC__
#include <glide.h>
#include "TextuDFX.h"
#include "DLLCom.h"
extern long GLI_gl_MaxTmuAvailable;
short TEXTURETWIDDLED[1024L*1024L];
/*
----------------------------------------------------------------------------------------
Structure for texture memory block (use to load texture into VRam)
----------------------------------------------------------------------------------------
*/
typedef struct tdstTextureMemoryBlock_
{
long lTmu;
long lStart;
long lCurrent;
long lEnd;
} tdstTextureMemoryBlock;
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
long GLI_fn_lGetTotalTextureMemorySize( void )
{
long i,lSize;
lSize = 0;
for (i = 0 ; i < GLI_gl_MaxTmuAvailable; i++)
lSize += grTexMaxAddress( i ) - grTexMinAddress( i );
return (lSize);
}
/*
----------------------------------------------------------------------------------------
Description : get video memory size taken by a given texture
----------------------------------------------------------------------------------------
*/
long GLI_DRV_lGetSizeOfTexture( GLI_tdstTexture *p_stTexture )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lTextureSize;
long lRef, lSize;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
lTextureSize = p_stTexture->lHeight * p_stTexture->lWidth;
/*
* 8 bits
*/
if (!(p_stTexture->lTextureCaps & GLI_C_lPaletteTexture))
lTextureSize <<= 1;
/*
* mipmap
*/
if (p_stTexture ->lNumberOfLod)
{
lRef = (p_stTexture->lWidth > p_stTexture->lHeight) ? p_stTexture->lHeight : p_stTexture->lWidth;
lSize = lTextureSize;
while ( lRef )
{
lSize >>= 2;
lRef >>= 1;
lTextureSize += lSize;
}
}
/*
* alignment
*/
if ( lTextureSize & 0x7 )
{
lTextureSize += 8 - (lTextureSize & 0x7);
}
GLI_MDRV_TEXBENCH_vSetTextureSize( p_stTexture, TEXBENCH_C_cComputedSize, lTextureSize );
return lTextureSize;
}
/*
----------------------------------------------------------------------------------------
Description : get correspondante GRLOd constant
----------------------------------------------------------------------------------------
*/
static long GLI_lFindGrLOD(long lvalue)
{
if (lvalue == 256) return GR_LOD_LOG2_256;
if (lvalue == 128) return GR_LOD_LOG2_128;
if (lvalue == 64) return GR_LOD_LOG2_64;
if (lvalue == 32) return GR_LOD_LOG2_32;
if (lvalue == 16) return GR_LOD_LOG2_16;
if (lvalue == 8) return GR_LOD_LOG2_8;
if (lvalue == 4) return GR_LOD_LOG2_4;
if (lvalue == 2) return GR_LOD_LOG2_2;
if (lvalue == 1) return GR_LOD_LOG2_1;
return 0;// GROSBUG
}
/*
----------------------------------------------------------------------------------------
Description : compute texture aspect ration
----------------------------------------------------------------------------------------
*/
long GLI_lFindAspectRatioAndMultiplySize(GLI_tdstTexture *p_stTexture)
{
long lValue1,lValue2;
GLI_tdstTextureDFX *p_stSpecParam;
p_stSpecParam=p_stTexture->p_stSpecParam;
lValue1 = p_stTexture -> lWidth;
lValue2 = p_stTexture -> lHeight;
if ((lValue1>>3) == lValue2)
{
p_stSpecParam -> lMultiplyWidth = 255.0f;
p_stSpecParam -> lMultiplyHeight = 31.0f;
return GR_ASPECT_LOG2_8x1;
}
if ((lValue1>>2) == lValue2)
{
p_stSpecParam -> lMultiplyWidth = 255.0f;
p_stSpecParam -> lMultiplyHeight = 63.0f;
return GR_ASPECT_LOG2_4x1;
}
if ((lValue1>>1) == lValue2)
{
p_stSpecParam -> lMultiplyWidth = 255.0f;
p_stSpecParam -> lMultiplyHeight =127.0f;
return GR_ASPECT_LOG2_2x1;
}
if ((lValue1) == (lValue2))
{
p_stSpecParam -> lMultiplyWidth = 255.0f;
p_stSpecParam -> lMultiplyHeight =255.0f;
return GR_ASPECT_LOG2_1x1;
}
if ((lValue1) == (lValue2>>1))
{
p_stSpecParam -> lMultiplyWidth = 127.0f;
p_stSpecParam -> lMultiplyHeight =255.0f;
return GR_ASPECT_LOG2_1x2;
}
if ((lValue1) == (lValue2>>2))
{
p_stSpecParam -> lMultiplyWidth = 63.0f;
p_stSpecParam -> lMultiplyHeight =255.0f;
return GR_ASPECT_LOG2_1x4;
}
if ((lValue1) == (lValue2>>3))
{
p_stSpecParam -> lMultiplyWidth = 31.0f;
p_stSpecParam -> lMultiplyHeight =255.0f;
return GR_ASPECT_LOG2_1x8;
}
return 0; /* GROS BUG */
}
/*
----------------------------------------------------------------------------------------
Description : Compress texture and compute mip map levels
----------------------------------------------------------------------------------------
*/
static void GLI_vCompressTex ( GLI_tdstTexture *p_stTexture , GrTexInfo *p_stTexInfo )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lCurrentDecalTextureForMipMapping,Verify;
unsigned short *p_Destination;
unsigned char *p_ucDest;
unsigned long *p_ulPalette;
long lNbLod;
unsigned short lWidth, lHeight;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (p_stTexture == NULL )
return;
lCurrentDecalTextureForMipMapping = 0;
p_Destination = TEXTURETWIDDLED;
p_stTexture->p_vBitMap = GLI_gs_p_ConvertBufferMipMapping;
/*
* load texture
*/
GLI_MDRV_xLoadTextureInTexelField(p_stTexture, GLI_gs_p_ConvertBufferMipMapping, TRUE);
/*
* check for alpha texture
*/
if ((p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture) || (p_stTexture -> lTextureCaps & GLI_C_lNZFilteredTexture))
{
Verify = GLI_MDRV_vVerifyTextureIsRealyAlpha(p_stTexture);
if ((Verify & 0xE0000000) == 0xE0000000)
p_stTexture -> lTextureCaps &= 0xffffffff - GLI_C_lAlphaTexture;
if ((Verify & 0x80000000) == 0x80000000)
p_stTexture -> lTextureCaps &= 0xffffffff - GLI_C_lNZFilteredTexture;
}
p_stTexture->p_vBitMap = GLI_gs_p_ConvertBufferMipMapping;
lNbLod = p_stTexture->lNumberOfLod;
lWidth = p_stTexture->lWidth;
lHeight = p_stTexture->lHeight;
if ( p_stTexture->lTextureCaps & GLI_C_lPaletteTexture )
{
p_ucDest = (char *) p_Destination;
p_ulPalette = (unsigned long *) p_stTexture->p_vColorTable;
((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_P_8;
memcpy( p_ucDest, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth );
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
GLI_MDRV_vDivideBitmapSurfaceBy2Palette( (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_ulPalette, p_stTexture->lHeight, p_stTexture->lWidth );
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
memcpy( p_ucDest + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth );
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else if ( p_stTexture->lTextureCaps & GLI_C_lAlphaTest )
{
((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_1555;
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination)) ;
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture->lHeight, p_stTexture->lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else if ((!(p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)) && (p_stTexture -> lTextureCaps & GLI_C_lNZFilteredTexture))
{
((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_1555;
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination)) ;
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth);
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else if (p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)
{
((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_4444;
GLI_MDRV_vCompressTex4444( p_stTexture , (void *)(p_Destination)) ;
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight , p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight , p_stTexture -> lWidth );
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
GLI_MDRV_vCompressTex4444( p_stTexture , (void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else
{
((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_RGB_565;
GLI_MDRV_vCompressTex565( p_stTexture , (void *)(p_Destination)) ;
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth);
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
GLI_MDRV_vCompressTex565 ( p_stTexture , (void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
p_stTexture->lWidth = lWidth;
p_stTexture->lHeight = lHeight;
}
/*
----------------------------------------------------------------------------------------
Description : adjust Tex info parameters
----------------------------------------------------------------------------------------
*/
static void GLI_vComputeGrTexInfo ( GLI_tdstTexture *p_stTexture , GrTexInfo *p_stTexInfo )
{
if (p_stTexture -> lHeight >= p_stTexture -> lWidth)
{
p_stTexInfo -> smallLodLog2 = GLI_lFindGrLOD(p_stTexture -> lHeight >> p_stTexture -> lNumberOfLod);
p_stTexInfo -> largeLodLog2 = GLI_lFindGrLOD(p_stTexture -> lHeight );
} else
{
p_stTexInfo -> smallLodLog2 = GLI_lFindGrLOD(p_stTexture -> lWidth >> p_stTexture -> lNumberOfLod);
p_stTexInfo -> largeLodLog2 = GLI_lFindGrLOD(p_stTexture -> lWidth );
}
p_stTexInfo -> aspectRatioLog2 = GLI_lFindAspectRatioAndMultiplySize(p_stTexture);
p_stTexInfo -> data = TEXTURETWIDDLED;
}
/*
----------------------------------------------------------------------------------------
Description : download textures
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vDownLoadTextures(long bRestore, long _lTextureMode, BOOL bReloading )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tdstTextureMemoryBlock st_TexMemBlock[6];
tdstTextureMemoryBlock *pst_TexMemBlock;
long lNbTexMemBlocks;
long i;
long lMemoryNeeded;
long lTextureCounter;
GLI_tdstTexture *p_stTexture;
GLI_tdstTextureDFX *p_stSpecParam;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* init texture block;
*/
lNbTexMemBlocks = 0;
for ( i = 0; i < GLI_gl_MaxTmuAvailable; i++)
{
st_TexMemBlock[ lNbTexMemBlocks ].lTmu = i;
st_TexMemBlock[ lNbTexMemBlocks ].lStart = grTexMinAddress( i );
st_TexMemBlock[ lNbTexMemBlocks ].lCurrent = st_TexMemBlock[ lNbTexMemBlocks ].lStart;
lMemoryNeeded = grTexMaxAddress( i );
if (lMemoryNeeded > 2097152 )
{
st_TexMemBlock[ lNbTexMemBlocks++ ].lEnd = 2097152;
st_TexMemBlock[ lNbTexMemBlocks ].lTmu = i;
st_TexMemBlock[ lNbTexMemBlocks ].lStart = 2097152;
st_TexMemBlock[ lNbTexMemBlocks ].lCurrent = st_TexMemBlock[ lNbTexMemBlocks ].lStart;
}
st_TexMemBlock[ lNbTexMemBlocks++ ].lEnd = lMemoryNeeded;
}
grTexMipMapMode( GR_TMU0, GR_MIPMAP_NEAREST_DITHER, FXFALSE);
grTexMipMapMode( GR_TMU1, GR_MIPMAP_NEAREST_DITHER, FXFALSE);
/*
* load all textures
*/
for (lTextureCounter = 0; lTextureCounter < GLI_C_lNBMaxOfTextures ; lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] == GLI_TEXIsUnallocated )
continue;
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
if (p_stTexture == NULL)
continue;
p_stTexture->p_stSpecParam = (GLI_tdstTextureDFX *) GLI_MDRV_p_vTmpMalloc( sizeof(GLI_tdstTextureDFX) );
p_stSpecParam = p_stTexture->p_stSpecParam;
p_stTexture -> bIsAvailable = 0;
p_stSpecParam -> lMultiplyWidth = 0.0f;
p_stSpecParam -> lMultiplyHeight = 0.0f;
p_stSpecParam -> xEvenOdd = GR_MIPMAPLEVELMASK_BOTH ;
GLI_vComputeGrTexInfo( p_stTexture , &p_stSpecParam->stInfoBitmapGlide ) ;
GLI_vCompressTex( p_stTexture , &p_stSpecParam->stInfoBitmapGlide ) ;
lMemoryNeeded = grTexTextureMemRequired( p_stSpecParam -> xEvenOdd , &p_stSpecParam -> stInfoBitmapGlide );
/*
* search a block that accept current texture
*/
pst_TexMemBlock = st_TexMemBlock;
for ( i = 0; i < lNbTexMemBlocks; i++, pst_TexMemBlock++ )
{
if (lMemoryNeeded < pst_TexMemBlock->lEnd - pst_TexMemBlock->lCurrent )
break;
}
if ( i == lNbTexMemBlocks)
continue;
/* bench texture size */
GLI_MDRV_TEXBENCH_vSetTextureSize( p_stTexture, 1, lMemoryNeeded );
p_stTexture -> bIsAvailable = 1;
p_stSpecParam->xTmuNumber = pst_TexMemBlock->lTmu;
p_stSpecParam->xStartAddress = pst_TexMemBlock->lCurrent;
pst_TexMemBlock->lCurrent += lMemoryNeeded;
grTexDownloadMipMap (p_stSpecParam -> xTmuNumber,p_stSpecParam -> xStartAddress ,p_stSpecParam -> xEvenOdd ,&p_stSpecParam -> stInfoBitmapGlide );
}
}
/*
----------------------------------------------------------------------------------------
Description : unload texture
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vUnLoadTextures()
{
long lTextureCounter;
GLI_tdstTexture *p_stTexture;
for ( lTextureCounter = 0 ; lTextureCounter < C_lMaxNumberOfTexture ;lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated )
{
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
if (p_stTexture != NULL)
{
if (p_stTexture->bIsAvailable)
{
if (p_stTexture-> p_stSpecParam)
GLI_MDRV_vTmpFree( (void *) p_stTexture-> p_stSpecParam );
p_stTexture->bIsAvailable = 0;
}
}
}
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@@ -0,0 +1,774 @@
/*
=======================================================================================
Name : Init_Glide2.c
Author : GliGlou
Description :
=======================================================================================
*/
/*
=======================================================================================
Include
=======================================================================================
*/
#define INITGUID
#include <ddraw.h>
#define __MSC__
#include <glide.h>
#include "init_gli.h"
#include "gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "DLLCom.h"
#include "tmr.h"
#include "prf.h"
#include "Glide2To3.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Protos
=======================================================================================
*/
void GLI_DRV_xClearViewingList ( void );
long GLI_fn_lGetTotalTextureMemorySize();
void GLI_fn_vInitRenderParameters( void );
/*
=======================================================================================
Structure
=======================================================================================
*/
typedef struct tdstGlideResolution_
{
long lCode;
unsigned long ulWidth;
unsigned long ulHeight;
long lAlreadyAdded;
} tdstGlideResolution;
/*
=======================================================================================
Globals
=======================================================================================
*/
tdstGlideResolution g_a_stGlideRes[16] =
{
{GR_RESOLUTION_320x200 , 320, 200, 0 },
{GR_RESOLUTION_320x240 , 320, 240, 0 },
{GR_RESOLUTION_400x256 , 400, 256, 0 },
{GR_RESOLUTION_512x384 , 512, 384, 0 },
{GR_RESOLUTION_640x200 , 640, 200, 0 },
{GR_RESOLUTION_640x350 , 640, 350, 0 },
{GR_RESOLUTION_640x400 , 640, 400, 0 },
{GR_RESOLUTION_640x480 , 640, 480, 0 },
{GR_RESOLUTION_800x600 , 800, 600, 0 },
{GR_RESOLUTION_960x720 , 960, 720, 0 },
{GR_RESOLUTION_856x480 , 856, 480, 0 },
{GR_RESOLUTION_512x256 , 512, 256, 0 },
{GR_RESOLUTION_1024x768 ,1024, 768, 0 },
{GR_RESOLUTION_1280x1024,1280,1024, 0 },
{GR_RESOLUTION_1600x1200,1600,1200, 0 },
{GR_RESOLUTION_400x300 , 400, 300, 0 }
};
/*
=======================================================================================
Constants
=======================================================================================
*/
long GLI_gl_MaxTmuAvailable;
long GLI_g_lNumberOfFogTableEntries;
GrContext_t GLI_g_xGlideContext;
long GLI_g_lWDepthMinMaxValue[2];
/*
* for windowed mode
*/
#ifndef RETAIL
static BOOL gs_bIsWindowed = FALSE;
static HWND gs_hWnd = NULL;
static LPDIRECTDRAW gs_lpDD = NULL;
static LPDIRECTDRAW2 gs_lpDD2 = NULL;
static LPDIRECTDRAWSURFACE gs_lpDDSFront = NULL;
static LPDIRECTDRAWSURFACE gs_lpDDSBack = NULL;
static LPDIRECTDRAWCLIPPER gs_lpDDClipper = NULL;
#endif
/*
=======================================================================================
function use for windowed mode
=======================================================================================
*/
BOOL __declspec(dllexport) GLI_DRV_bWindowedModeIsOptimized(void)
{
return FALSE;
}
void __declspec(dllexport) GLI_DRV_vOptimizedWindowedMode(void)
{
return;
}
void __declspec(dllexport) GLI_DRV_vNonOptimizedWindowedMode(void)
{
return;
}
/*
----------------------------------------------------------------------------------------
Description : release directX object created for windowed mode
----------------------------------------------------------------------------------------
*/
void GLI_fn_vReleaseDDObject( void )
{
if (gs_lpDDClipper)
{
gs_lpDDClipper->lpVtbl->Release( gs_lpDDClipper );
gs_lpDDClipper = NULL;
}
if (gs_lpDDSFront)
{
gs_lpDDSBack->lpVtbl->Release( gs_lpDDSBack );
gs_lpDDSBack = NULL;
}
if (gs_lpDDSFront)
{
gs_lpDDSFront->lpVtbl->Release( gs_lpDDSFront );
gs_lpDDSFront = NULL;
}
if (gs_lpDD2)
{
gs_lpDD2->lpVtbl->Release(gs_lpDD2);
gs_lpDD2 = NULL;
}
if (gs_lpDD)
{
gs_lpDD->lpVtbl->Release(gs_lpDD);
gs_lpDD = NULL;
}
}
/*
----------------------------------------------------------------------------------------
Description : prepare display for windowed mode
----------------------------------------------------------------------------------------
*/
BOOL __declspec(dllexport) GLI_DRV_bPrepareForGliWindowed( HWND _hWnd )
{
HRESULT hr;
DDSURFACEDESC ddsd;
RECT rcWindow;
gs_bIsWindowed = TRUE;
gs_hWnd = _hWnd;
// Create Direct draw object
hr = DirectDrawCreate( NULL, &gs_lpDD, NULL );
if( hr != DD_OK )
{
gs_lpDD = NULL;
return FALSE;
}
// Get the DirectDraw2 object
hr = gs_lpDD->lpVtbl->QueryInterface(gs_lpDD, &IID_IDirectDraw2, (LPVOID *)&gs_lpDD2 );
if( hr != DD_OK )
{
GLI_fn_vReleaseDDObject();
return FALSE;
}
// Set cooperative level to normal
hr = gs_lpDD2->lpVtbl->SetCooperativeLevel( gs_lpDD2, _hWnd, DDSCL_NORMAL );
if ( hr != DD_OK )
{
GLI_fn_vReleaseDDObject();
return FALSE; //Can't get normal mode
}
// Creation of primary surface
memset( &ddsd, 0, sizeof( DDSURFACEDESC ) );
ddsd.dwSize = sizeof( DDSURFACEDESC );
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
hr = gs_lpDD2->lpVtbl->CreateSurface(gs_lpDD2, &ddsd, &gs_lpDDSFront, NULL );
if ( hr != DD_OK )
{
GLI_fn_vReleaseDDObject();
return FALSE; //Can't create primary surface
}
// Creation of DirectDraw Clipper
hr = gs_lpDD2->lpVtbl->CreateClipper(gs_lpDD2, 0, &gs_lpDDClipper, NULL );
if ( hr != DD_OK )
{
GLI_fn_vReleaseDDObject();
return FALSE;
}
// Associate clipper with Window
hr = gs_lpDDClipper->lpVtbl->SetHWnd(gs_lpDDClipper, 0, _hWnd );
if( hr != DD_OK )
{
GLI_fn_vReleaseDDObject();
return FALSE; //Can't create clipper
}
hr = gs_lpDDSFront->lpVtbl->SetClipper(gs_lpDDSFront, gs_lpDDClipper );
if ( hr != DD_OK )
{
GLI_fn_vReleaseDDObject();
return FALSE; //Can't create clipper
}
GetClientRect( _hWnd, &rcWindow );
memset( &ddsd, 0, sizeof( DDSURFACEDESC ) );
ddsd.dwSize = sizeof( DDSURFACEDESC );
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
/*pstDevAttrib->dwHeight = */
ddsd.dwHeight = rcWindow.bottom;
//pstDevAttrib->dwWidth =
ddsd.dwWidth = rcWindow.right;
// Back buffer
hr = gs_lpDD2->lpVtbl->CreateSurface(gs_lpDD2, &ddsd, &gs_lpDDSBack, NULL );
if ( hr != DD_OK )
{
GLI_fn_vReleaseDDObject();
return FALSE; //Can't create clipper
}
grDisable ( GR_PASSTHRU );
//GLI3grSstControl( GR_CONTROL_DEACTIVATE);
return TRUE; // BART
}
/*
----------------------------------------------------------------------------------------
Description : prepare display for full screen mode
----------------------------------------------------------------------------------------
*/
void __declspec(dllexport) GLI_DRV_vPrepareForGliFullScreen( HWND _hWnd )
{
GLI_fn_vReleaseDDObject();
gs_bIsWindowed = FALSE;
//GLI3grSstControl( GR_CONTROL_ACTIVATE);
grEnable( GR_PASSTHRU );
}
/*
----------------------------------------------------------------------------------------
Description : copy 3DFX back buffer into D3D back bufer
----------------------------------------------------------------------------------------
*/
void GLI_fn_vCopyBackBufferToD3DBackBuffer()
{
GrLfbInfo_t info;
DDSURFACEDESC ddsd;
unsigned long *p_sourceptr , *p_sourceptrLast , *p_destptr ,lYCounterLocal, lSizeX,lSizeY,lPitch;
HRESULT ddrval;
POINT pt;
RECT rcDest, rcSrc;
memset( &ddsd, 0, sizeof( DDSURFACEDESC ) );
ddsd.dwSize = sizeof( DDSURFACEDESC );
grLfbLock( GR_LFB_READ_ONLY, GR_BUFFER_BACKBUFFER,GR_LFBWRITEMODE_565, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info);
ddrval = IDirectDrawSurface_Lock(gs_lpDDSBack, NULL, &ddsd, DDLOCK_WAIT, NULL );
if (ddrval == DD_OK)
{
lSizeX = ddsd.dwWidth;
lSizeY =ddsd.dwHeight;
lPitch =ddsd.lPitch;
for (lYCounterLocal = 0; lYCounterLocal < lSizeY ; lYCounterLocal++)
{
p_sourceptr = ((unsigned long *)info.lfbPtr) + 512L /*pitch 3dfx */ * lYCounterLocal ;
p_destptr = ((unsigned long *)ddsd.lpSurface) + (lPitch >>2) * lYCounterLocal ;
p_sourceptrLast = p_sourceptr + (lSizeX >>1);
for (;p_sourceptr < p_sourceptrLast ;p_sourceptr ++,p_destptr ++)
*p_destptr = *p_sourceptr ;
}
IDirectDrawSurface_Unlock(gs_lpDDSBack, ddsd.lpSurface );
}
grLfbUnlock( GR_LFB_READ_ONLY, GR_BUFFER_BACKBUFFER);
GetClientRect( gs_hWnd, &rcDest );
rcSrc.top = 0;
rcSrc.left = 0;
rcSrc.right = 640;
rcSrc.bottom = 480;
pt.x = pt.y = 0;
ClientToScreen( gs_hWnd, &pt );
OffsetRect( &rcDest, pt.x, pt.y );
ddrval = IDirectDrawSurface_Blt(gs_lpDDSFront, &rcDest, gs_lpDDSBack, &rcSrc, 0, NULL );
}
/*
=======================================================================================
Lock / unlock backbuffer
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Lock (return pointer on virtual screen and pitch value)
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bLockDevice( void **_pp_vVirtualScreen, long *_p_lPitch )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GrLfbInfo_t info;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
grLfbLock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER,GR_LFBWRITEMODE_565, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info);
*_pp_vVirtualScreen = info.lfbPtr;
*_p_lPitch = info.strideInBytes;
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : UnLock
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bUnlockDevice( void )
{
grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER);
return TRUE;
}
/*
=======================================================================================
Init / close
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Set capabilities
----------------------------------------------------------------------------------------
*/
void VD2_fnv_SetCaps( tdstGliCaps *_pst_Caps )
{
memset( _pst_Caps, 0, sizeof( tdstGliCaps ) );
_pst_Caps->ulDriverCaps = GLICAPS_DRV_C_ulIsHardware | GLICAPS_DRV_C_ulCanBeWindowed /*| GLICAPS_DRV_C_ulSupportAlphaTest*/;
_pst_Caps->ulTextureCaps = GLICAPS_TEX_C_ulSupport8P | GLICAPS_TEX_C_ulSupportNonSquare | GLICAPS_TEX_C_ulSupportMipmap;
_pst_Caps->ulTextureMaxSize = 256;
_pst_Caps->ulTotalTextureMemory = GLI_fn_lGetTotalTextureMemorySize();
_pst_Caps->ulTotalAGPMemory = 0;
_pst_Caps->ucPrimarySurfacePixelFormat = GLD_C_xR5G6B5PixelFormat;
}
/*
----------------------------------------------------------------------------------------
Description : open Glide with good resolution
----------------------------------------------------------------------------------------
*/
long fn_lChooseResolution( HWND _hWnd, BOOL _bFullScreen, long _lWidth, long _lHeight, long _lBpp )
{
int iResIndex;
long lContext;
GrScreenResolution_t GrResolutionChoosen;
GrResolutionChoosen = GR_RESOLUTION_NONE;
for (iResIndex = 0; iResIndex < 16; iResIndex++)
{
if ( (g_a_stGlideRes[iResIndex].ulWidth == (unsigned long) _lWidth) && (g_a_stGlideRes[iResIndex].ulHeight == (unsigned long) _lHeight) )
{
GrResolutionChoosen = g_a_stGlideRes[iResIndex].lCode;
break;
}
}
if ( GrResolutionChoosen!= GR_RESOLUTION_NONE)
lContext = grSstWinOpen( (FxU32) _hWnd, GrResolutionChoosen, GR_REFRESH_60Hz, GR_COLORFORMAT_ABGR, GR_ORIGIN_UPPER_LEFT, 2, 1 ) ;
/*
if (lContext)
{
gs_bIsWindowed = (_bFullScreen) ? 0 : 1;
g_lDestWidthInit = _lWidth;
g_lDestHeightInit = _lHeight;
GLI_fn_vActualizeModeDevice();
}
*/
return lContext;
}
/*
----------------------------------------------------------------------------------------
Description : open Glide with good resolution
----------------------------------------------------------------------------------------
*/
void GLI_DRV_xInitDriver( HWND _hWnd, BOOL _bFullScreen, long _lWidth, long _lHeight, long _lBpp )
{
grGlideInit();
grGet( GR_NUM_TMU, 4, &GLI_gl_MaxTmuAvailable );
grGet( GR_FOG_TABLE_ENTRIES, 4, &GLI_g_lNumberOfFogTableEntries );
grGet( GR_WDEPTH_MIN_MAX, 8, (long *) &GLI_g_lWDepthMinMaxValue );
grSstSelect( 0 );
grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
//grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);
grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
//grSstWinOpen( 0, GR_RESOLUTION_640x480, GR_REFRESH_60Hz, GR_COLORFORMAT_ABGR, GR_ORIGIN_UPPER_LEFT, 2, 1 ) ;
//GLI_g_xGlideContext = grSstWinOpen( (FxU32) _hWnd, GR_RESOLUTION_640x480, GR_REFRESH_60Hz, GR_COLORFORMAT_ABGR, GR_ORIGIN_UPPER_LEFT, 2, 1 ) ;
GLI_g_xGlideContext = fn_lChooseResolution( _hWnd, _bFullScreen, _lWidth, _lHeight, _lBpp );
grDepthBufferMode( GR_DEPTHBUFFER_WBUFFER );
grDepthBufferFunction( GR_CMP_LESS );
grDepthMask( FXTRUE );
MMG_MDRV_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeZList , NULL);
GLI_BIG_GLOBALS -> p_TheZListe = (GLI_tdstZListe *) GLI_MDRV_p_vTmpMalloc(sizeof(GLI_tdstZListe));
memset (GLI_BIG_GLOBALS -> p_TheZListe , 0 , sizeof(GLI_tdstZListe));
MMG_MDRV_vAddMemoryInfo(MMG_C_lTypeGLI , MMG_C_lSubTypeZList , NULL);
GLI_BIG_GLOBALS -> p_TheZListe -> p_TableOfPoints = GLI_MDRV_p_vTmpMalloc((3L * sizeof (GLI_tdScreenVertx))<<GLI_MaxZListeTrianglesPO2);
GLI_BIG_GLOBALS -> ulCurrentZTable = 0;
GLI_DRV_xClearViewingList();
grTexFilterMode(0,GR_TEXTUREFILTER_BILINEAR,GR_TEXTUREFILTER_BILINEAR );
grTexFilterMode(1,GR_TEXTUREFILTER_BILINEAR,GR_TEXTUREFILTER_BILINEAR );
grTexLodBiasValue(0, -1.0f );
grTexLodBiasValue(1, -1.0f );
GLI_BIG_GLOBALS -> ulCurrentZTable = 0;
/* get fog distance value */
{
long lIndex;
extern float GLI_ga_fFogDist[ 64 ];
for (lIndex = 0; lIndex < GLI_g_lNumberOfFogTableEntries; lIndex++)
GLI_ga_fFogDist[lIndex] = guFogTableIndexToW(lIndex) * GLI_C_xZClippingNear;
}
/* set format of vertices */
grCoordinateSpace(GR_WINDOW_COORDS);
grViewport((FxU32)0, (FxU32)0, (FxU32)_lWidth, (FxU32)_lHeight);
grDepthRange(0,1);
grRenderBuffer( GR_BUFFER_BACKBUFFER );
/*
* Init render parameters
*/
GLI_fn_vInitRenderParameters();
/*
* Set driver capabilities
*/
VD2_fnv_SetCaps( g_p_stGliCaps );
}
void GLI_DRV_vCloseDriver()
{
grSstWinClose( GLI_g_xGlideContext );
grGlideShutdown();
GLI_MDRV_vTmpFree( GLI_BIG_GLOBALS->p_TheZListe->p_TableOfPoints );
GLI_MDRV_vTmpFree( GLI_BIG_GLOBALS->p_TheZListe );
}
/*
=======================================================================================
Clear
=======================================================================================
*/
void GLI_DRV_vClearZBufferRegion(long lXStart,long lXEnd,long lYStart,long lYEnd)
{
if (!GLI_BIG_GLOBALS->bDrawMirrorSymetric)
GLI_BIG_GLOBALS->lDisplayMenuIsDetected = 1;
}
void GLI_vBeginDrawingTexturedMirrors(void)
{
GLI_BIG_GLOBALS->bDrawMirrorSymetric = 1;
}
void GLI_vBeginDrawingTexturedMirrorsSurfaces()
{
GLI_BIG_GLOBALS->lAMirrorIsDetected = 3;
}
void GLI_vEndDrawingTexturedMirrors()
{
GLI_BIG_GLOBALS->lAMirrorIsDetected &= 1;
GLI_BIG_GLOBALS->bDrawMirrorSymetric = 0;
}
void GLI_DRV_vClearDevice(BOOL ZBuffer, BOOL ColorBuffer, unsigned long Color)
{
if (GLI_MDRV_xIsGliInit())
{
if (ColorBuffer)
grColorMask( FXTRUE, FXFALSE );
else
grColorMask( FXFALSE, FXFALSE );
if (ZBuffer)
grDepthMask( FXTRUE );
else
grDepthMask( FXFALSE );
//GLI3grBufferClear( Color, 0, GR_WDEPTHVALUE_FARTHEST );
grBufferClear( Color, 0, GLI_g_lWDepthMinMaxValue[1] );
grColorMask( FXTRUE, FXFALSE );
grDepthMask( FXTRUE );
}
}
/*
=======================================================================================
Flip
=======================================================================================
*/
void GLI_DRV_vFlipDevice(long lNbFrames)
{
PRF_MDRV_vStartChrono( PRF_C_ulWaitFor3dFx , NULL);
if (!GLI_MDRV_xIsGliInit())
return;
GLI_BIG_GLOBALS->lDisplayMenuIsDetected = 0;
GLI_BIG_GLOBALS->lAMirrorIsDetected = 0;
//grSstIdle();
grFinish();
PRF_MDRV_vStopChrono( PRF_C_ulWaitFor3dFx , NULL);
PRF_MDRV_vStopChrono( PRF_C_ulFctMainLoop , NULL);
PRF_MDRV_lIncIndependantVariable( PRF_C_ulIdpRasterTime, -(long)TMR_fn_ulFastGetInternalCounter() );
GAM_MDRV_vShowRasters();
PRF_MDRV_lIncIndependantVariable( PRF_C_ulIdpRasterTime, TMR_fn_ulFastGetInternalCounter() );
PRF_MDRV_vStartChrono (PRF_C_ulFctFlip , NULL);
grBufferSwap( lNbFrames );
do
{
//lNbFrames = grBufferNumPending();
grGet( GR_PENDING_BUFFERSWAPS, 4, &lNbFrames );
}
while (lNbFrames != 0 );
#ifdef _DEBUG
if ( gs_bIsWindowed )
{
GLI_fn_vCopyBackBufferToD3DBackBuffer();
}
#endif
PRF_MDRV_vStopChrono (PRF_C_ulFctFlip , NULL);
PRF_MDRV_vStartChrono (PRF_C_ulFctMainLoop, NULL);
}
void GLI_DRV_vFlipDeviceWithSyncro( void )
{
GLI_DRV_vFlipDevice( 1 );
}
/*
----------------------------------------------------------------------------------------
Description : Get display statistics
_p_ulPixelSent -> return % of pixel sent / screen size
_p_ulPixelDisplayed -> return % of display pixel / screen size
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vGetStats(unsigned long *_p_ulPixelsSent, unsigned long *_p_ulPixelsDisplayed )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
//GrSstPerfStats_t stStats;
unsigned long ulScreenSize;
unsigned long ulPixelsIn, ulPixelsOut;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (!GLI_MDRV_xIsGliInit())
return;
//grSstPerfStats( &stStats );
grGet( GR_STATS_PIXELS_IN, 4, &ulPixelsIn );
grGet( GR_STATS_PIXELS_OUT, 4, &ulPixelsOut );
ulScreenSize = 480 * 640 / 100;
*_p_ulPixelsSent = ulPixelsIn / ulScreenSize;
*_p_ulPixelsDisplayed = ulPixelsOut / ulScreenSize;
grReset( GR_STATS_PIXELS );
}
/*
----------------------------------------------------------------------------------------
Description : enumerate display mode
----------------------------------------------------------------------------------------
*/
long __declspec(dllexport) GLI_DRV_fnl_EnumModes( char *_sz_DriverName, char *_sz_DeviceName )
{
GrResolution stQuery;
GrResolution *p_stQueryResult;
int iListSize;
int iIndex;
int iResIndex;
/* find all possible modes that include a z-buffer */
grGlideInit();
grSstSelect( 0 );
stQuery.resolution = GR_QUERY_ANY;
stQuery.refresh = GR_REFRESH_60Hz;
stQuery.numColorBuffers = 2;
stQuery.numAuxBuffers = 1;
iListSize = grQueryResolutions( &stQuery, NULL );
p_stQueryResult = malloc( iListSize );
grQueryResolutions( &stQuery, p_stQueryResult );
grGlideShutdown();
iListSize /= sizeof(iListSize);
for (iIndex = 0; iIndex < iListSize; iIndex++)
{
for (iResIndex = 0; iResIndex < 16; iResIndex++)
{
if (p_stQueryResult[iIndex].resolution == g_a_stGlideRes[iResIndex].lCode)
break;
}
if (iResIndex < 16)
{
if ( !g_a_stGlideRes[iResIndex].lAlreadyAdded )
{
g_a_stGlideRes[iResIndex].lAlreadyAdded = 1;
GLI_MDRV_lAddDisplayMode( 1, g_a_stGlideRes[iResIndex].ulWidth, g_a_stGlideRes[iResIndex].ulHeight, 16 );
}
}
}
free( p_stQueryResult );
return 1;
}
/*
----------------------------------------------------------------------------------------
Description : change mode
----------------------------------------------------------------------------------------
*/
HRESULT GLI_DRV_hChangeMode( BOOL _bFullScreen, long _lWidth, long _lHeight, long _lBpp )
{
return 0;
}
long (*gpfnl_AddDisplayInfo) (long, long, long , char*, unsigned long );
long __declspec(dllexport) GLI_DRV_fn_lGetAllDisplayConfig( FARPROC _x_Fct )
{
long l_Disp, l_Dev, l_Mode;
tdstGliCaps stCaps;
gpfnl_AddDisplayInfo = (long (__cdecl *)( long, long, long, char *, unsigned long ) ) _x_Fct;
if ( gpfnl_AddDisplayInfo(0, 0, 0, "miscvoodoodetect", 2) == 0)
return 0;
gpfnl_AddDisplayInfo( 0, 0, 0, "dll_bmp", 1);
l_Disp = gpfnl_AddDisplayInfo( 0, 0, 0, "dispadd", 0 );
gpfnl_AddDisplayInfo( l_Disp, 0, 0, "dispname", (long) "" );
gpfnl_AddDisplayInfo( l_Disp, 0, 0, "dispdesc", (long) "---" );
l_Dev = gpfnl_AddDisplayInfo( l_Disp, 0, 0, "dev_add", 0 );
gpfnl_AddDisplayInfo( l_Disp, l_Dev, 0, "dev_name", (long) "" );
gpfnl_AddDisplayInfo( l_Disp, l_Dev, 0, "dev_desc", (long) "---" );
{
GrResolution stQuery;
GrResolution *p_stQueryResult;
int iListSize;
int iIndex;
int iResIndex;
/* find all possible modes that include a z-buffer */
grGlideInit();
grSstSelect( 0 );
stQuery.resolution = GR_QUERY_ANY;
stQuery.refresh = GR_REFRESH_60Hz;
stQuery.numColorBuffers = 2;
stQuery.numAuxBuffers = 1;
iListSize = grQueryResolutions( &stQuery, NULL );
p_stQueryResult = malloc( iListSize );
grQueryResolutions( &stQuery, p_stQueryResult );
grGlideShutdown();
iListSize /= sizeof(iListSize);
for (iIndex = 0; iIndex < iListSize; iIndex++)
{
for (iResIndex = 0; iResIndex < 16; iResIndex++)
{
if (p_stQueryResult[iIndex].resolution == g_a_stGlideRes[iResIndex].lCode)
break;
}
if (iResIndex < 16)
{
if ( !g_a_stGlideRes[iResIndex].lAlreadyAdded )
{
g_a_stGlideRes[iResIndex].lAlreadyAdded = 1;
l_Mode = gpfnl_AddDisplayInfo( l_Disp, l_Dev, 0, "modeadd", 0 );
gpfnl_AddDisplayInfo( l_Disp, l_Dev, l_Mode, "modefs", 1 );
gpfnl_AddDisplayInfo( l_Disp, l_Dev, l_Mode, "modebpp", 16 );
gpfnl_AddDisplayInfo( l_Disp, l_Dev, l_Mode, "modew", g_a_stGlideRes[iResIndex].ulWidth );
gpfnl_AddDisplayInfo( l_Disp, l_Dev, l_Mode, "modeh", g_a_stGlideRes[iResIndex].ulHeight );
}
}
}
free( p_stQueryResult );
}
VD2_fnv_SetCaps( &stCaps );
gpfnl_AddDisplayInfo( l_Disp, l_Dev, 0, "dev_caps", (long) &stCaps );
return 1;
}
#ifdef __cplusplus
} //extern "C"
#endif

View File

@@ -0,0 +1,45 @@
#ifndef __GLIDE2TO3_H__
#define __GLIDE2TO3_H__
typedef struct
{
float sow; /* s texture ordinate (s over w) */
float tow; /* t texture ordinate (t over w) */
float oow; /* 1/w (used mipmapping - really 0xfff/w) */
} GrTmuVertex;
typedef struct
{
float x, y, z; /* X, Y, and Z of scrn space -- Z is ignored */
float r, g, b; /* R, G, B, ([0..255.0]) */
float ooz; /* 65535/Z (used for Z-buffering) */
float a; /* Alpha [0..255.0] */
float oow; /* 1/W (used for W-buffering, texturing) */
GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
} OldGrVertex;
#define GLI_tdScreenVertx OldGrVertex
#define GR_VERTEX_X_OFFSET 0
#define GR_VERTEX_Y_OFFSET 1
#define GR_VERTEX_Z_OFFSET 2
#define GR_VERTEX_R_OFFSET 3
#define GR_VERTEX_G_OFFSET 4
#define GR_VERTEX_B_OFFSET 5
#define GR_VERTEX_OOZ_OFFSET 6
#define GR_VERTEX_A_OFFSET 7
#define GR_VERTEX_OOW_OFFSET 8
#define GR_VERTEX_SOW_TMU0_OFFSET 9
#define GR_VERTEX_TOW_TMU0_OFFSET 10
#define GR_VERTEX_OOW_TMU0_OFFSET 11
#define GR_VERTEX_SOW_TMU1_OFFSET 12
#define GR_VERTEX_TOW_TMU1_OFFSET 13
#define GR_VERTEX_OOW_TMU1_OFFSET 14
#if (GLIDE_NUM_TMU > 2)
#define GR_VERTEX_SOW_TMU2_OFFSET 15
#define GR_VERTEX_TOW_TMU2_OFFSET 16
#define GR_VERTEX_OOW_TMU2_OFFSET 17
#endif
#endif

View File

@@ -0,0 +1,26 @@
#ifndef GLI_TEXTUDFX_H
#define GLI_TEXTUDFX_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern GrChipID_t GLI_GLIDE1_xTmuNumber;
typedef struct GLI_tdstTextureDFX_
{
float lMultiplyHeight;
float lMultiplyWidth;
long lMultiplyHeightPowerOf2;
long lMultiplyWidthPowerOf2;
GrChipID_t xTmuNumber;
FxU32 xStartAddress;
FxU32 xEvenOdd;
GrTexInfo stInfoBitmapGlide;
} GLI_tdstTextureDFX;
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif // GLI_TEXTUDFX_H

View File

@@ -0,0 +1,9 @@
SCC = This is a Source Code Control file
[Glide3.dsp]
SCC_Aux_Path = "\\srvprojets-ma\Rayman4_DS\Versions\Rayman4DS\Tools"
SCC_Project_Name = "$/CPA/tempgrp/GliGlou/Drivers/GLIDE3", ZFMAAAAA
[Glide3.mak]
SCC_Aux_Path = "\\srvprojets-ma\Rayman4_DS\Versions\Rayman4DS\Tools"
SCC_Project_Name = "$/CPA/tempgrp/GliGlou/Drivers/GLIDE3", ZFMAAAAA

View File

@@ -0,0 +1,54 @@
; GliDLL.def : Declares the module parameters for the DLL.
LIBRARY
DESCRIPTION 'Gli Specific Driver'
EXPORTS
;**** DOMATxxx.C
GLI_DRV_vDoOpaqueTextureSelection
GLI_DRV_vWrite16bBitmapToBackBuffer
GLI_DRV_vAddBlackPolygon
GLI_DRV_vNoBlackPolygon
GLI_DRV_vComputeFogEffect
GLI_DRV_bBeginScene
GLI_DRV_bEndScene
;**** ACCES_XXXX.C
GLI_DRV_vSendSpriteToClip
GLI_DRV_vSendSpriteToClipWithUV
;**** ACCES_ALL.C
GLI_DRV_vSendSingleLineToClip
;**** HDWTex_xxx.C
GLI_DRV_vDownLoadTextures
GLI_DRV_vUnLoadTextures
GLI_DRV_lGetSizeOfTexture
;**** init_XXX.c
GLI_DRV_vFlipDevice
GLI_DRV_vFlipDeviceWithSyncro
GLI_DRV_vClearDevice
GLI_DRV_xInitDriver
GLI_DRV_vCloseDriver
GLI_DRV_vClearZBufferRegion
GLI_DRV_hChangeMode
GLI_DRV_bLockDevice
GLI_DRV_bUnlockDevice
GLI_DRV_vGetStats
GLI_DRV_vWaitRetrace
;**** ClipTriangles
GLI_DRV_xClearViewingList
GLI_DRV_xSendListToViewport
GLI_DRV_vSetZClip
GLI_DRV_vSetClipWindow
GLI_DRV_xSendElementTIToClip_TRIANGLES
GLI_DRV_xSendSingleTriangleToClip_TRIANGLES
;*** set gli common functions
GLI_DRV_lGetDllInfo
GLI_DRV_lSetCommonData
GLI_DRV_lSetCommonFct

View File

@@ -0,0 +1,134 @@
#include <kamui.h>
/* GET*/
#define GetX(a) a.fX
#define GetY(a) a.fY
#define GetZ(a) a.fZ
#define GetPackedColor(a) *(unsigned long *)&a.uBaseRGB
#define GetU(a) a.fU
#define GetV(a) a.fV
/* SET*/
#define SetX(a,b) a.fX = b
#define SetY(a,b) a.fY = b
#define SetZ(a,b) a.fZ = b
#define SetPackedColor(a,b) *(unsigned long *)&a.uBaseRGB = b
#define SetPackedSpecular(a,b)
#define SetU(a,b) a.fU = b
#define SetV(a,b) a.fV = b
#define SetU_Cpy(a,b) *(unsigned long *)&a.fU = *(unsigned long *)&b
#define SetV_Cpy(a,b) *(unsigned long *)&a.fV = *(unsigned long *)&b
/* GLOBALS*/
#define GLI_tdScreenVertx KMVERTEX_03
extern KMVERTEXBUFFDESC VertexBufferDesc;
KMVERTEX_03 CurrentDestXYZ[4];
/* Special functions*/
#define GLI_M_RestoreCW()\
{\
CurrentDestXYZ[0].ParamControlWord = \
CurrentDestXYZ[1].ParamControlWord = \
CurrentDestXYZ[3].ParamControlWord = KM_VERTEXPARAM_NORMAL;\
CurrentDestXYZ[2].ParamControlWord = KM_VERTEXPARAM_ENDOFSTRIP;\
}\
static void GLI_BeforeDraw()
{
GLI_M_RestoreCW();
};
#define GLI_AfterDraw()
static void GLI_DrawQuad(void)
{
kmSetVertex(&VertexBufferDesc,&CurrentDestXYZ[0],KM_VERTEXTYPE_03,sizeof(CurrentDestXYZ[1]));
kmSetVertex(&VertexBufferDesc,&CurrentDestXYZ[1],KM_VERTEXTYPE_03,sizeof(CurrentDestXYZ[1]));
kmSetVertex(&VertexBufferDesc,&CurrentDestXYZ[3],KM_VERTEXTYPE_03,sizeof(CurrentDestXYZ[1]));
kmSetVertex(&VertexBufferDesc,&CurrentDestXYZ[2],KM_VERTEXTYPE_03,sizeof(CurrentDestXYZ[1]));
}
/* Draw Triangle*/
GLI_FuncNodeBegin(GLI_vDrawTriangle)
{
kmSetVertex(&VertexBufferDesc,&CurrentDestXYZ[0],KM_VERTEXTYPE_03,3*sizeof(CurrentDestXYZ[0]));
}
void GLI_vDrawZSortedTriangle(void *p_3Point)
{
}
void GLI_vDrawZSortedQuad(void *p_3Point)
{
}
void GLI_vAddDrawFunc()
{
GLI_M_AddFunc(GLI_vDrawTriangle);
}
/* GLI_BIG_GLOBALS -> lClippingModeMask*/
void GLI_ReComputeClippingMask()
{
*(float *)&fX_CMP_Optimize = 640.0f;
*(float *)&fY_CMP_Optimize = 480.0f;
*(float *)&fXMin_CLIP_Optimize = 100.0f;
*(float *)&fYMin_CLIP_Optimize = 50.0f;
*(float *)&fXMax_CLIP_Optimize = 540.0f;
*(float *)&fYMax_CLIP_Optimize = 430.0f;
}
/**********************************************************************************************/
/* Name: GLI_DRV_vSendSpriteToClip*/
/* Goal: draw a sprite*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void GLI_DRV_vSendSpriteToClip
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_BeforeDraw();
GLI_M_InitSprite();
SetU(CurrentDestXYZ[0],0.0f);
SetV(CurrentDestXYZ[0],1.0f);
SetU(CurrentDestXYZ[1],1.0f);
SetV(CurrentDestXYZ[1],1.0f);
SetU(CurrentDestXYZ[2],1.0f);
SetV(CurrentDestXYZ[2],0.0f);
SetU(CurrentDestXYZ[3],0.0f);
SetV(CurrentDestXYZ[3],0.0f);
GLI_DrawQuad();
GLI_AfterDraw();
}
/**********************************************************************************************/
/* Name: GLI_DRV_vSendSpriteToClipWithUV 1.0*/
/* Goal: */
/* Code: Philippe Vimont / 1.0*/
/* REM: */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void GLI_DRV_vSendSpriteToClipWithUV
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal *a8_stUVVertex,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_BeforeDraw();
GLI_M_InitSprite();
SetU(CurrentDestXYZ[2],a8_stUVVertex[4]);
SetV(CurrentDestXYZ[2],a8_stUVVertex[4+1]);
SetU(CurrentDestXYZ[3],a8_stUVVertex[6]);
SetV(CurrentDestXYZ[3],a8_stUVVertex[6+1]);
SetU(CurrentDestXYZ[0],a8_stUVVertex[0]);
SetV(CurrentDestXYZ[0],a8_stUVVertex[0+1]);
SetU(CurrentDestXYZ[1],a8_stUVVertex[2]);
SetV(CurrentDestXYZ[1],a8_stUVVertex[2+1]);
GLI_DrawQuad();
GLI_AfterDraw();
}

View File

@@ -0,0 +1,374 @@
/******************************************************************************************
FILE : CLIPDomat.C
VERS : 1.00 \ Marc Villemain - version directX5
0.00 \ Philippe Vimont
DATE : 15.05.97
Select materials
*******************************************************************************************/
#include "Gli_st.h"
#include "GLI_Defn.h"
#include "polygon.h"
#include "mater_st.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "ScrVert.h"
#include "Liste.h"
#include "SelecTex.h"
#include "watrplan.h"
#include "proj.h"
#include "vpt3D.h"
#include "camera.h"
#include "material.h"
#include "texture.h"
#include "GliBench.h
#include <kamui.h>
#include "GLI_interface.h"
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef ZARMA
}
#endif
extern KMVERTEXBUFFDESC VertexBufferDesc;
/*extern long GLD_RenderingCounter;*/
extern KMVERTEX_03 CurrentDestXYZ[4];
extern long TRYIT;
extern GLI_tdxValue xZFogDepth;
/*extern GEO_tdstColor stColorDepthCuing;*/
/*extern float xZDepthStart,xZDepthEnd,xZDepthConstant;*/
/*extern float xFogIntensityStart;*/
/*extern float xFogIntensityEnd;*/
/*extern GLI_tdxValue xDepthStartSave,xZDepthEndSave;*/
extern KMSURFACEDESC stSpecialTexture;
extern KMSURFACEDESC stSpecialTexture20;
extern KMSURFACEDESC stSpecialTexture21;
extern KMVERTEXCONTEXT stRenderingContex;
void GLI_fnSwitchTwiddled(short *p_Texture , long size );
short VignetteBuffer[1024L * 1024L];
/*static long bisready = 0;*/
/*void ZZZGLI_ZOOOOOOOOOOOORRRRRRGGGLL();*/
#define GLI_M_ChangeRenderingParrameter( Renderingflag, Renderingvar, Renderingval) \
{\
if (stRenderingContex . Renderingvar != (Renderingval))\
{\
stRenderingContex . RenderState |= (Renderingflag);\
stRenderingContex . Renderingvar = (Renderingval);\
}\
}
void GLI_BigInitKamuiRendering(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
memset( &stRenderingContex, 0, sizeof(stRenderingContex)); /* Crear Context*/
stRenderingContex . RenderState = KM_DEPTHMODE | KM_CULLINGMODE | KM_SCREENCOORDINATION | KM_SHADINGMODE | KM_MODIFIER | KM_ZWRITEDISABLE | KM_SRCBLENDINGMODE | KM_DSTBLENDINGMODE| KM_SRCSELECT | KM_DSTSELECT| KM_FOGMODE | KM_USESPECULAR| KM_USEALPHA | KM_IGNORETEXTUREALPHA| KM_FLIPUV | KM_CLAMPUV| KM_FILTERMODE | KM_SUPERSAMPLE | KM_MIPMAPDADJUST | KM_TEXTURESHADINGMODE| KM_PARAMTYPE | KM_LISTTYPE | KM_COLORTYPE | KM_USESPECULAR| KM_UVFORMAT;
stRenderingContex . ParamType = KM_POLYGON;
stRenderingContex . ListType = KM_OPAQUE_POLYGON;
stRenderingContex . ColorType = KM_PACKEDCOLOR;/*KM_FLOATINGCOLOR;*/
stRenderingContex . bUseSpecular = FALSE;/*TRUE;*/
stRenderingContex . UVFormat = KM_32BITUV;
stRenderingContex . DepthMode = KM_GREATER;
stRenderingContex . CullingMode = KM_NOCULLING;
stRenderingContex . ScreenCoordination = KM_SCREEN;/*KM_PROJECTIVE;//KM_SCREEN;*/
stRenderingContex . ShadingMode = KM_NOTEXTUREGOURAUD;
stRenderingContex . SelectModifier = KM_NOMODIFIER;
stRenderingContex . bZWriteDisable = FALSE;
stRenderingContex . SRCBlendingMode = KM_ONE;
stRenderingContex . DSTBlendingMode = KM_ZERO;
stRenderingContex . bSRCSel = FALSE;
stRenderingContex . bDSTSel = FALSE;
stRenderingContex . FogMode = KM_NOFOG;
stRenderingContex . FogMode = KM_FOGTABLE;
stRenderingContex . bUseSpecular = FALSE;
stRenderingContex . bUseAlpha = FALSE;
stRenderingContex . FlipUV = KM_NOFLIP;
stRenderingContex . ClampUV = KM_CLAMP_UV;/*KM_NOCLAMP;*/
stRenderingContex . FilterMode = KM_BILINEAR;/*KM_POINT_SAMPLE;*/
stRenderingContex . bSuperSample = FALSE;
stRenderingContex . MipMapAdjust = 0x00000003;
stRenderingContex . TextureShadingMode = KM_MODULATE_ALPHA;
stRenderingContex . bColorClamp = FALSE;
stRenderingContex . PaletteBank = 0;
stRenderingContex . fFaceColorAlpha = 1.0f;
stRenderingContex . fFaceColorRed = 1.0f;
stRenderingContex . fFaceColorGreen = 1.0f;
stRenderingContex . fFaceColorBlue = 1.0f;
stRenderingContex . fOffsetColorAlpha = 1.0f;
stRenderingContex . fOffsetColorRed = 1.0f;
stRenderingContex . fOffsetColorGreen = 1.0f;
stRenderingContex . fOffsetColorBlue = 1.0f;
kmProcessVertexRenderState(&stRenderingContex);
}
void GLI_INTERFACE_FUNC(GLI_vDoTextureSelection)(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
static bFirst = 0;
if (*GLD_p_lRenderingCounter != p_stGlobaleMT->GLD_RenderingCounter)
{
p_stGlobaleMT->GLD_RenderingCounter = *GLD_p_lRenderingCounter;
}
if (!bFirst)
{
bFirst = 1;
GLI_BigInitKamuiRendering(p_stGlobaleMT);
}
stRenderingContex . RenderState = 0;
if (GLI_BIG_GLOBALS->xFogIsOn)
{
if ( GLI_BIG_GLOBALS->p_stLastComputedFog != GLI_BIG_GLOBALS->p_stActiveFog )
{
GLI_vSetFogParams( GLI_BIG_GLOBALS->p_stActiveFog );
GLI_BIG_GLOBALS->p_stLastComputedFog = GLI_BIG_GLOBALS->p_stActiveFog;
}
GLI_M_ChangeRenderingParrameter(KM_FOGMODE , FogMode , KM_FOGTABLE);
}
else
{
GLI_M_ChangeRenderingParrameter(KM_FOGMODE , FogMode , KM_NOFOG);
}
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsTestingBackface)
{
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lNotInvertBackfaces)
{
GLI_M_ChangeRenderingParrameter(KM_CULLINGMODE , CullingMode ,KM_CULLCW);
}
else
{
GLI_M_ChangeRenderingParrameter(KM_CULLINGMODE , CullingMode ,KM_CULLCCW);
}
}
else
GLI_M_ChangeRenderingParrameter(KM_CULLINGMODE , CullingMode ,KM_NOCULLING);
if (GLI_BIG_GLOBALS->lAMirrorIsDetected & 2)
{
GLI_M_ChangeRenderingParrameter(KM_FILTERMODE , FilterMode , KM_POINT_SAMPLE);
GLI_M_ChangeRenderingParrameter(KM_SHADINGMODE , ShadingMode ,KM_TEXTUREGOURAUD);
if ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))
{
GLI_M_ChangeRenderingParrameter(KM_LISTTYPE , ListType ,KM_TRANS_POLYGON);
GLI_M_ChangeRenderingParrameter(KM_SRCBLENDINGMODE , SRCBlendingMode ,KM_SRCALPHA);
GLI_M_ChangeRenderingParrameter(KM_DSTBLENDINGMODE , DSTBlendingMode ,KM_INVSRCALPHA);
GLI_M_ChangeRenderingParrameter(KM_USEALPHA , bUseAlpha , TRUE);
GLI_M_ChangeRenderingParrameter(KM_SRCBLENDINGMODE , SRCBlendingMode ,KM_ONE);
GLI_M_ChangeRenderingParrameter(KM_DSTBLENDINGMODE , DSTBlendingMode ,KM_ONE);
GLI_M_ChangeRenderingParrameter(KM_USEALPHA , bUseAlpha , FALSE);
} else {
GLI_M_ChangeRenderingParrameter(KM_LISTTYPE , ListType ,KM_OPAQUE_POLYGON);
GLI_M_ChangeRenderingParrameter(KM_SRCBLENDINGMODE , SRCBlendingMode ,KM_ONE);
GLI_M_ChangeRenderingParrameter(KM_DSTBLENDINGMODE , DSTBlendingMode ,KM_ZERO);
GLI_M_ChangeRenderingParrameter(KM_USEALPHA , bUseAlpha , FALSE);
}
stRenderingContex . pTextureSurfaceDesc = &stSpecialTexture;
}
else
{
if ((p_stGlobaleMT -> p_stCurrentTexture != NULL) && (p_stGlobaleMT -> p_stCurrentTexture -> bIsAvailable))
{
GLI_M_ChangeRenderingParrameter(KM_FILTERMODE , FilterMode , KM_BILINEAR);
GLI_M_ChangeRenderingParrameter(KM_SHADINGMODE , ShadingMode ,KM_TEXTUREGOURAUD);
if ((p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTexture | GLI_C_lNZTexture | GLI_C_lAddTransparencyTexture) )
|| ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (p_stGlobaleMT->xGlobalAlpha < 0.98f)))
{
GLI_M_ChangeRenderingParrameter(KM_LISTTYPE , ListType ,KM_TRANS_POLYGON);
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAddTransparencyTexture)
{
GLI_M_ChangeRenderingParrameter(KM_SRCBLENDINGMODE , SRCBlendingMode ,KM_ONE);
GLI_M_ChangeRenderingParrameter(KM_DSTBLENDINGMODE , DSTBlendingMode ,KM_ONE);
GLI_M_ChangeRenderingParrameter(KM_USEALPHA , bUseAlpha , FALSE);
} else {
GLI_M_ChangeRenderingParrameter(KM_SRCBLENDINGMODE , SRCBlendingMode ,KM_SRCALPHA);
GLI_M_ChangeRenderingParrameter(KM_DSTBLENDINGMODE , DSTBlendingMode ,KM_INVSRCALPHA);
GLI_M_ChangeRenderingParrameter(KM_USEALPHA , bUseAlpha , TRUE);
}
} else
{
GLI_M_ChangeRenderingParrameter(KM_LISTTYPE , ListType ,KM_OPAQUE_POLYGON);
GLI_M_ChangeRenderingParrameter(KM_SRCBLENDINGMODE , SRCBlendingMode ,KM_ONE);
GLI_M_ChangeRenderingParrameter(KM_DSTBLENDINGMODE , DSTBlendingMode ,KM_ZERO);
GLI_M_ChangeRenderingParrameter(KM_USEALPHA , bUseAlpha , FALSE);
}
switch (p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode)
{
case 0:
GLI_M_ChangeRenderingParrameter(KM_CLAMPUV , ClampUV ,KM_CLAMP_UV);
break;
case GLI_C_lCylingUV:
GLI_M_ChangeRenderingParrameter(KM_CLAMPUV , ClampUV ,KM_NOCLAMP);
break;
case GLI_C_lCylingU:
GLI_M_ChangeRenderingParrameter(KM_CLAMPUV , ClampUV ,KM_CLAMP_U);
break;
case GLI_C_lCylingV:
GLI_M_ChangeRenderingParrameter(KM_CLAMPUV , ClampUV ,KM_CLAMP_V);
break;
}
/* STRIPS BUG*/
/* GLI_M_ChangeRenderingParrameter(KM_CLAMPUV , ClampUV ,KM_NOCLAMP);*/
stRenderingContex . pTextureSurfaceDesc = p_stGlobaleMT -> p_stCurrentTexture -> p_stSpecParam;
} else
{
GLI_M_ChangeRenderingParrameter(KM_SHADINGMODE , ShadingMode ,KM_NOTEXTUREGOURAUD);
GLI_M_ChangeRenderingParrameter(KM_LISTTYPE , ListType ,KM_TRANS_POLYGON);
GLI_M_ChangeRenderingParrameter(KM_SRCBLENDINGMODE , SRCBlendingMode ,KM_SRCALPHA);
GLI_M_ChangeRenderingParrameter(KM_DSTBLENDINGMODE , DSTBlendingMode ,KM_INVSRCALPHA);
GLI_M_ChangeRenderingParrameter(KM_USEALPHA , bUseAlpha , TRUE);
p_stGlobaleMT-> p_stCurrentTexture = NULL;
}
}
kmProcessVertexRenderState(&stRenderingContex);
kmSetVertexRenderState(&stRenderingContex);
kmStartVertexStrip/*Direct*/(&VertexBufferDesc);
}
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
extern KMVERTEXBUFFDESC VertexBufferDesc;
void GLI_vWaitEndOfRendering();
void GLI_vWaitEndOfVertexTransfert();
void GLI_vWaitEndOfVSync();
void GLI_DRV_vWrite16bBitmapToBackBuffer( void *_p_vSourceBuffer, long _lWidth, long _lHeight, long _lDestLeft, long _lDestTop, long _lDestRight, long _lDestBottom )
{
KMVERTEX_03 gld_CurrentDestXYZ[4];
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT;
static bFirst = 0;
p_stGlobaleMT = GLI_BIG_GLOBALS;
if (!bFirst)
{
GLI_BigInitKamuiRendering(p_stGlobaleMT);
}
bFirst++;
if ((bFirst & 0x1F) ) /* == QUADRUPLE SPEED!!*/
{
/* GLI_vWaitEndOfVSync();
GLI_vWaitEndOfRendering();*/
GLD_MDRV_vBlitStretched16b( 512,512,VignetteBuffer ,512,_lWidth,_lHeight,_p_vSourceBuffer);
kmLoadTexture(&stSpecialTexture,(void *)VignetteBuffer,FALSE,FALSE);
}/* */
/* GLI_vWaitEndOfVSync();*/
/* return;*/
/* ------------------------ BEURK ---------------------------------*/
stRenderingContex . RenderState = 0;
GLI_M_ChangeRenderingParrameter(KM_SHADINGMODE , ShadingMode ,KM_TEXTUREGOURAUD);
GLI_M_ChangeRenderingParrameter(KM_LISTTYPE , ListType ,KM_OPAQUE_POLYGON);
GLI_M_ChangeRenderingParrameter(KM_SRCBLENDINGMODE , SRCBlendingMode ,KM_ONE);
GLI_M_ChangeRenderingParrameter(KM_DSTBLENDINGMODE , DSTBlendingMode ,KM_ZERO);
GLI_M_ChangeRenderingParrameter(KM_USEALPHA , bUseAlpha , FALSE);
GLI_M_ChangeRenderingParrameter(KM_CLAMPUV , ClampUV ,KM_CLAMP_UV);
GLI_M_ChangeRenderingParrameter(KM_CLAMPUV , ClampUV ,KM_CLAMP_UV);
GLI_M_ChangeRenderingParrameter(KM_FILTERMODE , FilterMode , KM_POINT_SAMPLE);
GLI_M_ChangeRenderingParrameter(KM_FOGMODE , FogMode , KM_NOFOG);
stRenderingContex . pTextureSurfaceDesc = &stSpecialTexture;/* */
kmProcessVertexRenderState(&stRenderingContex);
kmSetVertexRenderState(&stRenderingContex);
kmStartVertexStrip/*Direct*/(&VertexBufferDesc);
/* ------------------------ End BEURK ------------------------------*/
gld_CurrentDestXYZ[0] . fX = 0.0f;
gld_CurrentDestXYZ[0] . fY = 0.0f;
gld_CurrentDestXYZ[1] . fX = 0.0f;
gld_CurrentDestXYZ[1] . fY = 480.0f;
gld_CurrentDestXYZ[2] . fX = 640.0f;
gld_CurrentDestXYZ[2] . fY = 480.0f;
gld_CurrentDestXYZ[3] . fX = 640.0f;
gld_CurrentDestXYZ[3] . fY = 0.0f;
gld_CurrentDestXYZ[0] . fU = 0.0f;
gld_CurrentDestXYZ[0] . fV = 0.0f;
gld_CurrentDestXYZ[1] . fU = 0.0f;
gld_CurrentDestXYZ[1] . fV = 1.0f;
gld_CurrentDestXYZ[2] . fU = 1.0f;
gld_CurrentDestXYZ[2] . fV = 1.0f;
gld_CurrentDestXYZ[3] . fU = 1.0f;
gld_CurrentDestXYZ[3] . fV = 0.0f;
*(unsigned long *)&gld_CurrentDestXYZ[0].uBaseRGB =
*(unsigned long *)&gld_CurrentDestXYZ[1].uBaseRGB =
*(unsigned long *)&gld_CurrentDestXYZ[2].uBaseRGB =
*(unsigned long *)&gld_CurrentDestXYZ[3].uBaseRGB = 0xffffffff;
gld_CurrentDestXYZ[0] . fZ =
gld_CurrentDestXYZ[1] . fZ =
gld_CurrentDestXYZ[2] . fZ =
gld_CurrentDestXYZ[3] . fZ =1.0f;
gld_CurrentDestXYZ[0].ParamControlWord =
gld_CurrentDestXYZ[1].ParamControlWord =
gld_CurrentDestXYZ[3].ParamControlWord =
KM_VERTEXPARAM_NORMAL;
gld_CurrentDestXYZ[2].ParamControlWord = KM_VERTEXPARAM_ENDOFSTRIP;
kmSetVertex(&VertexBufferDesc,&gld_CurrentDestXYZ[0],KM_VERTEXTYPE_03,sizeof(gld_CurrentDestXYZ[1]));
kmSetVertex(&VertexBufferDesc,&gld_CurrentDestXYZ[1],KM_VERTEXTYPE_03,sizeof(gld_CurrentDestXYZ[1]));
kmSetVertex(&VertexBufferDesc,&gld_CurrentDestXYZ[3],KM_VERTEXTYPE_03,sizeof(gld_CurrentDestXYZ[1]));
kmSetVertex(&VertexBufferDesc,&gld_CurrentDestXYZ[2],KM_VERTEXTYPE_03,sizeof(gld_CurrentDestXYZ[1]));
}
float GLI_km_IndexTableToOoZ(long index)
{
return (float)( pow ( 2.0f , (index >> 4)) * (float)((index & 0x0f) + 16) / 16.0f);
}
void GLI_INTERFACE_FUNC(GLI_vSetFogParams) ( tdstFogParams *_p_stFogParams )
{
long i;
float km_FogTable[256], RealZ , fCoef;
float fStart, fEnd ;
KMPACKEDARGB kmColor;
GLI_tdxValue xBlendStart, xBlendEnd;
kmSetFogDensity(0xFF08);
/* xZDepthEndSave = _p_stFogParams->xDepthEnd;*/
xDepthStartSave = _p_stFogParams->xDepthStart;
xBlendStart = _p_stFogParams->xBlendStart / 255.0f;
xBlendEnd = _p_stFogParams->xBlendEnd / 255.0f;
fStart = _p_stFogParams->xDepthStart;
fEnd = _p_stFogParams->xDepthEnd;
fCoef = 1.0f / ( fEnd - fStart );
for (i = 0 ; i < 256 ; i++)
{
RealZ = GLI_km_IndexTableToOoZ(i) / 512.0f;
RealZ = GLI_C_xZClippingNear / RealZ;
/* realZ == Now Real Depth, not 1/W !!!*/
/* les salaud!!!*/
if (RealZ < fStart)
km_FogTable[i] = xBlendStart;
else
{
if (RealZ > fEnd)
km_FogTable[i] = xBlendEnd;
else
{
km_FogTable[i] = ( RealZ - fStart ) * fCoef;
km_FogTable[i] *= xBlendEnd - xBlendStart;
km_FogTable[i] += xBlendStart;
}
}
}
kmSetFogTable((PKMFLOAT)km_FogTable);
*(long *)&kmColor = RGB_MAKE((long)( _p_stFogParams->stColor.xR * 255.f),(long)(_p_stFogParams->stColor.xG * 255.f),(long)(_p_stFogParams->stColor.xB * 255.f));
kmSetFogTableColor(kmColor);
}
/*EVL*/
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@@ -0,0 +1,306 @@
/*
Tested with LINT
*/
/**************
TEXTURE.C
Ver 1.0
***************/
#include "GLD.h"
#include "GEO.h"
#include "TEX.h"
#include "gli_st.h"
#include "textu_st.h"
#include "texture.h"
#include <string.h>
#ifdef KAMUI
#include <kamui.h>
#endif
#include "GLI_interface.h"
unsigned long ulTotalUsedMemory;
unsigned long ulAgpUsedMemory;
extern unsigned long GLI_gsCurrentMemoryChannel;
extern unsigned long gs_lRGBBitCount;
extern long gs_lTreeOfNamesNumberOfLastLetter;
extern long gs_lNumberOfTextureToCreate;
extern long gs_lLastIdxInDEFTableOfTextures;
extern long lNbTextureFormat;
extern long lCurrentTextureFormat;
/*extern long gs_aDEFTableOfTextureMemoryChannels[ C_lMaxNumberOfTexture ];*/
extern unsigned char *gs_aCurrentTextures;
/*extern GLI_tdstTexture *gs_aDEFTableOfTextureAlreadyRead [ C_lMaxNumberOfTexture ];*/
extern unsigned char g_ucGliModuleId;
/*extern void *GLI_gs_p_ConvertBufferMipMapping;*/
short TEXTURETWIDDLED[1024L*1024L];
static unsigned long GLI_a256FastTwiddledTable[256];
/*unsigned long GLI_a256FastTwiddledTableD4[256];*/
long GLI_fnLinear2CasseTete(unsigned long lLinear , long lPitch)
{
unsigned long lreturnvalue = 0;
unsigned long CMPX = 1;
while (lLinear != 0)
{
if (lLinear & 128) lreturnvalue += CMPX<<3;
if (lLinear & 64) lreturnvalue += lPitch<<3;
if (lLinear & 32) lreturnvalue += CMPX<<2;
if (lLinear & 16) lreturnvalue += lPitch<<2;
if (lLinear & 8) lreturnvalue += CMPX<<1;
if (lLinear & 4) lreturnvalue += lPitch<<1;
if (lLinear & 2) lreturnvalue += CMPX;
if (lLinear & 1) lreturnvalue += lPitch;
CMPX<<=4;
lPitch<<=4;
lLinear >>= 8;
}
return lreturnvalue;
}
void GLI_InitTwiddlingTable(long largeur)
{
long i;
for (i = 0 ; i < 256 ; i++ )
GLI_a256FastTwiddledTable[i] = GLI_fnLinear2CasseTete(i, largeur);
}
void GLI_fnSwitchTwiddled(short *p_Texture , long size )
{
unsigned long xcounter, SizeXSize , SizeXSizeD8;
short *Pdest ;
unsigned long *GLI_a256FastTwiddledTableLocal;
static long largeur = 0;
short *p_TextureLocal,*p_DestLast;
Pdest = TEXTURETWIDDLED;
if (size != largeur)
{
GLI_InitTwiddlingTable(size);
largeur = size;
}
SizeXSize = size * size;
if (!(SizeXSize & 0xFF))
{
SizeXSizeD8 = SizeXSize >> 8;
for (xcounter = 0 ; xcounter < SizeXSizeD8 ; xcounter ++ )
{
p_TextureLocal = p_Texture + (GLI_a256FastTwiddledTable[xcounter & 0xFF]<<4);
p_TextureLocal += GLI_a256FastTwiddledTable[(xcounter>>8) & 0xFF]<<8;
p_DestLast = Pdest + 256;
GLI_a256FastTwiddledTableLocal = GLI_a256FastTwiddledTable;
while (Pdest < p_DestLast)
*(Pdest++)= *(p_TextureLocal + *(GLI_a256FastTwiddledTableLocal++));
}
}
else
{
xcounter = SizeXSize ;
for ( xcounter = 0 ; xcounter < SizeXSize ; xcounter++ )
*(Pdest++)= *(p_Texture +
GLI_a256FastTwiddledTable[xcounter & 0xFF] +
(GLI_a256FastTwiddledTable[(xcounter>>8) & 0xFF]<<4) +
(GLI_a256FastTwiddledTable[(xcounter>>16) & 0xFF]<<8));
}
memcpy( p_Texture, TEXTURETWIDDLED , SizeXSize<<1);
}
/*void GLI_xLoadTextureInTexelField(GLI_tdstTexture *p_stTexture, long *p_lTexelField);*/
/*void GLI_vDivideBitmapSurfaceBy2NonZero (unsigned long *p_Source,unsigned long *p_Dest,long lWidthSurfSouce, long lLenghtSurfSouce);*/
/*void GLI_vDivideBitmapSurfaceBy2 (unsigned long *p_Source,unsigned long *p_Dest,long lWidthSurfSouce, long lLenghtSurfSouce);*/
/*long GLI_lComputeTexturesSize();*/
#ifdef KAMUI
unsigned long GLI_lCorrectOffset(unsigned long lHeight)
{
long lReturnValue, LHeightLoc;
lReturnValue = 0;
LHeightLoc = lHeight;
while (LHeightLoc)
{
LHeightLoc>>=1;
lReturnValue += LHeightLoc * LHeightLoc;
}
return (lReturnValue + 1);
}
void GLI_KamuiComputeMipMapping(void *p_SRC ,unsigned long Size ,KMTEXTURETYPE mode)
{
unsigned short *p_Local,*p_Local1;
unsigned long *p_Local2;
unsigned long *p_MEMCPY1 , *p_MEMCPY2 ,LocalSize;
unsigned long SizeXSize, SizeXSizeLocal , ulLocalColor;
p_Local = (unsigned short *)p_SRC;
SizeXSize = Size * Size;
p_Local1 = p_Local + GLI_lCorrectOffset(Size);
p_MEMCPY1 = (unsigned long *)p_Local1;
p_MEMCPY2 = (unsigned long *)p_Local;
LocalSize = SizeXSize>>1;
p_MEMCPY1 += LocalSize;
p_MEMCPY2 += LocalSize;
while (LocalSize--)
{
*(--p_MEMCPY1) = *(--p_MEMCPY2);
}
/* return;// */
/* memcpy( p_Local1 , p_Local , SizeXSize<<1);*/
Size >>= 1;
while (Size)
{
SizeXSize >>= 2;
SizeXSizeLocal = SizeXSize;
p_Local1 = p_Local + GLI_lCorrectOffset(Size);
(unsigned short *)p_Local2 = p_Local1 + SizeXSize;
switch (mode)
{
case KM_TEXTURE_RGB565:
while (SizeXSizeLocal--)
{
ulLocalColor = ((*(p_Local2) & 0x0000001f) << 1) + ((*(p_Local2) & 0x000007e0) << 3) + ((*(p_Local2) & 0x0000f800) << 6) + ((*(p_Local2) & 0x001f0000) >> 15) + ((*(p_Local2) & 0x07e00000) >> 13) + ((*(p_Local2) & 0xf8000000) >> 10);
p_Local2++;
ulLocalColor += ((*(p_Local2) & 0x0000001f) << 1) + ((*(p_Local2) & 0x000007e0) << 3) + ((*(p_Local2) & 0x0000f800) << 6) + ((*(p_Local2) & 0x001f0000) >> 15) + ((*(p_Local2) & 0x07e00000) >> 13) + ((*(p_Local2) & 0xf8000000) >> 10);
ulLocalColor <<= 8;
ulLocalColor = (ulLocalColor & 0xf8000000) | ((ulLocalColor & 0x00f80000)<<3) | ((ulLocalColor & 0x0000f800)<<5);
*(p_Local1++) = (unsigned short)(ulLocalColor>>16);
p_Local2++;
}
break;
case KM_TEXTURE_ARGB4444:
while (SizeXSizeLocal--)
{
ulLocalColor = ((*(p_Local2) & 0x0000000F) << 2 ) + ((*(p_Local2) & 0x000000F0) << 6 ) + ((*(p_Local2) & 0x00000F00) << 10) + ((*(p_Local2) & 0x0000f000) << 14) + ((*(p_Local2) & 0x000F0000) >> 14) + ((*(p_Local2) & 0x00F00000) >> 10) + ((*(p_Local2) & 0x0F000000) >> 6 ) + ((*(p_Local2) & 0xf0000000) >> 2 );
p_Local2++;
ulLocalColor += ((*(p_Local2) & 0x0000000F) << 2 ) + ((*(p_Local2) & 0x000000F0) << 6 ) + ((*(p_Local2) & 0x00000F00) << 10) + ((*(p_Local2) & 0x0000f000) << 14) + ((*(p_Local2) & 0x000F0000) >> 14) + ((*(p_Local2) & 0x00F00000) >> 10) + ((*(p_Local2) & 0x0F000000) >> 6 ) + ((*(p_Local2) & 0xf0000000) >> 2 );
ulLocalColor = (ulLocalColor & 0xf0000000) | ((ulLocalColor & 0x00f00000)<<4) | ((ulLocalColor & 0x0000f000)<<8) | ((ulLocalColor & 0x000000f0)<<12);
*(p_Local1++) = (unsigned short)(ulLocalColor>>16);
p_Local2++;
}
break;
case KM_TEXTURE_ARGB1555:
while (SizeXSizeLocal--)
{
ulLocalColor = ((*(p_Local2) & 0x0000001F) << 1 ) + ((*(p_Local2) & 0x000003E0) << 4 ) + ((*(p_Local2) & 0x00007C00) << 7 ) + ((*(p_Local2) & 0x00008000) << 14) + ((*(p_Local2) & 0x001F0000) >> 15) + ((*(p_Local2) & 0x03E00000) >> 12) + ((*(p_Local2) & 0x7C000000) >> 9 ) + ((*(p_Local2) & 0x80000000) >> 2 ) ;
p_Local2++;
ulLocalColor += ((*(p_Local2) & 0x0000001F) << 1 ) + ((*(p_Local2) & 0x000003E0) << 4 ) + ((*(p_Local2) & 0x00007C00) << 7 ) + ((*(p_Local2) & 0x00008000) << 14) + ((*(p_Local2) & 0x001F0000) >> 15) + ((*(p_Local2) & 0x03E00000) >> 12) + ((*(p_Local2) & 0x7C000000) >> 9 ) + ((*(p_Local2) & 0x80000000) >> 2 ) ;
ulLocalColor = (ulLocalColor & 0x80000000) | ((ulLocalColor & 0x00f80000)<<7) | ((ulLocalColor & 0x0000f800)<<10) | ((ulLocalColor & 0x000000f8)<<13);
*(p_Local1++) = (unsigned short)(ulLocalColor>>16);
p_Local2++;
}
break;
}
Size >>= 1;
}
}
void GLI_DRV_vDownLoadTextures(long bRestore, long _lTextureMode, BOOL bReloading )
{
long lTextureCounter;
KMTEXTURETYPE nTextureType;
GLI_tdstTexture *p_stTexture;
for (lTextureCounter = 0; lTextureCounter < GLI_C_lNBMaxOfTextures ; lTextureCounter ++)
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated )
{
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
while (p_stTexture != NULL)
{
p_stTexture -> bIsAvailable = 0;
GLI_MDRV_xLoadTextureInTexelField(p_stTexture, GLI_gs_p_ConvertBufferMipMapping,TRUE);
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
{
GLI_MDRV_vCompressTex1555 ( p_stTexture , GLI_gs_p_ConvertBufferMipMapping);
nTextureType = KM_TEXTURE_ARGB1555;
} else
{
if ((p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture) == 0)
{
GLI_MDRV_vCompressTex565 ( p_stTexture , GLI_gs_p_ConvertBufferMipMapping);
nTextureType = KM_TEXTURE_RGB565;
} else
{
GLI_MDRV_vCompressTex4444 ( p_stTexture , GLI_gs_p_ConvertBufferMipMapping);
nTextureType = KM_TEXTURE_ARGB4444;
}
}
p_stTexture-> p_stSpecParam = malloc(sizeof(KMSURFACEDESC));
GLI_fnSwitchTwiddled(GLI_gs_p_ConvertBufferMipMapping , p_stTexture->lHeight );
if (p_stTexture ->lNumberOfLod)
{
GLI_KamuiComputeMipMapping(GLI_gs_p_ConvertBufferMipMapping ,p_stTexture->lHeight , nTextureType);
nTextureType |= KM_TEXTURE_TWIDDLED_MM;
} else
nTextureType |= KM_TEXTURE_TWIDDLED;
if (kmCreateTextureSurface((KMSURFACEDESC * )p_stTexture-> p_stSpecParam,p_stTexture->lHeight,p_stTexture->lWidth,nTextureType) == KMSTATUS_SUCCESS)
{
kmLoadTexture((KMSURFACEDESC * )p_stTexture-> p_stSpecParam,GLI_gs_p_ConvertBufferMipMapping,FALSE,FALSE);
p_stTexture->bIsAvailable = 1;
}
p_stTexture = p_stTexture -> p_NextLodOfTexture;
p_stTexture = NULL;
}
}
}
#endif
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
long GLI_DRV_lGetHardwareTotalTextureMemorySize(long _lTextureMode)
{
return (6388608L);
}
/**********************************************************************************************/
/* Name: GLI_DRV_lGetHardwareMaxTextureSize() 1.0*/
/* OPTIMMIZED : No*/
/**********************************************************************************************/
long GLI_DRV_lGetHardwareMaxTextureSize(void)
{
return (1024);
}
/**********************************************************************************************/
/* Name: GLI_DRV_lIsHardwareAcceptNonSquaredTextures() 1.0*/
/* OPTIMMIZED : No*/
/**********************************************************************************************/
long GLI_DRV_lIsHardwareAcceptNonSquaredTextures(void)
{
return (0);
}
void GLI_DRV_vUnLoadTextures()
{
long lTextureCounter;
GLI_tdstTexture *p_stTexture;
for ( lTextureCounter = 0 ; lTextureCounter < C_lMaxNumberOfTexture ;lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated )
{
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
if (p_stTexture != NULL)
{
if (p_stTexture->bIsAvailable)
{
kmFreeTexture((KMSURFACEDESC * )p_stTexture-> p_stSpecParam);
free (p_stTexture-> p_stSpecParam);
p_stTexture->bIsAvailable = 0;
}
}
}
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@@ -0,0 +1,164 @@
/*
Tested with LINT
*/
#include <KAMUI.H>
#include "init_gli.h"
#include "gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "GLI_interface.h"
KMVERTEXBUFFDESC VertexBufferDesc;
KMSURFACEDESC PrimarySurfaceDesc; /* Primary frame buffer*/
KMSURFACEDESC BackSurfaceDesc; /* Back-buffer frame buffer*/
KMSURFACEDESC stSpecialTexture;
KMSURFACEDESC stSpecialTexture20;
KMSURFACEDESC stSpecialTexture21;
KMVERTEXCONTEXT stRenderingContex;
extern short TEXTURETWIDDLED[];
extern volatile long gsbIsRender;
#define GLI_C_SiSeOFVertexBuffer (512288)
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
#ifdef __cplusplus
extern "C"
{
#endif
void GLI_vEndOfRenderingCallback(void *pnull)
{
gsbIsRender &= 0xFFFFFFFF - 1;
}
void GLI_vEndOfVertexTransfertCallback(void *pnull)
{
gsbIsRender &= 0xFFFFFFFF - 2;
}
void GLI_vWaitEndOfVertexTransfert()
{
while (gsbIsRender & 2) {};
}
void GLI_vWaitEndOfRendering()
{
while (gsbIsRender & 1) {};
}
void GLI_vEndOfVSyncCallback(void *pnull)
{
gsbIsRender &= ~4;
}
void GLI_vWaitEndOfVSync()
{
gsbIsRender |= 4;
while (gsbIsRender & 4) {};
}
/* Global initialisation.*/
void GLI_DRV_xInitDriver( HWND _hWnd, BOOL _bFullScreen, long _lWidth, long _lHeight, long _lBpp )
{
kmInitDevice(KM_VGA);
kmSetDisplayMode( KM_DSPMODE_VGA,KM_DSPBPP_RGB565,FALSE,TRUE);
kmCreateFrameBufferSurface(&PrimarySurfaceDesc,640,480,FALSE,FALSE);
kmCreateFrameBufferSurface(&BackSurfaceDesc,640,480,FALSE,FALSE);
kmCreateVertexBuffer(&VertexBufferDesc, GLI_C_SiSeOFVertexBuffer , 0 , GLI_C_SiSeOFVertexBuffer , 0);
kmActivateFrameBuffer( &PrimarySurfaceDesc,&BackSurfaceDesc,FALSE,TRUE);
kmSetStrideWidth(512);
kmCreateTextureSurface(&stSpecialTexture,512,512, KM_TEXTURE_STRIDE | KM_TEXTURE_RGB565);
#define WATERSIZE 256L
kmCreateTextureSurface(&stSpecialTexture20,WATERSIZE ,WATERSIZE, KM_TEXTURE_TWIDDLED | KM_TEXTURE_ARGB4444);
kmSetEORCallback(GLI_vEndOfRenderingCallback,NULL);
kmSetEndOfVertexCallback(GLI_vEndOfVertexTransfertCallback,NULL);
kmSetVSyncCallback(GLI_vEndOfVSyncCallback,NULL);
memset( &stRenderingContex, 0, sizeof(stRenderingContex));
}
/* Temporary function.*/
/*
long GLI_INTERFACE_FUNC(GLI_DRV_lWhatIsGli)(void)
{
return GLI_C_VersionGlide;
}
*/
void GLI_DRV_vCloseDriver ()
{
}
/* Return version number.*/
/*
long GLI_INTERFACE_FUNC(GLI_lGetNumOfVersion)(void)
{
return 0;//g_stCurLLInterface.iMode;
}
*/
/* Return a pointer on the text version of GLI engine.*/
/*unsigned char *GLI_INTERFACE_FUNC(GLI_ucGetTextOfVersion)(void)
{
return NULL;//g_stCurLLInterface.ucTextMode;
}
*/
/* Erase a rectangular region of Z buffer.*/
void GLI_INTERFACE_FUNC(GLI_DRV_vClearZBufferRegion)(long lXStart,long lXEnd,long lYStart,long lYEnd)
{
/* g_stCurLLInterface.p_fnClearZBufferRegion(lXStart,lXEnd,lYStart,lYEnd);*/
if (!bDrawMirrorSymetric)
GLI_BIG_GLOBALS->lDisplayMenuIsDetected = 1;
}
void GLI_INTERFACE_FUNC(GLI_vBeginDrawingTexturedMirrors)(void)
{
GLI_BIG_GLOBALS->bDrawMirrorSymetric = 1;
}
void GLI_INTERFACE_FUNC(GLI_vBeginDrawingTexturedMirrorsSurfaces)()
{
/*kmSetFramebufferTexture(&TexSurfaceDesc2);*/
GLI_BIG_GLOBALS->lAMirrorIsDetected = 3;
/* GLI_vWaitEndOfRendering();*/
/* GLI_vWaitEndOfVSync();*/
/* kmRenderTexture(&stSpecialTexture);*/
/* GLI_vWaitEndOfRendering();*/
/* GLI_vWaitEndOfVSync();*/
/* kmFlipFrameBuffer();// */
/* GLI_vWaitEndOfRendering();*/
/* Now Draw The reversed World . It will be displayed with Frame later.*/
/* GLI_vWaitEndOfRendering();*/
}
void
GLI_INTERFACE_FUNC(GLI_vEndDrawingTexturedMirrors)()
{
GLI_BIG_GLOBALS->lAMirrorIsDetected &= 1;
GLI_BIG_GLOBALS->bDrawMirrorSymetric = 0;
}
/*extern long GLI_xIsGliInit();*/
void GLI_INTERFACE_FUNC(GLI_DRV_vFlipDevice)(long lNbFrames)
{
if (!GLI_MDRV_xIsGliInit())
return;
GLI_BIG_GLOBALS->lDisplayMenuIsDetected = 0;
GLI_BIG_GLOBALS->lAMirrorIsDetected = 0;
gsbIsRender |= 3;
kmFlipFrameBuffer();/* */
kmRender/*Direct*/();
}
void GLI_INTERFACE_FUNC(GLI_DRV_vClearDevice)(BOOL ZBuffer, BOOL ColorBuffer, unsigned long Color)
{
}
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@@ -0,0 +1,240 @@
# Microsoft Developer Studio Project File - Name="OpenGL" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=OpenGL - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "OpenGL.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "OpenGL.mak" CFG="OpenGL - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "OpenGL - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "OpenGL - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "OpenGL - Win32 Retail" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""$/cpa/tempgrp/GliGlou/Drivers/OpenGL", MVPAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "OpenGL - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "temp\Release"
# PROP Intermediate_Dir "temp\Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /I "t:\mssdk\include" /D "NDEBUG" /D "_WINDOWS" /D "USE_PROFILER" /D "WIN32" /D "GLI_OPENGL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"x:\cpa\exe\main\dll\GliOGLvr.dll"
!ELSEIF "$(CFG)" == "OpenGL - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "temp\Debug"
# PROP Intermediate_Dir "temp\Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /I "t:\mssdk\include" /D "_DEBUG" /D "VISUAL" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /D "WIN32" /D "GLI_OPENGL" /U "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /U "x:\cpa\public" /U "x:\cpa\public\gli" /U "x:\cpa\public\geo" /U "inc" /U "x:\cpa\tempgrp\gliglou\multidrv\inc" /U "..\\" /U "t:\mssdk\include" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"x:\cpa\exe\main\dll\GliOGLvd.dll" /pdbtype:sept
!ELSEIF "$(CFG)" == "OpenGL - Win32 Retail"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "temp\retail"
# PROP BASE Intermediate_Dir "temp\retail"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Temp\Retail"
# PROP Intermediate_Dir "Temp\Retail"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /D "NDEBUG" /D "_WINDOWS" /D "RETAIL" /D "WIN32" /D "GLI_OPENGL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"x:\cpa\exe\main\dll\GliOGLvf.dll"
!ENDIF
# Begin Target
# Name "OpenGL - Win32 Release"
# Name "OpenGL - Win32 Debug"
# Name "OpenGL - Win32 Retail"
# Begin Group "Src"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Acces_ALL.c
!IF "$(CFG)" == "OpenGL - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "OpenGL - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "OpenGL - Win32 Retail"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\ClipTRIANGLES.c
# End Source File
# Begin Source File
SOURCE=..\DllCom.c
# End Source File
# Begin Source File
SOURCE=..\GliDLL.def
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Acces.c
!IF "$(CFG)" == "OpenGL - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "OpenGL - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "OpenGL - Win32 Retail"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Dll.c
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Domat.c
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Errors.c
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Func.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_HdwTx.c
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Init.c
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Lock.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Thread.c
# End Source File
# End Group
# Begin Group "inc"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\DllCom.h
# End Source File
# Begin Source File
SOURCE=.\Inc\OGL_Errors.h
# End Source File
# Begin Source File
SOURCE=.\Inc\OGL_Options.h
# End Source File
# Begin Source File
SOURCE=.\Inc\OGL_Thread.h
# End Source File
# End Group
# Begin Group "lib"
# PROP Default_Filter ""
# Begin Source File
SOURCE=T:\dxsdk\sdk\lib\ddraw.lib
# End Source File
# End Group
# Begin Source File
SOURCE=.\OpenGL.mak
# End Source File
# End Target
# End Project

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,446 @@
//#include <d3d.h>
#include <windows.h>
#include <gl/gl.h>
#include "PRF.h"
#include "OGL_Options.h"
#include "OGL_Errors.h"
#include "OGL_Thread.h"
/*
=======================================================================================
Globals
=======================================================================================
*/
void GLI_DRV_xSendSpriteToClip_TRIANGLES( GLI_tdstAligned2DVector *a4_st2DVertex, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
GLI_tdScreenVertx ga_stVertexBuffer[ 3000 ];
GLI_tdScreenVertx *CurrentDestXYZ = ga_stVertexBuffer;
#define GLI_M_RestoreCW()
void GLI_BeforeDraw()
{
CurrentDestXYZ = ga_stVertexBuffer;
OGLThread_fn_vWaitForSynchro();
}
void GLI_AfterDraw()
{
//OGLThread_fn_vWaitForSynchro();
if (CurrentDestXYZ != ga_stVertexBuffer)
OGLThread_fn_vPostCmd_1Long(OGLT1_RENDER, (long)CurrentDestXYZ);
//OGLThread_fn_vWaitForSynchro();
}
GLI_FuncNodeBegin(GLI_vDrawTriangle)
{
CurrentDestXYZ += 3;
}
GLI_FuncNodeBegin(GLI_vDrawWiredTriangle)
{
}
GLI_FuncNodeBegin(GLI_vZSortTriangle)
{
/* draw */
float ZMax;
if ((unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint > (unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_TableOfPoints + ((3L << GLI_MaxZListeTrianglesPO2)* sizeof (GLI_tdScreenVertx)) - 3L * sizeof(GLI_tdScreenVertx))
return;
/* 3DFX BUG */
memcpy(GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint , CurrentDestXYZ , sizeof(GLI_tdScreenVertx) * 3L);
if (*(unsigned long *)&GetZ(CurrentDestXYZ[0]) < *(unsigned long *)&GetZ(CurrentDestXYZ[1]))
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[0]);
else
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[1]);
if (*(unsigned long *)&ZMax > *(unsigned long *)&GetZ(CurrentDestXYZ[2]))
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[2]);
GLI_v_AddNodeInZList(ZMax);
(unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint += sizeof(GLI_tdScreenVertx) * 3L;
}
/*
----------------------------------------------------------------------------------------
Description : draw a quad stored in CurrentDestXYZ array or add it in Z list
1-----0
| /| Send two triangle : 0 1 2 and 3 2 0
| / |
|/ |
2-----3
----------------------------------------------------------------------------------------
*/
void GLI_DrawQuad(void)
{
/* draw 2 triangles */
if ( GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_TrianglesMustBeSorted )
{
GLI_BIG_GLOBALS -> lCurrentDrawMask &= ~GLI_C_lIsGouraud;
if ((unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint > (unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_TableOfPoints + ((3L << GLI_MaxZListeTrianglesPO2)* sizeof (GLI_tdScreenVertx)) - 4L * sizeof(GLI_tdScreenVertx))
return;
memcpy(GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint , CurrentDestXYZ , sizeof(GLI_tdScreenVertx) * 4L);
GLI_v_AddNodeInZList(GetZ(CurrentDestXYZ[0]));
(unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint += sizeof(GLI_tdScreenVertx) * 4L;
}
else
{
CurrentDestXYZ[4] = CurrentDestXYZ[0];
CurrentDestXYZ[5] = CurrentDestXYZ[2];
CurrentDestXYZ += 6;
}
}
/*
----------------------------------------------------------------------------------------
Description : Draw a line
----------------------------------------------------------------------------------------
*/
void GLI_DrawLine(void)
{
}
/*
----------------------------------------------------------------------------------------
Description : draw Zsorted triangle
----------------------------------------------------------------------------------------
*/
void GLI_vDrawZSortedTriangle(void *p_3Point)
{
memcpy( CurrentDestXYZ, p_3Point, 3 * sizeof(GLI_tdScreenVertx) );
CurrentDestXYZ += 3;
}
/*
----------------------------------------------------------------------------------------
Description : draw ZSorted quad
----------------------------------------------------------------------------------------
*/
void GLI_vDrawZSortedQuad(void *p_3Point)
{
memcpy( CurrentDestXYZ, p_3Point, 4 * sizeof(GLI_tdScreenVertx) );
CurrentDestXYZ[4] = *((GLI_tdScreenVertx *) p_3Point + 2);
CurrentDestXYZ[5] = *((GLI_tdScreenVertx *) p_3Point);
CurrentDestXYZ += 6;
}
/*
----------------------------------------------------------------------------------------
Description : choose good drawing function
----------------------------------------------------------------------------------------
*/
void GLI_vAddDrawFunc()
{
if (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_TrianglesMustBeSorted)
GLI_M_AddFunc(GLI_vZSortTriangle);
// else if ( (GLI_BIG_GLOBALS->lCurrentDrawMask & GLI_C_lIsNotWired) == 0 )
// GLI_M_AddFunc(GLI_vDrawWiredTriangle);
else
GLI_M_AddFunc(GLI_vDrawTriangle);
}
/*
----------------------------------------------------------------------------------------
Description : compute clipping mask
----------------------------------------------------------------------------------------
*/
void GLI_ReComputeClippingMask()
{
*(float *)&fX_CMP_Optimize = GLI_BIG_GLOBALS->fXMaxClipping;
*(float *)&fY_CMP_Optimize = GLI_BIG_GLOBALS->fYMaxClipping;
*(float *)&fXMin_CLIP_Optimize = GLI_BIG_GLOBALS->fXMinClipping;
*(float *)&fYMin_CLIP_Optimize = GLI_BIG_GLOBALS->fYMinClipping;
*(float *)&fXMax_CLIP_Optimize = GLI_BIG_GLOBALS->fXMaxClipping; // - 1.0f;
*(float *)&fYMax_CLIP_Optimize = GLI_BIG_GLOBALS->fYMaxClipping; // - 1.0f;
GLI_BIG_GLOBALS -> lClippingModeMask |= (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_lCLIP_ALL) << 4;
}
/*
----------------------------------------------------------------------------------------
Description : clip a sprite
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vSendSpriteToClip
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT
)
{
float fClipYMax, fClipYMin, fClipXMax, fClipXMin;
GLI_BeforeDraw();
if (a4_st2DVertex[0].xY == a4_st2DVertex[1].xY) /* Aligned sprite */
{
GLI_ReComputeClippingMask();
if ( ( *(long *) &a4_st2DVertex[0].xY > fYMax_CLIP_Optimize) || (*(long *) &a4_st2DVertex[2].xY < fYMin_CLIP_Optimize) || (*(long *) &a4_st2DVertex[0].xX < fXMin_CLIP_Optimize) || (*(long *) &a4_st2DVertex[1].xX > fXMax_CLIP_Optimize) )
return;
/*
* clip xMax
*/
if ( *(long *) &a4_st2DVertex[0].xX > fXMax_CLIP_Optimize )
{
fClipXMax = (GLI_BIG_GLOBALS->fXMaxClipping - a4_st2DVertex[1].xX) / ( a4_st2DVertex[0].xX - a4_st2DVertex[1].xX );
a4_st2DVertex[0].xX = a4_st2DVertex[3].xX = GLI_BIG_GLOBALS->fXMaxClipping;
}
else
fClipXMax = 1.0f;
/*
* clip xMin
*/
if ( *(long *) &a4_st2DVertex[1].xX < fXMin_CLIP_Optimize )
{
fClipXMin = (fClipXMax * ( GLI_BIG_GLOBALS->fXMinClipping - a4_st2DVertex[1].xX) ) / ( a4_st2DVertex[0].xX - a4_st2DVertex[1].xX );
a4_st2DVertex[1].xX = a4_st2DVertex[2].xX = GLI_BIG_GLOBALS->fXMinClipping;
}
else
fClipXMin = 0.0f;
/*
* clip yMin
*/
if ( *(long *) &a4_st2DVertex[0].xY < fYMin_CLIP_Optimize )
{
fClipYMin = (GLI_BIG_GLOBALS->fYMinClipping - a4_st2DVertex[2].xY) / ( a4_st2DVertex[0].xY - a4_st2DVertex[2].xY );
a4_st2DVertex[0].xY = a4_st2DVertex[1].xY = GLI_BIG_GLOBALS->fYMinClipping;
}
else
fClipYMin = 1.0f;
/*
* clip yMax
*/
if ( *(long *) &a4_st2DVertex[2].xY > fYMax_CLIP_Optimize )
{
fClipYMax = (fClipYMin * ( GLI_BIG_GLOBALS->fYMaxClipping - a4_st2DVertex[2].xY ) ) / ( a4_st2DVertex[0].xY - a4_st2DVertex[2].xY );
a4_st2DVertex[2].xY = a4_st2DVertex[3].xY = GLI_BIG_GLOBALS->fYMaxClipping;
}
else
fClipYMax = 0.0f;
}
else
{
if ( *(long *) &GLI_BIG_GLOBALS->xWaterPlaneDistance != 0 );
{
GLI_DRV_xSendSpriteToClip_TRIANGLES( a4_st2DVertex, p_stGlobaleMT);
return;
}
if ( (a4_st2DVertex [0] . xY < 0.0f) || (a4_st2DVertex [1] . xY < 0.0f) || (a4_st2DVertex [2] . xY < 0.0f) || (a4_st2DVertex [3] . xY < 0.0f) ) return;
if ( (a4_st2DVertex [0] . xX < 0.0f) || (a4_st2DVertex [1] . xX < 0.0f) || (a4_st2DVertex [2] . xX < 0.0f) || (a4_st2DVertex [3] . xX < 0.0f) ) return;
if ( (a4_st2DVertex [0] . xY > 480.0f) || (a4_st2DVertex [1] . xY > 480.0f) || (a4_st2DVertex [2] . xY > 480.0f) || (a4_st2DVertex [3] . xY > 480.0f) ) return;
if ( (a4_st2DVertex [0] . xX > 640.0f) || (a4_st2DVertex [1] . xX > 640.0f) || (a4_st2DVertex [2] . xX > 640.0f) || (a4_st2DVertex [3] . xX > 640.0f) ) return;
fClipXMin = fClipYMax = 0.0f;
fClipYMin = fClipXMax = 1.0f;
}
GLI_M_InitSprite();
SetU(CurrentDestXYZ[0], fClipXMax );
SetV(CurrentDestXYZ[0], fClipYMin );
SetU(CurrentDestXYZ[1], fClipXMin );
SetV(CurrentDestXYZ[1], fClipYMin );
SetU(CurrentDestXYZ[2], fClipXMin );
SetV(CurrentDestXYZ[2], fClipYMax );
SetU(CurrentDestXYZ[3], fClipXMax );
SetV(CurrentDestXYZ[3], fClipYMax );
GLI_DrawQuad();
GLI_AfterDraw();
}
/*
----------------------------------------------------------------------------------------
Description : clip a sprite that have UV coordinates (it seems to be unused)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vSendSpriteToClipWithUV
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal *a8_stUVVertex,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_BeforeDraw();
GLI_M_InitSprite();
if (a4_st2DVertex [0] . xY < 0.0f) return;
if (a4_st2DVertex [1] . xY < 0.0f) return;
if (a4_st2DVertex [2] . xY < 0.0f) return;
if (a4_st2DVertex [3] . xY < 0.0f) return;
if (a4_st2DVertex [0] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [1] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [2] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [3] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if ( p_stGlobaleMT->p_stCurrentTexture->lIncrementIsEnable )
{
float fAddU, fAddV;
fAddU = p_stGlobaleMT-> p_stCurrentTexture -> fAddU;
fAddV = p_stGlobaleMT-> p_stCurrentTexture -> fAddV;
SetU(CurrentDestXYZ[2], a8_stUVVertex[4] + fAddU );
SetV(CurrentDestXYZ[2], a8_stUVVertex[4 + 1] + fAddV);
SetU(CurrentDestXYZ[3], a8_stUVVertex[6] + fAddU);
SetV(CurrentDestXYZ[3], a8_stUVVertex[6 + 1] + fAddV);
SetU(CurrentDestXYZ[0], a8_stUVVertex[0] + fAddU);
SetV(CurrentDestXYZ[0], a8_stUVVertex[0 + 1] + fAddV);
SetU(CurrentDestXYZ[1], a8_stUVVertex[2] + fAddU);
SetV(CurrentDestXYZ[1], a8_stUVVertex[2 + 1] + fAddV);
}
else
{
SetU(CurrentDestXYZ[2], a8_stUVVertex[4]);
SetV(CurrentDestXYZ[2], a8_stUVVertex[4 + 1]);
SetU(CurrentDestXYZ[3], a8_stUVVertex[6]);
SetV(CurrentDestXYZ[3], a8_stUVVertex[6 + 1]);
SetU(CurrentDestXYZ[0], a8_stUVVertex[0]);
SetV(CurrentDestXYZ[0], a8_stUVVertex[0 + 1]);
SetU(CurrentDestXYZ[1], a8_stUVVertex[2]);
SetV(CurrentDestXYZ[1], a8_stUVVertex[2 + 1]);
}
GLI_DrawQuad();
GLI_AfterDraw();
}
/*
----------------------------------------------------------------------------------------
Description : clip a line (not implemented)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vSendSingleLineToClip
(
GLD_tdstViewportAttributes *p_stVpt ,
GLI_tdstAligned3DVector *p_stVertex1 ,
GLI_tdstAligned2DVector *p_st2DVertex1 ,
GLI_tdstAligned3DVector *p_stVertex2 ,
GLI_tdstAligned2DVector *p_st2DVertex2 ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT,
long lDrawModeMask, GEO_tdstColor *p_stColor
)
{
#ifdef _DEBUG
/*
GLI_tdstAligned2DVector *p_stP1, *p_stP2;
GLI_tdstAligned3DVector *p_st3DP1, *p_st3DP2;
*/
GLI_tdstAligned2DVector stP1, stP2;
GLI_tdstAligned3DVector st3DP1, st3DP2;
float fFactor;
p_st2DVertex1->ulPackedColor = 0xFFFFFFFF;
p_st2DVertex2->ulPackedColor = 0xFFFFFFFF;
/* xClipping */
if (p_st2DVertex1->xX < p_st2DVertex2->xX)
{
stP1 = *p_st2DVertex1;
st3DP1 = *p_stVertex1;
stP2 = *p_st2DVertex2;
st3DP2 = *p_stVertex2;
}
else
{
stP1 = *p_st2DVertex2;
st3DP1 = *p_stVertex2;
stP2 = *p_st2DVertex1;
st3DP2 = *p_stVertex1;
}
if (( stP2.xX < 0.0f) || ( stP1.xX > 640.0f ) )
return;
if ( stP1.xX < 0.0f )
{
fFactor = stP2.xX / (stP2.xX - stP1.xX );
stP1.xY = stP2.xY - ( stP2.xY - stP1.xY) * fFactor;
//(*p_stP1)->ulPackedColor = (unsigned long) ((*p_stP2)->ulPackedColor - ( (*p_stP2)->ulPackedColor - (*p_stP1)->ulPackedColor) * fFactor);
st3DP1.xZ = st3DP2.xZ - ( st3DP2.xY - st3DP1.xY) * fFactor;
stP1.xX = 0.0f;
}
if ( stP2.xX > 640.0f)
{
fFactor = (stP1.xX - 640.0f) / (stP2.xX - stP1.xX );
stP2.xY = stP1.xY - ( stP2.xY - stP1.xY) * fFactor;
//(*p_stP2)->ulPackedColor = (unsigned long) ((*p_stP1)->ulPackedColor - ( (*p_stP2)->ulPackedColor - (*p_stP1)->ulPackedColor) * fFactor);
st3DP2.xZ = st3DP1.xZ - ( st3DP2.xY - st3DP1.xY) * fFactor;
stP2.xX = 640.0f;
}
/* yClipping */
if ( stP1.xY < stP2.xY)
{
p_st2DVertex1 = &stP1;
p_stVertex1 = &st3DP1;
p_st2DVertex2 = &stP2;
p_stVertex2 = &st3DP2;
}
else
{
p_st2DVertex1 = &stP2;
p_stVertex1 = &st3DP2;
p_st2DVertex2 = &stP1;
p_stVertex2 = &st3DP1;
}
if (( p_st2DVertex2->xY < 0.0f) || ( p_st2DVertex1->xY > 480.0f ) )
return;
if ( p_st2DVertex1->xY < 0.0f )
{
fFactor = p_st2DVertex2->xY / (p_st2DVertex2->xY - p_st2DVertex1->xY );
p_st2DVertex1->xX = p_st2DVertex2->xX - ( p_st2DVertex2->xX - p_st2DVertex1->xX) * fFactor;
//(*p_st2DVertex1)->ulPackedColor = (unsigned long) ((*p_st2DVertex2)->ulPackedColor - ( (*p_st2DVertex2)->ulPackedColor - (*p_st2DVertex1)->ulPackedColor) * fFactor);
p_stVertex1->xZ = p_stVertex2->xZ - ( p_stVertex2->xZ - p_stVertex1->xZ) * fFactor;
p_st2DVertex1->xY = 0.0f;
}
if ( p_st2DVertex2->xY > 480.0f)
{
//fFactor = ( (*p_st2DVertex2)->xX - (*p_st2DVertex1)->xX) / ((*p_st2DVertex2)->xY - (*p_st2DVertex1)->xY );
fFactor = (p_st2DVertex1->xY - 480.0f) / (p_st2DVertex2->xY - p_st2DVertex1->xY );
p_st2DVertex2->xX = p_st2DVertex1->xX - ( p_st2DVertex2->xX - p_st2DVertex1->xX) * fFactor;
//(*p_st2DVertex2)->ulPackedColor = (unsigned long) ((*p_st2DVertex1)->ulPackedColor - ( (*p_st2DVertex2)->ulPackedColor - (*p_st2DVertex1)->ulPackedColor) * fFactor);
p_stVertex2->xZ = p_stVertex1->xZ - ( p_stVertex2->xZ - p_stVertex1->xZ) * fFactor;
p_st2DVertex2->xY = 480.0f;
}
#else
if (p_st2DVertex1->xX < 0) return;
if (p_st2DVertex1->xY < 0) return;
if (p_st2DVertex1->xX > 640.0f) return;
if (p_st2DVertex1->xY > 480.0f) return;
if (p_st2DVertex2->xX < 0) return;
if (p_st2DVertex2->xY < 0) return;
if (p_st2DVertex2->xX > 640.0f) return;
if (p_st2DVertex2->xY > 480.0f) return;
#endif
GLI_M_InitLine();
GLI_BeforeDraw();
GLI_DrawLine();
GLI_AfterDraw();
}

View File

@@ -0,0 +1,27 @@
/*
=======================================================================================
Name : Glide2_Dll.c
Author : vincent lhullier Date :16/09/98
Description : specific DLL fonction
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "init_gli.h"
#include "DLLCom.h"
#include "DLLCaps.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tdstGliDriverIdentity stGlide2Id =
{
"OpenGL",
"Driver for OpenGL",
"1.0.0",
10
};
void fn_vInitDllIdentity( void )
{
memcpy( &g_stGliDrvId, &stGlide2Id, sizeof( tdstGliDriverIdentity ) );
}

View File

@@ -0,0 +1,793 @@
/******************************************************************************************
FILE : DoMat Glide2
Do render parameters settings for texture/material/fog
Dispay black triangles for window smaller than screen
*******************************************************************************************/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "Gli_st.h"
#include "GLI_Defn.h"
#include "polygon.h"
#include "mater_st.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "Liste.h"
#include "watrplan.h"
#include "proj.h"
#include "vpt3D.h"
#include "camera.h"
#include "material.h"
#include "texture.h"
#include "TEX.h"
#include "light.h"
#include "GliBench.h"
#include "DLLCom.h"
#include "PRF.h"
#include <gl/gl.h>
#include "OGL_Options.h"
#include "OGL_Errors.h"
#include "OGL_Thread.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Globals
=======================================================================================
*/
/*typedef struct _GLI_tdScreenVertx {
float sx;
float sy;
float sz;
//float rhw;
unsigned long color;
unsigned long specular;
float tu;
float tv;
} GLI_tdScreenVertx;
*/
/*
* render parameters
*/
static long bIsWriteEnable = 1;
static ACP_tdxIndex xSaveFogIsOn = 0;
static unsigned char ucSaveCyclingMode = -1;
static unsigned char ucSaveFunction = -1;
static unsigned long gs_ulDepthBufferTestEnabled = 0;
/*
* Fog table
*/
//GrFog_t Gli_C_xFogTable[ GR_FOG_TABLE_SIZE ];
//float GLI_ga_fFogDist[ GR_FOG_TABLE_SIZE ];
/*
* Black triangles
*/
GLI_tdScreenVertx g_stBlackTriangle[16];
long g_lNumberOfBlackTriangles = 0;
/*
* external
*/
//extern long g_lDestWidth, g_lDestHeight;
/*
=======================================================================================
Special function for displaying black polygon
it's for cinematic scene to hide non black for color
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : reinit list of black triangles
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vNoBlackPolygon()
{
g_lNumberOfBlackTriangles = 0;
}
/*
----------------------------------------------------------------------------------------
Description : Add a black triangles to list
Assume that list is large enough (no test)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vAddBlackPolygon( long _lLeft, long _lTop, long _lRight, long _lBottom )
{
GLI_tdScreenVertx *p_stVertex;
p_stVertex = g_stBlackTriangle + g_lNumberOfBlackTriangles;
memset( p_stVertex, 0, 4 * sizeof( GLI_tdScreenVertx ) );
g_lNumberOfBlackTriangles += 4;
p_stVertex->sx = (float) _lLeft;
p_stVertex->sy = (float) _lBottom;
p_stVertex->sz = .8f;
p_stVertex++;
p_stVertex->sx = (float) _lLeft;
p_stVertex->sy = (float) _lTop;
p_stVertex->sz = .8f;
p_stVertex++;
p_stVertex->sx = (float) _lRight;
p_stVertex->sy = (float) _lTop;
p_stVertex->sz = .8f;
p_stVertex++;
p_stVertex->sx = (float) _lRight;
p_stVertex->sy = (float) _lBottom;
p_stVertex->sz = .8f;
}
/*
----------------------------------------------------------------------------------------
Description : Draw black triangles
----------------------------------------------------------------------------------------
*/
void GLI_vSendBlackPolygon()
{
if (g_lNumberOfBlackTriangles == 0)
return;
xSaveFogIsOn = 0;
OGLThread_fn_vPostCmd(OGLT0_BLACKPOLY);
}
/*
=======================================================================================
Function for Fog
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Set render parameter for given fog parameters
----------------------------------------------------------------------------------------
*/
tdstFogParams* g_p_stFogParams;
void GLI_vSetFogParams( tdstFogParams *_p_stFogParams )
{
g_p_stFogParams = _p_stFogParams;
OGLThread_fn_vPostCmd(OGLT0_FOGPARAM);
}
/*
----------------------------------------------------------------------------------------
Description : compute fog effect on vertex color (nothing to do for Glide2)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vComputeFogEffect(GLI_tdstInternalGlobalValuesFor3dEngine *p_stBG )
{
}
/*
=======================================================================================
ZBuffer function
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : To enable write to ZBuffer
----------------------------------------------------------------------------------------
*/
static void GLI_fn_vEnableWriteToZBuffer()
{
if (bIsWriteEnable)
return;
OGLThread_fn_vPostCmd_1Long(OGLT1_DEPTHMASK, (long)GL_TRUE);
bIsWriteEnable = 1;
}
/*
----------------------------------------------------------------------------------------
Description : To disable write to ZBuffer
----------------------------------------------------------------------------------------
*/
static void GLI_fn_vDisableWriteToZBuffer()
{
if (!bIsWriteEnable)
return;
OGLThread_fn_vPostCmd_1Long(OGLT1_DEPTHMASK, (long)GL_FALSE);
bIsWriteEnable = 0;
}
/*
----------------------------------------------------------------------------------------
Description : To manage use of ZBuffer
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vEnableDepthTest()
{
if( gs_ulDepthBufferTestEnabled )
return;
OGLThread_fn_vPostCmd_1Long( OGLT1_ENABLE, GL_DEPTH_TEST);
gs_ulDepthBufferTestEnabled = 1;
}
void GLI_DRV_vDisableDepthTest()
{
if( ! gs_ulDepthBufferTestEnabled )
return;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_DEPTH_TEST);
gs_ulDepthBufferTestEnabled = 0;
}
/*
=======================================================================================
Main render parameter setting functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Macro to set chromakey
CB : La valeur de chromakey doit etre <20>gale <20> : 5 bits de poids fort, plus les 3 bits de poids fort copi<70>s dans les bits de poids faible.... !!!
VL : sauf pour la composante G : 6 bit de poids fort + 2 bit de poids fort copi<70>s dans les bits de poids faible !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
----------------------------------------------------------------------------------------
*/
#define M_vChromakey()\
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lNZTexture)\
{\
unsigned long ulChromakey;\
grChromakeyMode( GR_CHROMAKEY_ENABLE );\
ulChromakey = (p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x00F800F8) | ((p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x00E000E0) >> 5);\
ulChromakey|= (p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x0000FC00) | ((p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x0000C000) >> 6);\
grChromakeyValue( ulChromakey );\
}\
else\
{\
grChromakeyMode( GR_CHROMAKEY_DISABLE );\
}
/*
----------------------------------------------------------------------------------------
Description : Macro to change fog rendering
----------------------------------------------------------------------------------------
*/
#define M_vFog()\
if (GLI_BIG_GLOBALS->xFogIsOn)\
{\
if ( GLI_BIG_GLOBALS->p_stLastComputedFog != GLI_BIG_GLOBALS->p_stActiveFog )\
{\
GLI_vSetFogParams( GLI_BIG_GLOBALS->p_stActiveFog );\
GLI_BIG_GLOBALS->p_stLastComputedFog = GLI_BIG_GLOBALS->p_stActiveFog;\
}\
if (!xSaveFogIsOn)\
{\
OGLThread_fn_vPostCmd_1Long( OGLT1_ENABLE, GL_FOG); /*grFogMode( GR_FOG_WITH_TABLE);*/\
xSaveFogIsOn = 1;\
}\
}\
else if (xSaveFogIsOn)\
{\
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_FOG); /*grFogMode( GR_FOG_DISABLE);*/\
xSaveFogIsOn = 0;\
}
/*
----------------------------------------------------------------------------------------
Description : Set init parameter as none set
----------------------------------------------------------------------------------------
*/
void GLI_fn_vInitRenderParameters( void )
{
bIsWriteEnable = 1;
xSaveFogIsOn = 0;
// xSaveTmuNumber = -1;
ucSaveCyclingMode = -1;
ucSaveFunction = -1;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_FOG);
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters that will work for all faces which are not
transparent
----------------------------------------------------------------------------------------
*/
void GLI_fn_vSetRenderParametersBeforeOpaqueFace( void ) {
//grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
//grAlphaTestFunction( GR_CMP_ALWAYS );
//grAlphaTestReferenceValue( 0xC0 );
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_ONE, GL_ZERO); //grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE); // guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
ucSaveFunction = 4;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST); // ?
GLI_fn_vEnableWriteToZBuffer();
}
/*
----------------------------------------------------------------------------------------
Description : called before the rendering of any triangle
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bBeginScene()
{
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : called after the rendering of all triangles
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bEndScene()
{
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : Called for all object before drawn.
Set some general parameters and set render parameter for opaque texture only
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vDoOpaqueTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLboolean bOK;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// GLI_tdstTextureDFX *p_stSpecParam;
BOOL bTexture;
#if defined (TEX_TEST)
BOOL bTempOk;
unsigned int uiTextureId;
#endif //defined (TEX_TEST)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (*GLD_p_lRenderingCounter != p_stGlobaleMT->GLD_RenderingCounter)
{
p_stGlobaleMT->GLD_RenderingCounter = *GLD_p_lRenderingCounter;
GLI_vSendBlackPolygon();
// GLI_fn_vSetRenderParametersBeforeOpaqueFace() :
/*
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
grAlphaTestFunction( GR_CMP_ALWAYS );
grAlphaTestReferenceValue( 0xC0 );
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_ONE, GL_ZERO);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE);
ucSaveFunction = 4;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
GLI_fn_vEnableWriteToZBuffer();
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
GLI_DRV_vEnableDepthTest();
else
GLI_DRV_vDisableDepthTest();
bTexture = (p_stGlobaleMT->p_stCurrentTexture != NULL) && (p_stGlobaleMT->p_stCurrentTexture->bIsAvailable);
/*
* test if triangle will be transparent if so do not set render parameters
*/
if (GLI_BIG_GLOBALS->lAMirrorIsDetected)
GLI_BIG_GLOBALS->lAMirrorIsDetected = 3;
if (
( !(GLI_BIG_GLOBALS->lAMirrorIsDetected) && bTexture && (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTexture | GLI_C_lNZFilteredTexture | GLI_C_lAddTransparencyTexture) ) )
|| (!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))
)
{
p_stGlobaleMT -> lClippingModeMask |= GLI_C_TrianglesMustBeSorted;
return;
}
p_stGlobaleMT -> lClippingModeMask &= 0xffffffff - GLI_C_TrianglesMustBeSorted;
/*
* fog
*/
#if !defined(NO_FOG)
M_vFog();
#endif
#ifdef TEX_TEST
if (bTexture) {
uiTextureId = (unsigned int) p_stGlobaleMT->p_stCurrentTexture->p_stSpecParam;
bTempOk = OGLThread_fn_bPostCmdAndWait(OGLT1_ISTEXTURE, (long)uiTextureId);
if (!bTempOk )
bTexture = FALSE;
if (bTexture) {
bTempOk = OGLThread_fn_bPostCmdAndWait(OGLT1_ISRESIDENT, (long)uiTextureId);
if (!bTempOk)
bTexture = FALSE;
}
// if not resident => delete it
if (!bTexture) {
bTempOk = OGLThread_fn_bPostCmdAndWait(OGLT1_ISTEXTURE, (long)uiTextureId);
if (bTempOk)
OGLThread_fn_vPostCmd_1Long(OGLT1_DELETETEXTURE, (long)uiTextureId);
}
}
#endif //defined (TEX_TEST)
if ( bTexture )
{
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAlphaTest)
{
if (ucSaveFunction != 5)
{
if ( ucSaveFunction == 2 )
GLI_fn_vSetRenderParametersBeforeOpaqueFace() ;
/*
grAlphaTestFunction( GR_CMP_GEQUAL );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
*/
OGLThread_fn_vPostCmd( OGLT0_ALPHATEST );
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE);
ucSaveFunction = 5;
OGLThread_fn_vPostCmd_1Long( OGLT1_ENABLE, GL_ALPHA_TEST);
}
}
else if (GLI_BIG_GLOBALS->lAMirrorIsDetected & 2)
{
/*
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE ,GR_BLEND_ZERO );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE);
ucSaveFunction = 2;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
else
{
if (ucSaveFunction != 4)
{
if ( ucSaveFunction == 2 )
GLI_fn_vSetRenderParametersBeforeOpaqueFace() ;
/*
grAlphaTestFunction( GR_CMP_ALWAYS );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
*/
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE);
ucSaveFunction = 4;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
}
/*
* Chromakey
*/
/* M_vChromakey();*/
/*
* uv cycling mode => made when loading texture
*/
/*if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lNZTexture)
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_TEXTURE_2D);
else*/
{
OGLThread_fn_vPostCmd_1Long( OGLT1_ENABLE, GL_TEXTURE_2D);
OGLThread_fn_vPostCmd_1Long( OGLT1_BINDTEXTURE, (long)p_stGlobaleMT->p_stCurrentTexture->p_stSpecParam );
}
}
else /* gouraud */
{
bOK = OGLThread_fn_bPostCmdAndWait(OGLT1_ISENABLED, GL_TEXTURE_2D);
if (bOK)
{
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_TEXTURE_2D);
bOK = OGLThread_fn_bPostCmdAndWait(OGLT1_ISENABLED, GL_TEXTURE_2D);
}
if (bOK) // still Enabled !
OGLThread_fn_vPostCmd_1Long( OGLT1_BINDTEXTURE, 0L );
if (ucSaveFunction != 0)
{
/*
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
grAlphaTestFunction( GR_CMP_ALWAYS );
guColorCombineFunction( GR_COLORCOMBINE_ITRGB );
ucSaveFunction = 0;
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_ONE, GL_ZERO);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE);
ucSaveFunction = 0;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
}
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters that will work for all transparency faces
----------------------------------------------------------------------------------------
*/
void GLI_fn_vSetRenderParametersBeforeTransparencyFace( void )
{
// grAlphaTestFunction( GR_CMP_ALWAYS );
GLI_fn_vDisableWriteToZBuffer();
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters for transparent triangles
----------------------------------------------------------------------------------------
*/
void GLI_vDoTransparentTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
BOOL bTexture;
#ifdef TEX_TEST
BOOL bTempOk;
unsigned int uiTextureId;
#endif //defined (TEX_TEST)
//grAlphaTestFunction( GR_CMP_ALWAYS );
/*
* write to Z buffer ?
*/
/*
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsWriteZBuffer)
GLI_fn_vEnableWriteToZBuffer();
else
GLI_fn_vDisableWriteToZBuffer();
*/
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
GLI_DRV_vEnableDepthTest();
else
GLI_DRV_vDisableDepthTest();
/*
* fog
*/
#if !defined(NO_FOG)
M_vFog();
#endif
bTexture = (p_stGlobaleMT -> p_stCurrentTexture != NULL) && (p_stGlobaleMT -> p_stCurrentTexture -> bIsAvailable);
#ifdef TEX_TEST
if (bTexture) {
uiTextureId = (unsigned int) p_stGlobaleMT->p_stCurrentTexture->p_stSpecParam;
bTempOk = bOGLThread_fn_vPostCmd_WaitForBoolean(OGLT1_ISTEXTURE, (long)uiTextureId);
if (!bTempOk )
bTexture = FALSE;
if (bTexture) {
bTempOk = bOGLThread_fn_vPostCmd_WaitForBoolean(OGLT1_ISRESIDENT, (long)uiTextureId);
if (!bTempOk)
bTexture = FALSE;
}
// if not resident => delete it
if (!bTexture) {
bTempOk = bOGLThread_fn_vPostCmd_WaitForBoolean(OGLT1_ISTEXTURE, (long)uiTextureId);
if (bTempOk)
OGLThread_fn_vPostCmd_1Long(OGLT1_DELETETEXTURE, (long)uiTextureId);
}
}
#endif //defined (TEX_TEST)
if (bTexture) //((p_stGlobaleMT -> p_stCurrentTexture != NULL) && (p_stGlobaleMT -> p_stCurrentTexture -> bIsAvailable))
{
//glEnable(GL_TEXTURE_2D);
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTest | GLI_C_lAlphaTexture | GLI_C_lNZFilteredTexture | GLI_C_lAddTransparencyTexture) )
{
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAddTransparencyTexture)
{
// Trans ADD
if (ucSaveFunction != 1)
{
/*
grAlphaBlendFunction( GR_BLEND_ONE,GR_BLEND_ONE,GR_BLEND_ZERO ,GR_BLEND_ZERO );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA);
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_ONE, GL_ONE);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_DECAL); // guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA);
ucSaveFunction = 1;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
// No fog With This;
if (xSaveFogIsOn)
{
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_FOG); //grFogMode( GR_FOG_DISABLE);
xSaveFogIsOn = 0;
}
}
else if (ucSaveFunction != 2)
{
// Trans ALPHA
/*
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE ,GR_BLEND_ZERO );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE); // guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
ucSaveFunction = 2;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
}
else //if ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (xGlobaLAlpha < 0.98f))
{
// Trans ALPHA ITERATED
if (ucSaveFunction != 3)
{
/*
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE,GR_BLEND_ZERO );
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE); // guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
ucSaveFunction = 3;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
}
/*
* Chromakey
*/
/* M_vChromakey();*/
/*
* uv cycling mode => made when loading texture
*/
/*if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lNZTexture)
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_TEXTURE_2D);
else*/
{
OGLThread_fn_vPostCmd_1Long( OGLT1_ENABLE, GL_TEXTURE_2D);
OGLThread_fn_vPostCmd_1Long( OGLT1_BINDTEXTURE, (long)p_stGlobaleMT->p_stCurrentTexture->p_stSpecParam );
}
}
else
{
// GOURAUD
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_TEXTURE_2D);
//glBindTexture(GL_TEXTURE_2D, 0 );
if (((p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided) == 0) && (p_stGlobaleMT->xGlobalAlpha < 0.98f) )
{
// alpha iterated transparency
/*
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE,GR_BLEND_ZERO );
grAlphaCombine(GR_COMBINE_FUNCTION_BLEND, GR_COMBINE_FACTOR_LOCAL_ALPHA,GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_NONE,FXFALSE);
guAlphaSource(GR_ALPHASOURCE_ITERATED_ALPHA);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
p_stGlobaleMT -> lClippingModeMask |= GLI_C_TrianglesMustBeSorted;
}
else
{
/*
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_ONE, GL_ZERO);
}
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE); //guColorCombineFunction( GR_COLORCOMBINE_ITRGB );
ucSaveFunction = 0;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
}
/*
=======================================================================================
Write bitmap into backbuffer
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : write bitmap part into backbuffer
----------------------------------------------------------------------------------------
*/
/*
void GLI_fn_vWriteRegion3DFX(long X, long Y, long l, long h, unsigned char *p_ucSrc, long SrcPitch , GrLfbInfo_t *p_info)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* long lPitch;
long *p_sourceptr , *p_sourceptrLast , *p_destptr ,lYCounterLocal;
short *p_Src;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* p_Src = (unsigned short *)p_ucSrc;
lPitch = p_info->strideInBytes/4;
for (lYCounterLocal = 0; lYCounterLocal < h ; lYCounterLocal++)
{
p_destptr = ((unsigned long *)p_info->lfbPtr) + (X>>1) + lPitch * (Y + lYCounterLocal);
p_sourceptr = ((unsigned long *)p_Src + lYCounterLocal * (SrcPitch >>2)) ;
p_sourceptrLast = p_sourceptr + (l>>1);
for (;p_sourceptr < p_sourceptrLast ;p_sourceptr ++,p_destptr ++)
*p_destptr = *p_sourceptr ;
}
}
*/
/*
----------------------------------------------------------------------------------------
Description : Write a 16 bit bitmap in the back buffer
_p_vSourceBuffer -> bitmap
_lWidth, _lHeight -> dimension of bitmap
_lDestX, _lDestY -> where the bitmap have to be copied in the backbuffer
----------------------------------------------------------------------------------------
*/
void* g_p_vSourceBuffer;
RECT g_DestBitmapRect;
void GLI_DRV_vWrite16bBitmapToBackBuffer( void *_p_vSourceBuffer, long _lWidth, long _lHeight, long _lDestLeft, long _lDestTop, long _lDestRight, long _lDestBottom )
{
g_p_vSourceBuffer = _p_vSourceBuffer;
g_DestBitmapRect.left = _lDestLeft;
g_DestBitmapRect.top = _lDestTop;
g_DestBitmapRect.right = _lDestRight;
g_DestBitmapRect.bottom = _lDestBottom;
OGLThread_fn_vPostCmd_2Long( OGLT2_WRITEBITMAP, _lWidth, _lHeight );
}
#ifdef __cplusplus
} //extern "C"
#endif

View File

@@ -0,0 +1,121 @@
/*
=======================================================================================
Name : OGL_Errors.c
Author : Bart
Description :
=======================================================================================
*/
/*
=======================================================================================
Include
=======================================================================================
*/
#include <windows.h>
#include <stdio.h>
#include <gl/gl.h>
#include "OGL_Options.h"
#include "OGL_Errors.h"
#include "OGL_Thread.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/***** Errors Managment (ERROR_TEST) ******/
#if defined (ERROR_TEST)
void fn_vOutputLog(char* ErrorString)
{
static FILE *g_fErrorFile;
static BOOL g_bFirstTime = TRUE;
if (g_bFirstTime) {
g_bFirstTime = FALSE;
g_fErrorFile = fopen( "errors.log", "wt" );
}
if (g_fErrorFile != NULL) {
fprintf(g_fErrorFile, ErrorString);
fflush(g_fErrorFile);
}
}
void fn_vOglError(char* oglFunc)
{
GLenum oglError;
GLenum oglPrevError;
char oglErrorString[255];
int oglErrorCount;
oglError = glGetError();
while ( oglError != GL_NO_ERROR )
{
switch (oglError) {
case GL_INVALID_ENUM : sprintf(oglErrorString, "OpenGLError: INVALID_ENUM in %s ", oglFunc); break;
case GL_INVALID_VALUE : sprintf(oglErrorString, "OpenGLError: INVALID_VALUE in %s ", oglFunc); break;
case GL_INVALID_OPERATION : sprintf(oglErrorString, "OpenGLError: INVALID_OPERATION in %s ", oglFunc); break;
case GL_STACK_OVERFLOW : sprintf(oglErrorString, "OpenGLError: STACK_OVERFLOW in %s ", oglFunc); break;
case GL_STACK_UNDERFLOW : sprintf(oglErrorString, "OpenGLError: STACK_UNDERFLOW in %s ", oglFunc); break;
case GL_OUT_OF_MEMORY : sprintf(oglErrorString, "OpenGLError: OUT_OF_MEMORY in %s ", oglFunc); break;
default : sprintf(oglErrorString, "OpenGLError: !!UNKNOWN!! in %s ", oglFunc); break;
}
M_OUTPUT(oglErrorString);
oglErrorCount = 20;
oglPrevError = glGetError();
while ( (oglErrorCount>0) && ( oglPrevError == oglError ) )
{
M_OUTPUT(".");
oglErrorCount--;
oglPrevError = glGetError();
}
if ( (oglErrorCount == 0) && ( oglPrevError == oglError ) ) {
M_OUTPUT("\n\tError on glGetError(); ! ! !");
oglError = GL_NO_ERROR; /* to skip */
}
else
{
oglError = oglPrevError; /* error changed */
}
M_OUTPUT("\n");
}
}
void fn_vError()
{
LPVOID lpMsgBuf;
DWORD dwError;
dwError = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,
dwError/*GetLastError()*/,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0,
NULL
);
//MessageBox( NULL, lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION );
M_OUTPUT(lpMsgBuf);
LocalFree( lpMsgBuf );
}
#endif //defined (ERROR_TEST)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
} //extern "C"
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

View File

@@ -0,0 +1,393 @@
/*
=======================================================================================
Name : OGL_Func.c
Author : Bart
Description : included in OGL_Thread.c
=======================================================================================
*/
#include "textu_st.h"
#include "texture.h"
#include "DLLCom.h"
#include "TEX.h" // for def of GLI_C_lCyling..
extern HWND gs_hWnd;
HGLRC gs_hRC;
extern HDC gs_hDC;
/* from OGL_Acces.c */
extern GLI_tdScreenVertx ga_stVertexBuffer[ 3000 ];
/* from OGL_HdwTx.c */
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
extern short TEXTURETWIDDLED[1024L*1024L];
#else
extern long TEXTURETWIDDLED[1024L*1024L];
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
/* from OGL_Init.c */
extern RECT g_rcViewportRect;
extern RECT g_rcScreenRect;
/* from OGL_Domat.c */
extern GLI_tdScreenVertx g_stBlackTriangle[ 16 ];
extern long g_lNumberOfBlackTriangles;
extern tdstFogParams* g_p_stFogParams;
/************************************ divers ************************************/
void fn_OGLThread_vCreate()
{
M_ASSERT( (gs_hRC = wglCreateContext(gs_hDC)) )
M_ASSERT( wglMakeCurrent(gs_hDC, gs_hRC) )
}
void fn_OGLThread_vResume()
{
M_ASSERT( wglMakeCurrent(gs_hDC, NULL) ) /* make our context 'un-'current */
M_ASSERT( ReleaseDC(gs_hWnd, gs_hDC) ) /* release handle to DC - already done by wglMakeCurrent(..., NULL) ! */
M_ASSERT( wglDeleteContext(gs_hRC) ) /* delete the rendering context */
gs_hRC = NULL;
gs_hDC = NULL;
}
void fn_OGLThread_vSwap()
{
SwapBuffers( gs_hDC );
//glFinish();
//SwapBuffers(wglGetCurrentDC());
}
/************************************ OGL_Acces.c ************************************/
void fn_OGLThread_vRender(GLI_tdScreenVertx* _p_CurrentDestXYZ)
{
GLI_tdScreenVertx *p_stEnumerate;
GLubyte* pBGRA;
M_OGL_ASSERT_FAKE(glBegin(GL_TRIANGLES);)
p_stEnumerate = ga_stVertexBuffer;
while (p_stEnumerate < _p_CurrentDestXYZ)
{
//glColor4ubv( (GLubyte *) &p_stEnumerate->color );
pBGRA = (GLubyte *) &p_stEnumerate->color;
M_OGL_ASSERT_FAKE( glColor4ub( pBGRA[2], pBGRA[1], pBGRA[0], pBGRA[3]); )
M_OGL_ASSERT_FAKE( glTexCoord2f( GetU((*p_stEnumerate)), GetV((*p_stEnumerate)) ); )
M_OGL_ASSERT_FAKE( M_glVertex( GetX((*p_stEnumerate)), GetY((*p_stEnumerate)), GetZ((*p_stEnumerate)) ); )
p_stEnumerate++;
}
M_OGL_ASSERT( glEnd(); )
}
/******************************** fin OGL_Acces.c ************************************/
/************************************ OGL_HdwTx.c ************************************/
void fn_OGLThread_vLoadTextures(GLI_tdstTexture* _p_stTexture)
{
unsigned int *p_uiTextureId;
long lNbLod;
unsigned short lWidth, lHeight;
long lCurrentDecalTextureForMipMapping;
GLint nInternalFormats;
GLenum PixelDataType;
p_uiTextureId = (unsigned int *) &_p_stTexture->p_stSpecParam;
M_OGL_ASSERT( glGenTextures(1, p_uiTextureId ); )
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, *p_uiTextureId); )/*texture is bound*/
#if !defined(IGNORE_TEXTUREWRAP)
/*
* uv cycling mode
*/
switch ( _p_stTexture -> ucCylingMode )
{
case 0:
/*NO CYCLING*/
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); )
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); )
break;
case GLI_C_lCylingUV:
/*CYCLING*/
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); )
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); )
break;
case GLI_C_lCylingU:
/*CYCLING V*/
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); )
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); )
break;
case GLI_C_lCylingV:
/*CYCLING U*/
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); )
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); )
break;
}
#endif //!defined(IGNORE_TEXTUREWRAP)
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR /*GL_NEAREST*/); )
if (_p_stTexture->lNumberOfLod == 0)
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); )
else
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR /*GL_NEAREST_MIPMAP_LINEAR*/ /*GL_LINEAR_MIPMAP_NEAREST*/ /*GL_NEAREST_MIPMAP_NEAREST*/ /*GL_LINEAR*/); )
lCurrentDecalTextureForMipMapping = 0;
lWidth = _p_stTexture->lWidth;
lHeight = _p_stTexture->lHeight;
nInternalFormats = 4; // default : 8888
PixelDataType = GL_UNSIGNED_BYTE; // default (OpenGL ver 1.1, no EXT) : 32 bits !
if ( _p_stTexture->lTextureCaps & GLI_C_lAlphaTest )
{
nInternalFormats = GL_RGB5_A1; //5551
#if defined (OGL_VER2_2)
PixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; //5551
#elif defined (GL_EXT_packed_pixels)
PixelDataType = GL_UNSIGNED_SHORT_5_5_5_1_EXT; //5551
#endif //defined (GL_EXT_packed_pixels)
}
else if ((!(_p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)) && (_p_stTexture -> lTextureCaps & GLI_C_lNZFilteredTexture))
{
nInternalFormats = GL_RGB5_A1; //5551
#if defined (OGL_VER2_2)
PixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; //5551
#elif defined (GL_EXT_packed_pixels)
PixelDataType = GL_UNSIGNED_SHORT_5_5_5_1_EXT; //5551
#endif //defined (GL_EXT_packed_pixels)
}
else if (_p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)
{
nInternalFormats = GL_RGBA4; //4444
#if defined (OGL_VER2_2)
PixelDataType = GL_UNSIGNED_SHORT_4_4_4_4; //4444
#elif defined (GL_EXT_packed_pixels)
PixelDataType = GL_UNSIGNED_SHORT_4_4_4_4_EXT; //4444
#endif //defined (GL_EXT_packed_pixels)
}
else
{
nInternalFormats = GL_RGB5; //555 because no 565 !
#if defined (OGL_VER2_2)
PixelDataType = GL_UNSIGNED_SHORT_5_6_5; // 565 only in version 2.2 !
#elif defined (GL_EXT_packed_pixels)
PixelDataType = GL_UNSIGNED_SHORT_5_5_5_1_EXT; //? 5551 because no 565 !
#endif //defined (GL_EXT_packed_pixels)
}
for ( lNbLod=0 ; lNbLod <= _p_stTexture->lNumberOfLod ; lNbLod++ )
{
assert(lHeight>0);
assert(lWidth>0);
M_OGL_ASSERT( glTexImage2D(GL_TEXTURE_2D, lNbLod, nInternalFormats, lWidth, lHeight, 0, GL_RGBA, PixelDataType, TEXTURETWIDDLED+lCurrentDecalTextureForMipMapping ); )
lCurrentDecalTextureForMipMapping += lHeight * lWidth;
lHeight >>= 1;
lWidth >>= 1;
#if defined (MIPMAP_DOWN_TO_1x1)
if (lHeight == 0) lHeight = 1;
if (lWidth == 0) lWidth = 1;
#endif //defined (MIPMAP_DOWN_TO_1x1)
}
}
/******************************** fin OGL_HdwTx.c ************************************/
/************************************ OGL_Init.c ************************************/
#if defined (Z_BUFFER)
#define ZFAR 10000.0f
#define ZNEAR 0.0f //0.1667f
#define VIG_ZPOS 6.0f
#else //W_BUFFER
#define ZFAR 0.0001f
#if defined ACCURATE_DEPTH_BUFFER
#define ZNEAR 0.5f
#else
#define ZNEAR 6.0f
#endif
#define VIG_ZPOS ZNEAR
#endif
void fn_OGLThread_vInitOglFlags()
{
/*** GL_TEXTURE ***/
M_OGL_ASSERT( glMatrixMode(GL_TEXTURE); )
M_OGL_ASSERT( glLoadIdentity(); )
//glScalef( 1.0f, -1.0f, 0.0f ); // ?
/*** GL_PROJECTION ***/
M_OGL_ASSERT( glMatrixMode(GL_PROJECTION); )
M_OGL_ASSERT( glLoadIdentity(); )
/*** GL_MODELVIEW ***/
M_OGL_ASSERT( glMatrixMode(GL_MODELVIEW); )
M_OGL_ASSERT( glLoadIdentity(); )
M_OGL_ASSERT( glOrtho(0, (GLdouble)(g_rcViewportRect.right - g_rcViewportRect.left), (GLdouble)(g_rcViewportRect.bottom - g_rcViewportRect.top), 0, -ZFAR, -ZNEAR); )
M_OGL_ASSERT( glViewport(0, 0, g_rcScreenRect.right - g_rcScreenRect.left, g_rcScreenRect.bottom - g_rcScreenRect.top); )
{
M_OGL_ASSERT( glDisable(GL_ALPHA_TEST); )
//M_OGL_ASSERT( glDisable(GL_BLEND); )
//M_OGL_ASSERT( glDisable(GL_DEPTH_TEST); )
M_OGL_ASSERT( glDisable(GL_DITHER); )
M_OGL_ASSERT( glDisable(GL_LIGHTING); )
M_OGL_ASSERT( glDisable(GL_LOGIC_OP); )
M_OGL_ASSERT( glDisable(GL_STENCIL_TEST); )
M_OGL_ASSERT( glDisable(GL_TEXTURE_1D); )
M_OGL_ASSERT( glDisable(GL_TEXTURE_2D); )
M_OGL_ASSERT( glPixelTransferi(GL_MAP_COLOR, GL_FALSE); )
M_OGL_ASSERT( glPixelTransferi(GL_RED_SCALE, 1); )
M_OGL_ASSERT( glPixelTransferi(GL_RED_BIAS, 0); )
M_OGL_ASSERT( glPixelTransferi(GL_GREEN_SCALE, 1); )
M_OGL_ASSERT( glPixelTransferi(GL_GREEN_BIAS, 0); )
M_OGL_ASSERT( glPixelTransferi(GL_BLUE_SCALE, 1); )
M_OGL_ASSERT( glPixelTransferi(GL_BLUE_BIAS, 0); )
M_OGL_ASSERT( glPixelTransferi(GL_ALPHA_SCALE, 1); )
M_OGL_ASSERT( glPixelTransferi(GL_ALPHA_BIAS, 0); )
}
M_OGL_ASSERT( glEnable(GL_DEPTH_TEST); ) // Hidden surface removal
M_OGL_ASSERT( glDepthMask( GL_TRUE ); )
M_OGL_ASSERT( glDisable(GL_CULL_FACE); ) // Do not calculate inside of jet
//glEnable(GL_CULL_FACE); // Do not calculate inside of jet
M_OGL_ASSERT( glFrontFace(GL_CCW); ) // Counter clock-wise polygons face out
M_OGL_ASSERT( glEnable(GL_TEXTURE_2D); )
M_OGL_ASSERT( glEnable(GL_BLEND); )
M_OGL_ASSERT( glClearColor (0.0, 0.0, 0.0, 0.0); )
M_OGL_ASSERT( glClearDepth(0.0f); )
M_OGL_ASSERT( glDepthFunc( GL_GREATER ); )
//M_OGL_ASSERT( glClearDepth(1.0f); )
//M_OGL_ASSERT( glDepthFunc( GL_LESS ); )
//glDepthMask( GL_TRUE );
// fog
M_OGL_ASSERT( glDisable(GL_FOG); )
M_OGL_ASSERT( glFogi(GL_FOG_MODE, GL_LINEAR /*GL_EXP*/); ) //grFogTable( Gli_C_xFogTable );
// hint
M_OGL_ASSERT( glHint (GL_FOG_HINT, /*GL_NICEST*/ GL_FASTEST); ) /* per pixel */
M_OGL_ASSERT( glHint (GL_PERSPECTIVE_CORRECTION_HINT, /*GL_NICEST*/ GL_FASTEST); )
}
void fn_OGLThread_vClearDevice(BOOL ZBuffer, BOOL ColorBuffer, unsigned long Color)
{
char cR, cG, cB, cA;
char* pColor;
M_OGL_ASSERT( glDepthMask( GL_TRUE ); )
pColor = (char*) &Color;
cR = *pColor++;
cG = *pColor++;
cB = *pColor++;
cA = *pColor;
M_OGL_ASSERT( glClearColor ((float)cR/255.0f, (float)cG/255.0f, (float)cB/255.0f, (float)cA/255.0f); )
if ( ColorBuffer )
if (ZBuffer)
M_OGL_ASSERT( {glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); )}
else
M_OGL_ASSERT( {glClear(GL_COLOR_BUFFER_BIT ); )}
else if (ZBuffer)
M_OGL_ASSERT( {glClear( GL_DEPTH_BUFFER_BIT ); )}
}
/******************************** fin OGL_Init.c ************************************/
/******************************** OGL_Domat.c ************************************/
void fn_OGLThread_vSendBlackPolygon(void)
{
GLI_tdScreenVertx *p_stVertex, *p_stLastVertex;
M_OGL_ASSERT( glDisable(GL_TEXTURE_2D); )
M_OGL_ASSERT( glDisable(GL_FOG); )
M_OGL_ASSERT( glBlendFunc(GL_ONE, GL_ZERO); ) //grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
M_OGL_ASSERT( glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE/*GL_DECAL*/ /*not yet implemented : GL_BLEND, GL_REPLACE*/ ); ) //guColorCombineFunction( GR_COLORCOMBINE_ITRGB);
M_OGL_ASSERT( glColor4ub( 0, 0, 0, 0 ); )
p_stVertex = g_stBlackTriangle;
p_stLastVertex = p_stVertex + g_lNumberOfBlackTriangles;
M_OGL_ASSERT_FAKE( glBegin(GL_QUADS); )
for ( ; p_stVertex < p_stLastVertex; p_stVertex++ )
M_OGL_ASSERT_FAKE( glVertex3f( p_stVertex->sx, p_stVertex->sy, p_stVertex->sz ); )
M_OGL_ASSERT( glEnd(); )
}
void fn_OGLThread_vSetFogParams(void)
{
GLfloat fogColor[4];
GLfloat fBlendFactor;
M_OGL_ASSERT( glFogf (GL_FOG_START, g_p_stFogParams->xDepthStart); )
M_OGL_ASSERT( glFogf (GL_FOG_END, g_p_stFogParams->xDepthEnd); )
//glFogf (GL_FOG_DENSITY, g_p_stFogParams->xBlendEnd); // ?
fBlendFactor = g_p_stFogParams->xBlendEnd / 255.0f;
fogColor[0] = (GLfloat)g_p_stFogParams->stColor.xR * fBlendFactor;
fogColor[1] = (GLfloat)g_p_stFogParams->stColor.xG * fBlendFactor;
fogColor[2] = (GLfloat)g_p_stFogParams->stColor.xB * fBlendFactor;
fogColor[3] = (GLfloat)g_p_stFogParams->stColor.xA * fBlendFactor;
M_OGL_ASSERT( glFogfv(GL_FOG_COLOR, fogColor); ) //grFogColorValue(GlideColor);
fBlendFactor = g_p_stFogParams->xBlendStart / 255.0f;
fogColor[0] = (GLfloat)g_p_stFogParams->stColor.xR * fBlendFactor;
fogColor[1] = (GLfloat)g_p_stFogParams->stColor.xG * fBlendFactor;
fogColor[2] = (GLfloat)g_p_stFogParams->stColor.xB * fBlendFactor;
fogColor[3] = (GLfloat)g_p_stFogParams->stColor.xA * fBlendFactor;
M_OGL_ASSERT( glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, fogColor ); )
}
/******************************** fin OGL_Domat.c ************************************/
#include "OGL_Lock.c"

View File

@@ -0,0 +1,396 @@
#include <windows.h>
#include <gl/gl.h>
#include "GLD.h"
#include "GEO.h"
#include "TEX.h"
#include "gli_st.h"
#include "textu_st.h"
#include "texture.h"
#include "FIL.h"
#include "DLLCom.h"
#include "OGL_Options.h"
#include "OGL_Errors.h"
#include "OGL_Thread.h"
static long GLI_gs_lMaxTmuAvailable;
//GLI_tdstTexture *g_p_stTexture;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
short TEXTURETWIDDLED[1024L*1024L];
#else
long TEXTURETWIDDLED[1024L*1024L];
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
long GLI_fn_lGetTotalTextureMemorySize( void )
{
/*
long i,lSize;
GLI_gs_lMaxTmuAvailable = 2 ;
lSize = 0;
for (i = 0 ; i < GLI_gs_lMaxTmuAvailable ; i++)
lSize += grTexMaxAddress( i ) - grTexMinAddress( i );
return (lSize);
*/
return -1;
}
/*
----------------------------------------------------------------------------------------
Description : get video memory size taken by a given texture
----------------------------------------------------------------------------------------
*/
long GLI_DRV_lGetSizeOfTexture( GLI_tdstTexture *p_stTexture )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lTextureSize;
long lRef, lSize;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
lTextureSize = p_stTexture->lHeight * p_stTexture->lWidth;
/*
* 8 bits
*/
if (!(p_stTexture->lTextureCaps & GLI_C_lPaletteTexture))
lTextureSize <<= 1;
/*
* mipmap
*/
if (p_stTexture ->lNumberOfLod)
{
lRef = (p_stTexture->lWidth > p_stTexture->lHeight) ? p_stTexture->lHeight : p_stTexture->lWidth;
lSize = lTextureSize;
while ( lRef )
{
lSize >>= 2;
lRef >>= 1;
lTextureSize += lSize;
}
}
/*
* alignment
*/
if ( lTextureSize & 0x7 )
{
lTextureSize += 8 - (lTextureSize & 0x7);
}
GLI_MDRV_TEXBENCH_vSetTextureSize( p_stTexture, TEXBENCH_C_cComputedSize, lTextureSize );
return lTextureSize;
}
/*
----------------------------------------------------------------------------------------
Description : Compress texture and compute mip map levels
----------------------------------------------------------------------------------------
*/
static void GLI_vCompressTex ( GLI_tdstTexture *p_stTexture, BOOL bReloading)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lCurrentDecalTextureForMipMapping, Verify;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
unsigned short *p_Destination;
#else
unsigned long *p_Destination;
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
//unsigned char *p_ucDest;
//unsigned long *p_ulPalette;
long lNbLod;
unsigned short lWidth, lHeight;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (p_stTexture == NULL )
return;
lCurrentDecalTextureForMipMapping = 0;
p_Destination = TEXTURETWIDDLED;
p_stTexture->p_vBitMap = GLI_gs_p_ConvertBufferMipMapping;
/*
* load texture
*/
GLI_MDRV_xLoadTextureInTexelField(p_stTexture, GLI_gs_p_ConvertBufferMipMapping, bReloading/*TRUE*/);
/*
* check for alpha texture
*/
if ((p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture) || (p_stTexture -> lTextureCaps & GLI_C_lNZFilteredTexture))
{
Verify = GLI_MDRV_vVerifyTextureIsRealyAlpha(p_stTexture);
if ((Verify & 0xE0000000) == 0xE0000000)
p_stTexture -> lTextureCaps &= 0xffffffff - GLI_C_lAlphaTexture;
if ((Verify & 0x80000000) == 0x80000000)
p_stTexture -> lTextureCaps &= 0xffffffff - GLI_C_lNZFilteredTexture;
}
#if defined (NO_MIPMAP_FOR_TRANSPARENT_TEX)
if (p_stTexture -> lTextureCaps & (/*GLI_C_lAlphaTest |*/ GLI_C_lAlphaTexture /*| GLI_C_lNZFilteredTexture */ /*| GLI_C_lAddTransparencyTexture*/) )
p_stTexture->lNumberOfLod = 0;
#endif //defined (NO_MIPMAP_FOR_TRANSPARENT_TEX)
#if defined (MIPMAP_DOWN_TO_1x1)
if ( (p_stTexture->lNumberOfLod >0) && (p_stTexture->lWidth != p_stTexture->lHeight) )
{
//recalc lNumberOfLod
lWidth = p_stTexture->lWidth;
lHeight = p_stTexture->lHeight;
while ( (lWidth>1) && (lHeight>1) ) {
lHeight >>= 1;
lWidth >>= 1;
}
while ( (lWidth>1) || (lHeight>1) ) {
p_stTexture->lNumberOfLod++;
lHeight >>= 1;
lWidth >>= 1;
}
}
#endif //defined MIPMAP_DOWN_TO_1x1
p_stTexture->p_vBitMap = GLI_gs_p_ConvertBufferMipMapping;
lNbLod = p_stTexture->lNumberOfLod;
lWidth = p_stTexture->lWidth;
lHeight = p_stTexture->lHeight;
/*if ( p_stTexture->lTextureCaps & GLI_C_lPaletteTexture )
{
p_ucDest = (char *) p_Destination;
p_ulPalette = (unsigned long *) p_stTexture->p_vColorTable;
//((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_P_8;
memcpy( p_ucDest, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth );
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
GLI_MDRV_vDivideBitmapSurfaceBy2Palette( (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_ulPalette, p_stTexture->lHeight, p_stTexture->lWidth );
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
memcpy( p_ucDest + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth );
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else */
// TEST sur nouveau traitement sur texture NZ : marche pas bien pour l'instant
if ( p_stTexture->lTextureCaps & GLI_C_lAlphaTest )
{
//((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_1555;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination)) ;
#else
memcpy( p_Destination, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture->lHeight, p_stTexture->lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
#else
memcpy( p_Destination + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else if ((!(p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)) && (p_stTexture -> lTextureCaps & GLI_C_lNZFilteredTexture))
{
//((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_1555;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination)) ;
#else
memcpy( p_Destination , GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth);
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
#else
memcpy( p_Destination + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else if (p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)
{
//((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_4444;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex4444( p_stTexture , (void *)(p_Destination)) ;
#else
memcpy( p_Destination, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight , p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight , p_stTexture -> lWidth );
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex4444( p_stTexture , (void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
#else
memcpy( p_Destination + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else
{
//((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_RGB_565;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex565( p_stTexture , (void *)(p_Destination)) ;
#else
memcpy( p_Destination, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth);
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex565 ( p_stTexture , (void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
#else
memcpy( p_Destination + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
p_stTexture->lWidth = lWidth;
p_stTexture->lHeight = lHeight;
}
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vDownLoadTextures(long bRestore, long _lTextureMode, BOOL bReloading )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lTextureCounter;
GLI_tdstTexture *p_stTexture;
/*#if defined (ERROR_TEST)
char sz255String[255];
#endif //defined (ERROR_TEST)*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
#if defined (ERROR_TEST)
p_uiTextureId = NULL;
#endif //defined (ERROR_TEST)
*/
for (lTextureCounter = 0; lTextureCounter < GLI_C_lNBMaxOfTextures ; lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] == GLI_TEXIsUnallocated )
continue;
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
if (p_stTexture == NULL)
continue;
OGLThread_fn_vWaitForSynchro(); // finishing
GLI_vCompressTex( p_stTexture, bReloading);
//GLI_MDRV_xLoadTextureInTexelField(p_stTexture, GLI_gs_p_ConvertBufferMipMapping, bReloading); //bart990224
p_stTexture -> bIsAvailable = 1;
OGLThread_fn_vWaitForSynchro(); // for TEXTURETWIDDLED
//grTexDownloadMipMap (p_stSpecParam -> xTmuNumber,p_stSpecParam -> xStartAddress ,p_stSpecParam -> xEvenOdd ,&p_stSpecParam -> stInfoBitmapGlide );
OGLThread_fn_vPostCmd_1Long(OGLT1_LOADTEXTURES, (long)p_stTexture);
}
/*
#if defined (ERROR_TEST)
if (p_uiTextureId == NULL) {
M_OUTPUT("No texture loaded ! ! !\n");
}
else {
sprintf(sz255String, "Last texture loaded : %d\n", *p_uiTextureId);
M_OUTPUT(sz255String);
}
#endif //defined (ERROR_TEST)
*/
/*#endif*/
}
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vUnLoadTextures()
{
long lTextureCounter;
//unsigned int *p_uiTextureId;
GLI_tdstTexture *p_stTexture;
for ( lTextureCounter = 0 ; lTextureCounter < C_lMaxNumberOfTexture ;lTextureCounter ++)
{
if (
(gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated )
)
{
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
if (p_stTexture != NULL)
{
if (p_stTexture->bIsAvailable)
{
OGLThread_fn_vPostCmd_1Long(OGLT1_DELETETEXTURE, (long)p_stTexture->p_stSpecParam); //p_uiTextureId = (unsigned int *) &p_stTexture->p_stSpecParam;
p_stTexture->bIsAvailable = 0;
}
}
}
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,398 @@
/*
=======================================================================================
Name : OGL_Lock.c
Author : Bart
Description :
=======================================================================================
*/
/*
=======================================================================================
Lock / unlock backbuffer
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Lock (return pointer on virtual screen and pitch value)
----------------------------------------------------------------------------------------
*/
#define MAX_TEX_WIDTH 1024 /*256*/
#define MAX_TEX_HEIGHT 512 /*128*/
//unsigned long g_aulTmpBuffer[ MAX_TEX_WIDTH * MAX_TEX_HEIGHT ]; // RGBA 8888
unsigned char g_a3ucTmpBuffer[ 3 * MAX_TEX_WIDTH * MAX_TEX_HEIGHT ]; // RGB 888
unsigned short g_auwBuffer[ MAX_TEX_WIDTH * MAX_TEX_HEIGHT ]; // RGB 565
void* g_p_vVirtualScreen;
long g_lPitch;
void vConvertBuffer888To565_InvY(unsigned short* _puwDst, unsigned char* _pucSrc, long _lWidth, long _lHeight, long _lYOffset)
{
int Xpos, Ypos;
unsigned char cR, cG, cB;
unsigned char* pucSrc;
unsigned char* pucDst;
for (Ypos = 0; Ypos<_lHeight-_lYOffset ; Ypos++)
{
pucSrc = (unsigned char*)(_pucSrc+3*(_lHeight-_lYOffset-Ypos-1)*_lWidth);
pucDst = (unsigned char*)(_puwDst+Ypos*_lWidth);
for (Xpos = 0; Xpos<_lWidth ; Xpos++)
{
cR = *pucSrc++;
cG = *pucSrc++;
cB = *pucSrc++;
*pucDst++ = ((cG&0x1C)<<3)+((cB&0xF8)>>3);
*pucDst++ = (cR&0xF8)+((cG&0xE0)>>5);
}
}
memset( _puwDst + (_lHeight-_lYOffset) * _lWidth , 0, _lYOffset*_lWidth*sizeof(unsigned short));
}
void vConvertBuffer565To888(unsigned char* _pucDst, unsigned short* _puwSrc, long _lWidth, long _lHeight)
{
int Xpos, Ypos;
unsigned char cR, cG, cB;
unsigned char* pucSrc;
unsigned char* pucDst;
for (Ypos = 0; Ypos<_lHeight ; Ypos++)
{
pucSrc = (unsigned char*)(_puwSrc+Ypos*_lWidth);
pucDst = (unsigned char*)(_pucDst+3*Ypos*_lWidth);
for (Xpos = 0; Xpos<_lWidth ; Xpos++)
{
cB = (*pucSrc & 0x1F)<<3;
cG = ((*pucSrc & 0xE0)>>3) + ((*(pucSrc+1) & 0x07)<<5);
cR = (*(pucSrc+1) & 0xF8);
pucSrc+=2;
*pucDst++ = cR;
*pucDst++ = cG;
*pucDst++ = cB;
}
}
}
long fn_lSmallestPowerOfTwoGreaterThan(long lNb, GLint _nMaxSize)
{
long lRet = 1;
while (lRet < _nMaxSize)
{
if (lNb <= lRet)
return lRet;
lRet <<= 1;
}
return _nMaxSize;
}
void fn_OGL_vDisplayTexture(long _lWScreen, long _lHScreen, long _lWTexture, long _lHTexture)
{
float fWRatio, fHRatio;
float fWTextureCoord, fHTextureCoord, fWVertexCoord, fHVertexCoord;
float fCoordLeft, fCoordRight, fCoordTop, fCoordBottom;
fWRatio = (float)_lWScreen / (float)_lWTexture;
fHRatio = (float)_lHScreen / (float)_lHTexture;
if (fWRatio < 1) {
fWTextureCoord = fWRatio;
fWVertexCoord = 1;
} else {
fWTextureCoord = 1;
fWVertexCoord = 1/fWRatio;
}
if (fHRatio < 1) {
fHTextureCoord = fHRatio;
fHVertexCoord = 1;
} else {
fHTextureCoord = 1;
fHVertexCoord = 1/fHRatio;
}
fCoordLeft = -1;
fCoordRight = -1 + 2*fWVertexCoord;
fCoordTop = -(-1);
fCoordBottom = -(-1 + 2*fHVertexCoord);
M_OGL_ASSERT( glEnable( GL_TEXTURE_2D); )
M_OGL_ASSERT( glDisable( GL_BLEND); )
M_OGL_ASSERT( glDisable(GL_DEPTH_TEST); )
M_OGL_ASSERT( glMatrixMode(GL_MODELVIEW); )
M_OGL_ASSERT( glPushMatrix(); )
M_OGL_ASSERT( glLoadIdentity(); )
//M_OGL_ASSERT( glRasterPos2f(-1.0f, -1.0f); )
M_OGL_ASSERT_FAKE( glBegin (GL_QUADS); )
M_OGL_ASSERT_FAKE( glColor4f( 1, 1, 1, 1); )
M_OGL_ASSERT_FAKE( glTexCoord2f(0, /*1*/fHTextureCoord); )
M_OGL_ASSERT_FAKE( glVertex3f(fCoordLeft, fCoordBottom, 0); )
M_OGL_ASSERT_FAKE( glTexCoord2f(0, /*1-fHTextureCoord*/0); )
M_OGL_ASSERT_FAKE( glVertex3f(fCoordLeft, fCoordTop, 0); )
M_OGL_ASSERT_FAKE( glTexCoord2f(fWTextureCoord, /*1-fHTextureCoord*/0); )
M_OGL_ASSERT_FAKE( glVertex3f(fCoordRight, fCoordTop, 0); )
M_OGL_ASSERT_FAKE( glTexCoord2f(fWTextureCoord, /*1*/fHTextureCoord); )
M_OGL_ASSERT_FAKE( glVertex3f(fCoordRight, fCoordBottom, 0); )
M_OGL_ASSERT( glEnd(); )
M_OGL_ASSERT( glPopMatrix(); )
M_OGL_ASSERT( glEnable(GL_DEPTH_TEST); )
M_OGL_ASSERT( glEnable(GL_BLEND); )
}
void fn_OGL_vDisplayTextureWithCoord(long _lWScreen, long _lHScreen, long _lWTexture, long _lHTexture, long _lCoordLeft, long _lCoordTop, long _lCoordRight, long _lCoordBottom)
{
float fWRatio, fHRatio;
fWRatio = (float)_lWScreen / (float)_lWTexture;
fHRatio = (float)_lHScreen / (float)_lHTexture;
assert (fWRatio < 1);
assert (fHRatio < 1);
M_OGL_ASSERT( glEnable( GL_TEXTURE_2D); )
M_OGL_ASSERT( glDisable( GL_BLEND); )
M_OGL_ASSERT( glDisable(GL_DEPTH_TEST); )
M_OGL_ASSERT( glMatrixMode(GL_MODELVIEW); )
/*
M_OGL_ASSERT( glPushMatrix(); )
M_OGL_ASSERT( glLoadIdentity(); )
M_OGL_ASSERT( glOrtho(0, (GLdouble)(_lCoordRight - _lCoordLeft), (GLdouble)(_lCoordBottom - _lCoordTop), 0, 0, -0.5); )
*/
M_OGL_ASSERT_FAKE( glBegin (GL_QUADS); )
M_OGL_ASSERT_FAKE( glColor4f( 1, 1, 1, 1); )
M_OGL_ASSERT_FAKE( glTexCoord2f(0, fHRatio); )
M_OGL_ASSERT_FAKE( glVertex3f((float)_lCoordLeft, (float)_lCoordBottom, VIG_ZPOS); )
M_OGL_ASSERT_FAKE( glTexCoord2f(0, 0); )
M_OGL_ASSERT_FAKE( glVertex3f((float)_lCoordLeft, (float)_lCoordTop, VIG_ZPOS); )
M_OGL_ASSERT_FAKE( glTexCoord2f(fWRatio, 0); )
M_OGL_ASSERT_FAKE( glVertex3f((float)_lCoordRight, (float)_lCoordTop, VIG_ZPOS); )
M_OGL_ASSERT_FAKE( glTexCoord2f(fWRatio, fHRatio); )
M_OGL_ASSERT_FAKE( glVertex3f((float)_lCoordRight, (float)_lCoordBottom, VIG_ZPOS); )
M_OGL_ASSERT( glEnd(); )
//M_OGL_ASSERT( glPopMatrix(); )
M_OGL_ASSERT( glEnable(GL_DEPTH_TEST); ) // Hidden surface removal
M_OGL_ASSERT( glEnable(GL_BLEND); )
}
long g_lScreenWidth, g_lScreenHeight, g_lTextureWidth, g_lTextureHeight;
void fn_OGLThread_vLockDevice(void)
{
GLuint uiTextureId;
RECT rcScreenRect;
GLint nMaxSize;
long lYPos;
GetClientRect( gs_hWnd, &rcScreenRect );
g_lScreenWidth = rcScreenRect.right - rcScreenRect.left;
g_lScreenHeight = rcScreenRect.bottom - rcScreenRect.top;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &nMaxSize);
g_lTextureWidth = fn_lSmallestPowerOfTwoGreaterThan(g_lScreenWidth, (nMaxSize>MAX_TEX_WIDTH) ? MAX_TEX_WIDTH : nMaxSize);
g_lTextureHeight = fn_lSmallestPowerOfTwoGreaterThan(g_lScreenHeight, (nMaxSize>MAX_TEX_HEIGHT) ? MAX_TEX_HEIGHT : nMaxSize);
//M_OGL_ASSERT( glEnable(GL_TEXTURE_2D); ) // don't need ? ! ! !
lYPos = g_lScreenHeight-g_lTextureHeight;
M_OGL_ASSERT( glGenTextures(1, &uiTextureId ); ) // to prevent from destroying an existing texture
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, uiTextureId); )
M_OGL_ASSERT( glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA/*GL_RGB5_A1*/, 0, (lYPos<0) ? 0 : lYPos, g_lTextureWidth, g_lTextureHeight, 0 ); )
//M_OGL_ASSERT( glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGB/*GL_RGB5_A1*/, 0, lYPos, g_lTextureWidth, g_lTextureHeight, 0 ); )
//M_OGL_ASSERT( glGetTexImage( GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, g_aulTmpBuffer ); )
M_OGL_ASSERT( glGetTexImage( GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, g_a3ucTmpBuffer ); )
M_OGL_ASSERT( glDeleteTextures(1, &uiTextureId); )
//vConvertBuffer8888To565_InvY(g_auwBuffer, g_aulTmpBuffer, g_lTextureWidth, g_lTextureHeight, (lYPos<0) ? -lYPos : 0 );
vConvertBuffer888To565_InvY(g_auwBuffer, g_a3ucTmpBuffer, g_lTextureWidth, g_lTextureHeight, (lYPos<0) ? -lYPos : 0 );
g_p_vVirtualScreen = g_auwBuffer;
g_lPitch = g_lTextureWidth*2;
}
void fn_OGLThread_vUnlockDevice(void)
{
GLuint uiTextureId;
//vConvertBuffer565To8888(g_aulTmpBuffer, g_auwBuffer, g_lTextureWidth, g_lTextureHeight);
vConvertBuffer565To888(g_a3ucTmpBuffer, g_auwBuffer, g_lTextureWidth, g_lTextureHeight);
//M_OGL_ASSERT( glEnable(GL_TEXTURE_2D); ) // don't need ? ! ! !
M_OGL_ASSERT( glGenTextures(1, &uiTextureId ); )
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, uiTextureId); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP/*GL_REPEAT*/); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP/*GL_REPEAT*/); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); )
//M_OGL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, 4/*GL_RGB5_A1*/, g_lTextureWidth, g_lTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, g_aulTmpBuffer); )
M_OGL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, 3/*GL_RGB5_A1*/, g_lTextureWidth, g_lTextureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, g_a3ucTmpBuffer); )
// display the texture all over the ScreenRect :
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, uiTextureId); )
fn_OGL_vDisplayTexture(g_lScreenWidth, g_lScreenHeight, g_lTextureWidth, g_lTextureHeight);
M_OGL_ASSERT( glDeleteTextures(1, &uiTextureId); )
}
/*
void vCopyBufferToTexture8888(unsigned long* _pulDst, unsigned long* _pulSrc, long _lWDst, long _lHDst, long _lWSrc, long _lHSrc)
{
long lYPos;
if ( (_lWSrc > _lWDst) || (_lHSrc > _lHDst) )
return;
for (lYPos = 0 ; lYPos<_lHSrc ; lYPos++) {
memcpy(_pulDst + lYPos*_lWDst, _pulSrc+lYPos*_lWSrc, _lWSrc*sizeof(unsigned long));
memset(_pulDst + lYPos*_lWDst + _lWSrc, 0, (_lWDst-_lWSrc)*sizeof(unsigned long));
}
//for (lYPos = _lHSrc ; lYPos<_lHDst ; lYPos++)
// memset(_pulDst + lYPos*_lWDst, 0, _lWDst*sizeof(unsigned long));
memset(_pulDst + _lHSrc*_lWDst, 0, (_lHDst-_lHSrc)*_lWDst*sizeof(unsigned long));
}
*/
void vCopyBufferToTexture16b(unsigned short* _pulDst, unsigned short* _pulSrc, long _lWDst, long _lHDst, long _lWSrc, long _lHSrc)
{
long lYPos;
if ( (_lWSrc > _lWDst) || (_lHSrc > _lHDst) )
return;
for (lYPos = 0 ; lYPos<_lHSrc ; lYPos++) {
memcpy(_pulDst + lYPos*_lWDst, _pulSrc+lYPos*_lWSrc, _lWSrc*sizeof(unsigned short));
memset(_pulDst + lYPos*_lWDst + _lWSrc, 0, (_lWDst-_lWSrc)*sizeof(unsigned short));
}
//for (lYPos = _lHSrc ; lYPos<_lHDst ; lYPos++)
// memset(_pulDst + lYPos*_lWDst, 0, _lWDst*sizeof(unsigned short));
memset(_pulDst + _lHSrc*_lWDst, 0, (_lHDst-_lHSrc)*_lWDst*sizeof(unsigned short));
}
void vStretchBufferToTexture8888(unsigned long* _pulDst, unsigned long* _pulSrc, long _lWDst, long _lHDst, long _lWSrc, long _lHSrc)
{
long lXPos, lYPos;
long lXStep, lYStep;
lXStep = 1;
lYStep = 1;
while (_lWSrc > _lWDst) {
lXStep <<= 1; // *2
_lWSrc >>= 1; // /2
}
while (_lHSrc > _lHDst) {
lYStep <<= 1; // *2
_lHSrc >>= 1; // /2
}
for (lYPos = 0 ; lYPos<_lHSrc ; lYPos+=lYStep) {
//memcpy(_pulDst + lYPos*_lWDst, _pulSrc+lYPos*_lWSrc, _lWSrc*sizeof(unsigned long));
for (lXPos = 0 ; lXPos<_lWSrc ; lXPos+=lXStep)
*(_pulDst + lYPos*_lWDst + lXPos) = *(_pulSrc + lYPos*_lWSrc + lXPos);
memset(_pulDst + lYPos*_lWDst + _lWSrc, 0, (_lWDst-_lWSrc)*sizeof(unsigned long));
}
//for (lYPos = _lHSrc ; lYPos<_lHDst ; lYPos++)
// memset(_pulDst + lYPos*_lWDst, 0, _lWDst*sizeof(unsigned long));
memset(_pulDst + _lHSrc*_lWDst, 0, (_lHDst-_lHSrc)*_lWDst*sizeof(unsigned long));
}
extern void *g_p_vSourceBuffer;
extern RECT g_DestBitmapRect;
void fn_OGLThread_vWrite16bBitmapToBackBuffer(long _lWidth, long _lHeight)
{
GLint nMaxSize;
long lTextureWidth, lTextureHeight;
GLuint uiTextureId;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &nMaxSize);
lTextureWidth = fn_lSmallestPowerOfTwoGreaterThan(_lWidth, (nMaxSize>MAX_TEX_WIDTH) ? MAX_TEX_WIDTH : nMaxSize);
lTextureHeight = fn_lSmallestPowerOfTwoGreaterThan(_lHeight, (nMaxSize>MAX_TEX_HEIGHT) ? MAX_TEX_HEIGHT : nMaxSize);
vCopyBufferToTexture16b(g_auwBuffer, (unsigned short*)g_p_vSourceBuffer, lTextureWidth, lTextureHeight, _lWidth, _lHeight);
//vConvertBuffer565To8888(g_aulTmpBuffer, g_auwBuffer, lTextureWidth, lTextureHeight);
vConvertBuffer565To888(g_a3ucTmpBuffer, g_auwBuffer, lTextureWidth, lTextureHeight);
//M_OGL_ASSERT( glEnable(GL_TEXTURE_2D); ) // don't need ? ! ! !
M_OGL_ASSERT( glGenTextures(1, &uiTextureId ); )
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, uiTextureId); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP/*GL_REPEAT*/); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP/*GL_REPEAT*/); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); )
//M_OGL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, 4, lTextureWidth, lTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, g_aulTmpBuffer); )
M_OGL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, 3, lTextureWidth, lTextureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, g_a3ucTmpBuffer); )
M_OGL_ASSERT( glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); )
// display the texture all over the ScreenRect :
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, uiTextureId); )
//M_OGL_ASSERT( glDisable(GL_CULL_FACE); )
fn_OGL_vDisplayTextureWithCoord(_lWidth, _lHeight, lTextureWidth, lTextureHeight, g_DestBitmapRect.left, g_DestBitmapRect.top, g_DestBitmapRect.right, g_DestBitmapRect.bottom);
//fn_OGL_vDisplayTexture(_lWidth, _lHeight, lTextureWidth, lTextureHeight);
M_OGL_ASSERT( glDeleteTextures(1, &uiTextureId); )
}

View File

@@ -0,0 +1,399 @@
/*
=======================================================================================
Name : OGL_Thread.c
Author : Bart
Description :
=======================================================================================
*/
/*
=======================================================================================
Include
=======================================================================================
*/
#include <windows.h>
#include <gl/gl.h>
#include "OGL_Options.h"
#include "OGL_Errors.h"
#include "OGL_Thread.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// opengl thread
HANDLE g_h_OpenGLThread;
DWORD g_xThreadId;
#define M_h_GetOpenGLThread() (g_h_OpenGLThread)
#define M_v_SetOpenGLThread(_hThread) {g_h_OpenGLThread = _hThread;}
#define M_x_GetOpenGLThreadId() (g_xThreadId)
//events
#define C_sz_ThreadCreationEvtName "CREATETHREADEVT"
HANDLE hEvent_ThreadCreation = NULL; //, hEvent_ThreadCreation2;
#define C_sz_WaitingForBooleanEvtName "WAIT4BOOLEVT"
HANDLE hEvent_WaitingForBoolean = NULL; //, hEvent_WaitingForBoolean2;
#define C_sz_JustWaiting "JUSTWAIT"
HANDLE hEvent_WaitForSynchro = NULL; //, hEvent_Wait2;
/*
//mutexes
#define C_sz_CounterMutexName "FIFOCOUNT"
HANDLE hMutex_FIFOCount = NULL;
*/
/*
// FIFO
#define FIFO_MEM_SIZE 10
long* g_plFIFOStartPointer = NULL;
long g_lFIFOCurrentOffset;
long g_lFIFOCount;
#define M_GetParam(offset) g_plFIFOStartPointer[(offset)%FIFO_MEM_SIZE]
*/
/***** Called Functions *****/
#include "OGL_Func.c"
/*
long fn_lMallocNLong(int _nSize)
{
long lRet;
WaitForSingleObject( hMutex_FIFOCount, INFINITE ); //blocking on the mutex
if (g_lFIFOCount+_nSize > FIFO_MEM_SIZE) { // >= oder > ?
M_OUTPUT("Overflow\n");
ReleaseMutex( hMutex_FIFOCount );
OGLThread_fn_vWaitForSynchro();
WaitForSingleObject(hMutex_FIFOCount, INFINITE);
assert(g_lFIFOCount == 0);
}
assert (g_lFIFOCount >= 0);
g_lFIFOCount += _nSize;
lRet = g_lFIFOCurrentOffset;
g_lFIFOCurrentOffset = (g_lFIFOCurrentOffset + _nSize) % FIFO_MEM_SIZE;
ReleaseMutex( hMutex_FIFOCount );
return lRet;
}
void fn_vFreeNLong(int _nSize)
{
WaitForSingleObject( hMutex_FIFOCount, INFINITE );
g_lFIFOCount -= _nSize;
assert (g_lFIFOCount >= 0);
ReleaseMutex( hMutex_FIFOCount );
}
*/
/***** Treat Message *****/
BOOL fn_b_OpenGLThreadTreatMessage(UINT _message, WPARAM _wParam, LPARAM _lParam)
{
GLboolean bResidence; // for glAreTexturesResident
long* pParam = (long*)_wParam;
switch (_message)
{
case OGLT0_WAIT :
SetEvent(hEvent_WaitForSynchro);
break;
case OGLT0_CREATE :
fn_OGLThread_vCreate();
break;
case OGLT0_RESUME :
fn_OGLThread_vResume();
break;
case OGLT0_SWAP :
fn_OGLThread_vSwap();
break;
case OGLT0_INITFLAGS :
fn_OGLThread_vInitOglFlags();
break;
case OGLT0_FLUSH :
M_OGL_ASSERT( glFinish (); )
M_OGL_ASSERT( glFlush(); )
break;
case OGLT0_ALPHATEST :
M_OGL_ASSERT( glAlphaFunc( GL_GREATER, 0.5f ); )
break;
case OGLT0_LOCKDEVICE :
fn_OGLThread_vLockDevice();
break;
case OGLT0_UNLOCKDEVICE :
fn_OGLThread_vUnlockDevice();
break;
case OGLT0_BLACKPOLY :
fn_OGLThread_vSendBlackPolygon();
break;
case OGLT0_FOGPARAM :
fn_OGLThread_vSetFogParams();
break;
/* 1Long */
case OGLT1_ENABLE :
M_OGL_ASSERT( glEnable( (GLenum)_wParam ); )
break;
case OGLT1_DISABLE :
M_OGL_ASSERT( glDisable( (GLenum)_wParam ); )
break;
case OGLT1_DEPTHMASK :
M_OGL_ASSERT( glDepthMask( (GLboolean)_wParam ); )
break;
case OGLT1_DELETETEXTURE :
M_OGL_ASSERT( glDeleteTextures(1, (GLuint*) &_wParam ); )
break;
case OGLT1_BINDTEXTURE :
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, (GLuint) _wParam ); )
break;
case OGLT1_TEXTUREENV :
M_OGL_ASSERT( glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, (GLuint) _wParam ); )
break;
case OGLT1_RENDER :
fn_OGLThread_vRender((GLI_tdScreenVertx*) _wParam );
break;
case OGLT1_LOADTEXTURES :
fn_OGLThread_vLoadTextures((GLI_tdstTexture*) _wParam );
break;
/* 2Long */
case OGLT2_PIXELTRANSFER :
M_OGL_ASSERT( glPixelTransferi( (GLenum)_wParam, (GLint)_lParam ); )
break;
case OGLT2_BLENDFUNC :
M_OGL_ASSERT( glBlendFunc( (GLenum)_wParam, (GLenum)_lParam ); )
break;
case OGLT2_WRITEBITMAP :
fn_OGLThread_vWrite16bBitmapToBackBuffer(_wParam, _lParam );
break;
case OGLT2_CLEARDEVICE :
fn_OGLThread_vClearDevice((_wParam & 2), (_wParam & 1), (unsigned long) _lParam);
break;
/* 3Long */
/* case OGLT3_CLEARDEVICE :
fn_OGLThread_vClearDevice((BOOL) M_GetParam(_wParam+0), (BOOL) M_GetParam(_wParam+1), (unsigned long) M_GetParam(_wParam+2));
fn_vFreeNLong(3);
break;
*/
/* return boolean value */
case OGLT1_ISTEXTURE :
M_OGL_ASSERT( pParam[0] = (long)glIsTexture( (GLuint)pParam[1] ); )
SetEvent(hEvent_WaitingForBoolean);
break;
case OGLT1_ISENABLED :
M_OGL_ASSERT( pParam[0] = (long)glIsEnabled( (GLenum)pParam[1] ); )
SetEvent(hEvent_WaitingForBoolean);
break;
case OGLT1_ISRESIDENT :
M_OGL_ASSERT( pParam[0] = (long)glAreTexturesResident( 1, (GLuint*) &pParam[1], &bResidence ); )
SetEvent(hEvent_WaitingForBoolean);
break;
default : // OGLT0_EXIT or else ?
return FALSE;
}
return TRUE;
}
/***** Thread Loop *****/
DWORD WINAPI fn_x_OpenGLThreadEntryPoint(LPVOID _p_vParameter)
{
MSG stMsg;
BOOL bNoExit;
_p_vParameter = _p_vParameter;
PeekMessage(&stMsg, NULL, WM_USER, WM_USER, PM_NOREMOVE); // to force the system to create the message queue
SetEvent(hEvent_ThreadCreation);
// message loop
while (bNoExit)
{
GetMessage(&stMsg, NULL, WM_USER, WM_USER + OGLT0_NB_MSG_MAX);
assert(stMsg.message >= WM_USER);
assert(stMsg.message <= WM_USER + OGLT0_NB_MSG_MAX);
bNoExit = fn_b_OpenGLThreadTreatMessage( stMsg.message - WM_USER, stMsg.wParam, stMsg.lParam );
}
return 0;
}
/***** Calling Functions *****/
#define M_v_RequestToOpenGLThread(_uiMessage, _WParam, _LParam)\
{\
/*PostThreadMessage(M_x_GetOpenGLThreadId(), WM_USER+_uiMessage, (WPARAM)0, (LPARAM)_Param);*/\
PostThreadMessage(M_x_GetOpenGLThreadId(), WM_USER+_uiMessage, (WPARAM)_WParam, (LPARAM)_LParam);\
}
void OGLThread_fn_vPostCmd(int _nCommandId)
{
M_v_RequestToOpenGLThread(_nCommandId, 0, 0);
}
void OGLThread_fn_vPostCmd_1Long(int _nCommandId, long _lParam1)
{
M_v_RequestToOpenGLThread(_nCommandId, _lParam1, 0);
}
void OGLThread_fn_vPostCmd_2Long(int _nCommandId, long _lParam1, long _lParam2)
{
M_v_RequestToOpenGLThread(_nCommandId, _lParam1, _lParam2);
}
/*
void OGLThread_fn_vPostCmd_3Long(int _nCommandId, long _lParam1, long _lParam2, long _lParam3)
{
long lParam;
lParam = fn_lMallocNLong(3);
M_GetParam(lParam+0) = _lParam1;
M_GetParam(lParam+1) = _lParam2;
M_GetParam(lParam+2) = _lParam3;
M_v_RequestToOpenGLThread(_nCommandId, lParam, 0);
}
*/
/* send command to thread then wait for the returning boolean value */
BOOL OGLThread_fn_bPostCmdAndWait(int _nCommandId, long _lParam1)
{
long pParam[2];
pParam[1] = _lParam1;
M_v_RequestToOpenGLThread(_nCommandId, pParam, 0);
WaitForSingleObject(hEvent_WaitingForBoolean, INFINITE); // reset event when return
return pParam[0];
}
/***** Create / Resume context *****/
void OGLThread_fn_vCreateContext(BOOL _bReinitDevice)
{
if (_bReinitDevice)
{
/* Create the rendering context and make it current */
OGLThread_fn_vWaitForSynchro();
OGLThread_fn_vPostCmd(OGLT0_CREATE);
}
/* render initialization */
OGLThread_fn_vWaitForSynchro();
OGLThread_fn_vPostCmd(OGLT0_INITFLAGS); //GLI_fn_vInitOglFlags();
OGLThread_fn_vWaitForSynchro();
}
void OGLThread_fn_vResumeContext(BOOL _bReinitDevice)
{
if (!_bReinitDevice)
return;
OGLThread_fn_vWaitForSynchro();
OGLThread_fn_vPostCmd(OGLT0_RESUME);
OGLThread_fn_vWaitForSynchro();
}
/***** create / terminate thread, events & mutexes *****/
void OGLThread_fn_vCreateThread(void)
{
hEvent_ThreadCreation = CreateEvent(NULL, TRUE, FALSE, NULL /*C_sz_ThreadCreationEvtName*/); // create event (nonsignaled state)
M_v_SetOpenGLThread( CreateThread( NULL, 0, fn_x_OpenGLThreadEntryPoint, NULL, 0, &M_x_GetOpenGLThreadId() ) );
SetPriorityClass(M_h_GetOpenGLThread(), HIGH_PRIORITY_CLASS);
WaitForSingleObject(hEvent_ThreadCreation, INFINITE); // wait for the event to be signaled
if (hEvent_ThreadCreation)
CloseHandle(hEvent_ThreadCreation);
hEvent_WaitingForBoolean = CreateEvent(NULL, FALSE, FALSE, C_sz_WaitingForBooleanEvtName); // create event (no manual-reset)
hEvent_WaitForSynchro = CreateEvent(NULL, FALSE, FALSE, C_sz_JustWaiting); // create event (no manual-reset)
/*
hMutex_FIFOCount = CreateMutex(NULL, FALSE, C_sz_CounterMutexName);
g_plFIFOStartPointer = (long*)GLI_MDRV_p_vTmpMalloc(FIFO_MEM_SIZE*sizeof(long));
g_lFIFOCurrentOffset = 0;
g_lFIFOCount = 0;
*/
}
void OGLThread_fn_vTerminateThread()
{
OGLThread_fn_vWaitForSynchro();
if (hEvent_WaitingForBoolean)
CloseHandle(hEvent_WaitingForBoolean); // ?
hEvent_WaitingForBoolean = NULL;
if (hEvent_WaitForSynchro)
CloseHandle(hEvent_WaitForSynchro); // ?
hEvent_WaitForSynchro = NULL;
/*
if (hMutex_FIFOCount)
CloseHandle(hMutex_FIFOCount); // ?
hMutex_FIFOCount = NULL;
if (g_plFIFOStartPointer)
GLI_MDRV_vTmpFree(g_plFIFOStartPointer);
g_plFIFOStartPointer = NULL;
*/
OGLThread_fn_vPostCmd(OGLT0_EXIT);
}
/***** synkronizazion *****/
void OGLThread_fn_vWaitForSynchro()
{
OGLThread_fn_vPostCmd(OGLT0_WAIT);
WaitForSingleObject(hEvent_WaitForSynchro, INFINITE); // wait for the event to be signaled
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
} //extern "C"
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

View File

@@ -0,0 +1,54 @@
#if defined (ERROR_TEST)
/*
extern GLenum g_oglError;
extern GLenum g_oglPrevError;
extern char g_oglErrorString[255];
extern int g_oglErrorCount;
extern LPVOID g_lpMsgBuf;
*/
extern void fn_vOutputLog(char* ErrorString);
extern void fn_vOglError(char* oglFunc);
extern void fn_vError();
#define M_OUTPUT OutputDebugString
//#define M_OUTPUT fn_vOutputLog
#define M_OGL_ASSERT(oglFunc) \
{\
/*M_OUTPUT(#oglFunc);\
M_OUTPUT("\n");*/\
oglFunc\
fn_vOglError(#oglFunc);\
}
#define M_ASSERT(Func) \
{\
/*M_OUTPUT(#Func);\
M_OUTPUT("\n");*/\
if (!Func)\
{\
fn_vError();\
M_OUTPUT(#Func);\
M_OUTPUT("\n");\
}\
}
#define M_OGL_ASSERT_FAKE(oglFunc) \
{\
/*M_OUTPUT(#oglFunc);\
M_OUTPUT("\n");*/\
oglFunc\
}
//#define M_OGL_ASSERT_FAKE M_OGL_ASSERT
#else // ERROR_TEST
#define M_OGL_ASSERT_FAKE(oglFunc) oglFunc
#define M_OGL_ASSERT(oglFunc) oglFunc
#define M_ASSERT(Func) Func;
#define M_OUTPUT(str)
#endif // ERROR_TEST

View File

@@ -0,0 +1,62 @@
/* Testing Errors */
//#define OGL_VER2_2 // OpenGL version 2.2
#if defined (_DEBUG)
#define ERROR_TEST
#endif
//#define OPENGL_3DFX
#if defined (OPENGL_3DFX)
#define WORKAROUNDBUG //Work around bug in mini drivers
#endif //defined (OPENGL_3DFX)
/* Perspective */
//#define Z_BUFFER // if not defined => W_BUFFER
#define PERSP_CORRECTION
#if !defined (Z_BUFFER)
//#define ACCURATE_DEPTH_BUFFER // if defined in Rayman2 => nothing drawn in the "second viewport"
#endif
/* Texture test (fail if not in video memory) */
#if defined (_DEBUG)
//#define TEX_TEST
#endif
/* MIPMAP */
#if !defined (OGL_VER2_2)
#define MIPMAP_DOWN_TO_1x1
#endif
//#define REINIT_DEVICE_ONSIZE
//#define IGNORE_TEXTUREWRAP // to keep TexParameters GL_TEXTURE_WRAP_S & GL_TEXTURE_WRAP_T to GL_REPEAT value (because rastering GL_CLAMP'ed textures costs a lot !)
//#define NO_MIPMAP_FOR_TRANSPARENT_TEX // bug on the ATI RAGE PRO harware rasterization pipe : bilinear filtering is very ugly on transparent textures, so it looks better without Mipmaping these textures (on the software rasterization pipe, it is ok)
#define NO_FOG
/* window creation */
//#define USE_DEVMODE
//#define USE_DDRAW
#if defined (USE_DDRAW)
#define FULL_SCREEN
#endif //USE_DDRAW
#define SIZABLE
/* locking backbuffer*/
#define INVERT_Y
#define USE_ALPHA

View File

@@ -0,0 +1,139 @@
/*
=======================================================================================
Name : OGL_Thread.h
Author : Bart
Description :
=======================================================================================
*/
/*
=======================================================================================
Include
=======================================================================================
*/
/* 1->13 : no param */
#define OGLT0_CREATE 1
#define OGLT0_RESUME 2
#define OGLT0_SWAP 3
//#define OGLT0_RENDER 4
//#define OGLT0_LOADTEXTURES 5
#define OGLT0_INITFLAGS 6
#define OGLT0_FLUSH 7
#define OGLT0_ALPHATEST 8
#define OGLT0_LOCKDEVICE 9
#define OGLT0_UNLOCKDEVICE 10
#define OGLT0_BLACKPOLY 11
#define OGLT0_WAIT 12
#define OGLT0_FOGPARAM 13
/* 31->38 : 1 param */
#define OGLT1_ENABLE 31
#define OGLT1_DISABLE 32
#define OGLT1_DEPTHMASK 33
#define OGLT1_DELETETEXTURE 34
#define OGLT1_BINDTEXTURE 35
#define OGLT1_TEXTUREENV 36
#define OGLT1_RENDER 37
#define OGLT1_LOADTEXTURES 38
/* 51->54 : 2 params */
#define OGLT2_PIXELTRANSFER 51
#define OGLT2_BLENDFUNC 52
#define OGLT2_WRITEBITMAP 53
#define OGLT2_CLEARDEVICE 54
/* 71->71 : 3 params */
//#define OGLT3_CLEARDEVICE 71
/* 81->83 : 1 param + 1 returned (boolean) value */
#define OGLT1_ISTEXTURE 81
#define OGLT1_ISENABLED 82
#define OGLT1_ISRESIDENT 83
/* 98->99 : specific */
#define OGLT0_EXIT 98
#define OGLT0_NB_MSG_MAX 99
/* Post OGL Commands in the thread message queue */
void OGLThread_fn_vPostCmd(int _CommandId);
void OGLThread_fn_vPostCmd_1Long(int _nCommandId, long _lParam1);
void OGLThread_fn_vPostCmd_2Long(int _nCommandId, long _lParam1, long _lParam2);
//void OGLThread_fn_vPostCmd_3Long(int _nCommandId, long _lParam1, long _lParam2, long _lParam3);
BOOL OGLThread_fn_bPostCmdAndWait(int _nCommandId, long _lParam1);
void OGLThread_fn_vCreateThread(void);
void OGLThread_fn_vTerminateThread();
void OGLThread_fn_vCreateContext(BOOL _bReinitDevice);
void OGLThread_fn_vResumeContext(BOOL _bReinitDevice);
void OGLThread_fn_vWaitForSynchro();
/* from OGL_Acces.c */
#if defined (Z_BUFFER)
//#define M_glVertex(x, y, w) glVertex4f( x, y, 1.0f/w, 1.0f )
#if defined (PERSP_CORRECTION)
#define M_glVertex(x, y, w) glVertex4f( x/w, y/w, 1.0f/(w*w), 1.0f/w )
#else
#define M_glVertex(x, y, w) glVertex4f( x, y, 1.0f/w, 1.0f )
#endif
#else // W_BUFFER
//#define M_glVertex(x, y, w) glVertex4f( x, y, 1.0f, w )
#if defined (PERSP_CORRECTION)
#define M_glVertex(x, y, w) glVertex4f( x/w, y/w, 1.0f, 1.0f/w )
#else
#define M_glVertex(x, y, w) glVertex4f( x, y, w, 1.0f )
#endif
#endif
/*
=======================================================================================
Vertex Access Macros
=======================================================================================
*/
// GET
#define GetX(a) a.sx
#define GetY(a) a.sy
#define GetZ(a) a.sz //a.rhw
#define GetPackedColor(a) a.color
#define GetPackedSpecular(a) a.specular
#define GetU(a) a.tu
#define GetV(a) a.tv
// SET
#define SetX(a,b) a.sx = b
#define SetY(a,b) a.sy = b
#define SetZ(a,b) a.sz = b //a.rhw
#define SetPackedColor(a,b) a.color = b
#define SetPackedSpecular(a,b) a.specular = b
#define SetU(a,b) a.tu = b
#define SetV(a,b) a.tv = b
#define SetU_Cpy(a,b) a.tu = b
#define SetV_Cpy(a,b) a.tv = b
typedef struct _GLI_tdScreenVertx {
float sx;
float sy;
float sz;
//float rhw;
unsigned long color;
unsigned long specular;
float tu;
float tv;
} GLI_tdScreenVertx;
/* end of OGL_Acces.c */

View File

@@ -0,0 +1,9 @@
SCC = This is a Source Code Control file
[OpenGL.dsp]
SCC_Aux_Path = "\\srvprojets-ma\Rayman4_DS\Versions\Rayman4DS\Tools"
SCC_Project_Name = "$/CPA/tempgrp/GliGlou/Drivers/OpenGL", SGMAAAAA
[OpenGL.mak]
SCC_Aux_Path = "\\srvprojets-ma\Rayman4_DS\Versions\Rayman4DS\Tools"
SCC_Project_Name = "$/CPA/tempgrp/GliGlou/Drivers/OpenGL", SGMAAAAA

View File

@@ -0,0 +1,162 @@
// GET
#define GetX(a) a.fX
#define GetY(a) a.fY
#define GetZ(a) a.fInvW
#define GetPackedColor(a) a.u32Colour
#define GetU(a) a.fUOverW
#define GetV(a) a.fVOverW
// SET
#define SetX(a,b) a.fX = b
#define SetY(a,b) a.fY = b
#define SetZ(a,b) a.fInvW = b
#define SetPackedColor(a,b) a.u32Colour = b
#define SetPackedSpecular(a,b) a.u32Specular = b
#define SetU(a,b) a.fUOverW = b
#define SetV(a,b) a.fVOverW = b
#define SetU_Cpy(a,b) *(unsigned long *)&a.fUOverW = *(unsigned long *)&b
#define SetV_Cpy(a,b) *(unsigned long *)&a.fVOverW = *(unsigned long *)&b
// Fond de roulement SGL2
#define GLI_C_SGL2lMaxTriBuffer 512
#define GLI_C_SGL2lMaxVertBuffer GLI_C_SGL2lMaxTriBuffer * 3L
long GLI_glActualSizeOfVertex;
#define GLI_tdScreenVertx SGLVERTEX
SGLVERTEX aDEFCurrentDestXYZ[GLI_C_SGL2lMaxVertBuffer];
SGLVERTEX *CurrentDestXYZ;
extern SGLCONTEXT SGLContext;
extern SGLCONTEXT2 SGLContext2;
#define GLI_M_RestoreCW()
void GLI_BeforeDraw()
{
CurrentDestXYZ = aDEFCurrentDestXYZ;
GLI_glActualSizeOfVertex = 0;
};
void GLI_AfterDraw()
{
CurrentDestXYZ = aDEFCurrentDestXYZ;
if (GLI_glActualSizeOfVertex != 0)
sgltri_triangles(&SGLContext , GLI_glActualSizeOfVertex , NULL , CurrentDestXYZ);
GLI_glActualSizeOfVertex = 0;
}
void GLI_DrawQuad(void)
{
/* add 2 triangles */
CurrentDestXYZ[5] = CurrentDestXYZ[3];
CurrentDestXYZ[4] = CurrentDestXYZ[2];
CurrentDestXYZ[3] = CurrentDestXYZ[0];
if (GLI_glActualSizeOfVertex > GLI_C_SGL2lMaxTriBuffer - 4)
{
CurrentDestXYZ = aDEFCurrentDestXYZ;
sgltri_triangles(&SGLContext , GLI_glActualSizeOfVertex + 2, NULL , CurrentDestXYZ);
GLI_glActualSizeOfVertex = 0;
} else
{
CurrentDestXYZ += 6;
GLI_glActualSizeOfVertex+=2;
}
}
// Draw
GLI_FuncNodeBegin(GLI_vDrawTriangle)
{
/* draw */
if (GLI_glActualSizeOfVertex > GLI_C_SGL2lMaxTriBuffer - 4)
{
CurrentDestXYZ = aDEFCurrentDestXYZ;
sgltri_triangles(&SGLContext , GLI_glActualSizeOfVertex + 1, NULL , CurrentDestXYZ);
GLI_glActualSizeOfVertex = 0;
} else
{
CurrentDestXYZ += 3;
GLI_glActualSizeOfVertex++;
}
}
void GLI_vDrawZSortedTriangle(void *p_3Point)
{
}
void GLI_vDrawZSortedQuad(void *p_3Point)
{
}
void GLI_vAddDrawFunc()
{
GLI_M_AddFunc(GLI_vDrawTriangle);
}
// GLI_BIG_GLOBALS -> lClippingModeMask
void GLI_ReComputeClippingMask()
{
*(float *)&fX_CMP_Optimize = 640.0f;
*(float *)&fY_CMP_Optimize = 480.0f;
*(float *)&fXMin_CLIP_Optimize = 100.0f;
*(float *)&fYMin_CLIP_Optimize = 50.0f;
*(float *)&fXMax_CLIP_Optimize = 540.0f;
*(float *)&fYMax_CLIP_Optimize = 430.0f;
}
//********************************************************************************************
// Name: GLI_DRV_vSendSpriteToClip
// Goal: draw a sprite
// Code: Philippe Vimont
// OPTIMMIZED : No
//********************************************************************************************
void GLI_DRV_vSendSpriteToClip
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_BeforeDraw();
GLI_M_InitSprite();
SetU(CurrentDestXYZ[0],0.0f);
SetV(CurrentDestXYZ[0],1.0f);
SetU(CurrentDestXYZ[1],1.0f);
SetV(CurrentDestXYZ[1],1.0f);
SetU(CurrentDestXYZ[2],1.0f);
SetV(CurrentDestXYZ[2],0.0f);
SetU(CurrentDestXYZ[3],0.0f);
SetV(CurrentDestXYZ[3],0.0f);
GLI_DrawQuad();
GLI_AfterDraw();
}
//********************************************************************************************
// Name: GLI_DRV_vSendSpriteToClipWithUV 1.0
// Goal:
// Code: Philippe Vimont / 1.0
// REM:
// OPTIMMIZED : No
//********************************************************************************************
void GLI_DRV_vSendSpriteToClipWithUV
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal *a8_stUVVertex,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_BeforeDraw();
GLI_M_InitSprite();
SetU(CurrentDestXYZ[2],a8_stUVVertex[4]);
SetV(CurrentDestXYZ[2],a8_stUVVertex[4+1]);
SetU(CurrentDestXYZ[3],a8_stUVVertex[6]);
SetV(CurrentDestXYZ[3],a8_stUVVertex[6+1]);
SetU(CurrentDestXYZ[0],a8_stUVVertex[0]);
SetV(CurrentDestXYZ[0],a8_stUVVertex[0+1]);
SetU(CurrentDestXYZ[1],a8_stUVVertex[2]);
SetV(CurrentDestXYZ[1],a8_stUVVertex[2+1]);
GLI_DrawQuad();
GLI_AfterDraw();
}

View File

@@ -0,0 +1,336 @@
/******************************************************************************************
FILE : CLIPDomat.C
VERS : 1.00 \ Marc Villemain - version directX5
0.00 \ Philippe Vimont
DATE : 15.05.97
Select materials
*******************************************************************************************/
#include <SGL2.h>
#include "Gli_st.h"
#include "GLI_Defn.h"
#include "polygon.h"
#include "mater_st.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "ScrVert.h"
#include "Liste.h"
#include "SelecTex.h"
#include "watrplan.h"
#include "proj.h"
#include "vpt3D.h"
#include "camera.h"
#include "material.h"
#include "texture.h"
#include "GLI_interface.h"
#include "GliBench.h"
extern SGLCONTEXT SGLContext;
extern SGLCONTEXT2 SGLContext2;
extern SGLVERTEX aDEFCurrentDestXYZ[];
extern SGLVERTEX *CurrentDestXYZ;
extern sgl_intermediate_map SGL2_IM_sPecialtexture;
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef ZARMA
}
#endif
//extern long GLD_RenderingCounter;
extern int stSpecialTexture;
//********************************************************************************************
// Name: GLI_vDoTextureSelection
// Goal:
// Code: Philippe Vimont
// OPTIMMIZED : No
//********************************************************************************************
//KMSURFACEDESC stSpecialTexture;
short VignetteBuffer[1024L * 1024L];
#define SGL2_ChangeRenderingParrametter(a,b,c)\
{\
if (SGLContext.a != b)\
{\
SGLContext.a = b;\
SGLContext.u32Flags |= c;\
}\
}\
// if (SGLContext2.a != b)
#define SGL2_ChangeRenderingParrametterC2(a,b,c)\
{\
{\
SGLContext.u32Flags |= SGLTT_DIRECT_EXTENSIONS;\
SGLContext2.a = b;\
SGLContext2.u32Flags |= c;\
}\
}\
void GLI_BigInitSGL2Rendering(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
SGLContext2.u32Flags = 0;
SGLContext2.n32DeviceName = 0;
SGLContext2.u32BlendCntl = 0;
SGLContext2.eDepthCntl = sgl_zcomp_lessequal;
SGLContext2.fShadowScaling = 0.0f;
SGLContext2.fVertexFogR = 1.0f;
SGLContext2.fVertexFogG = 1.0f;
SGLContext2.fVertexFogB = 1.0f;
SGLContext.pSGLContext2 = &SGLContext2;
SGLContext.bFogOn = FALSE;
SGLContext.bCullBackfacing = FALSE;
SGLContext.bDoClipping = TRUE;
SGLContext.cBackgroundColour[0] = 0.0f;
SGLContext.cBackgroundColour[1] = 0.0f;
SGLContext.cBackgroundColour[2] = 0.0f;
SGLContext.eShadowLightVolMode = NO_SHADOWS_OR_LIGHTVOLS;
SGLContext.bFlipU = FALSE;
SGLContext.bFlipV = FALSE;
SGLContext.bDoUVTimesInvW = TRUE;
SGLContext.RenderRegions = 0;
SGLContext.n32MipmapOffset = -1;
SGLContext.u32GlobalTrans = 0x000000;
SGLContext.eFilterType = sgl_tf_bilinear;
SGLContext.u32Flags = SGLTT_TEXTURE | SGLTT_GOURAUD | SGLTT_DIRECT_EXTENSIONS;
SGL2_ChangeRenderingParrametterC2(eTextureBlend,sgl_stb_texascale,SGLTT2_TEXTUREBLEND);
}
void GLI_INTERFACE_FUNC(GLI_vDoTextureSelection)(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
static bFirst = 1;
if (*GLD_p_lRenderingCounter != p_stGlobaleMT->GLD_RenderingCounter)
{
p_stGlobaleMT->GLD_RenderingCounter = *GLD_p_lRenderingCounter;
}
if (bFirst)
{
GLI_BigInitSGL2Rendering(p_stGlobaleMT);
}
bFirst = 0;
SGLContext.u32Flags = SGLTT_DIRECT_EXTENSIONS;
SGLContext2.u32Flags = 0;
if (GLI_BIG_GLOBALS->xFogIsOn)
{
// FOG ON
if ( GLI_BIG_GLOBALS->p_stLastComputedFog != GLI_BIG_GLOBALS->p_stActiveFog )
{
GLI_vSetFogParams( GLI_BIG_GLOBALS->p_stActiveFog );
GLI_BIG_GLOBALS->p_stLastComputedFog = GLI_BIG_GLOBALS->p_stActiveFog;
}
SGLContext.bFogOn = TRUE;
}
else
{
// FOG OFF
SGLContext.bFogOn = FALSE;
}
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsTestingBackface)
{
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lNotInvertBackfaces)
{
// Backface Clock wize
}
else
{
// Backface CCW
}
}
else
{
//no backface
}
/* if (GLI_BIG_GLOBALS->lAMirrorIsDetected & 2)
{
// Use computed texture.
}
else*/
{
if ((p_stGlobaleMT -> p_stCurrentTexture != NULL) && (p_stGlobaleMT -> p_stCurrentTexture -> bIsAvailable))
{
// texture gouraud Rendering ww
SGLContext.u32Flags |= SGLTT_TEXTURE | SGLTT_GOURAUD | SGLTT_MIPMAPOFFSET;
SGLContext2.u32Flags = 0;
SGLContext.nTextureName = *(int *)&p_stGlobaleMT -> p_stCurrentTexture -> p_stSpecParam;
if ((!(p_stGlobaleMT->lAMirrorIsDetected & 2)) &&
((p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTexture | GLI_C_lNZTexture | GLI_C_lAddTransparencyTexture) )
|| ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))))
{
// Transparent polygone
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAddTransparencyTexture)
{
// Blendig ADD
// SGL2_ChangeRenderingParrametterC2(eTextureBlend,sgl_stb_texascale,SGLTT2_TEXTUREBLEND);
SGL2_ChangeRenderingParrametterC2(
u32BlendCntl,
sgl_blend_cntl(sgl_blend_one,sgl_blend_one,sgl_accum2_notused),
SGLTT2_BLENDCNTL);
// SGLContext2.u32Flags = SGLTT2_BLENDCNTL | SGLTT2_TEXTUREBLEND;
} else {
// Blending texture alpha
SGL2_ChangeRenderingParrametterC2(
u32BlendCntl,
sgl_blend_cntl(sgl_blend_srca,sgl_blend_invsrca,sgl_accum2_notused),
SGLTT2_BLENDCNTL);
}
} else
{
// No blending
SGL2_ChangeRenderingParrametterC2(
u32BlendCntl,
sgl_blend_cntl(sgl_blend_one,sgl_blend_zero,sgl_accum2_notused),
SGLTT2_BLENDCNTL);
}
SGLContext2.u32Flags &= 0xffffffff - SGLTT2_CLAMPU - SGLTT2_CLAMPV;
switch (p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode)
{
case GLI_C_lCylingUV:
// No Cycling
break;
case 0:
// Cycling UV
SGLContext.u32Flags |= SGLTT_DIRECT_EXTENSIONS;
SGLContext2.u32Flags |= SGLTT2_CLAMPU | SGLTT2_CLAMPV;
break;
case GLI_C_lCylingV:
// Cycling V (yes, V , a little mistake)
SGLContext.u32Flags |= SGLTT_DIRECT_EXTENSIONS;
SGLContext2.u32Flags |= SGLTT2_CLAMPV ;
break;
case GLI_C_lCylingU:
// Cycling U
SGLContext.u32Flags |= SGLTT_DIRECT_EXTENSIONS;
SGLContext2.u32Flags |= SGLTT2_CLAMPU;
break;
}
} else //*/
{
// Gouraud rendering
SGLContext.u32Flags = SGLTT_GOURAUD /*| SGLTT_DIRECT_EXTENSIONS*/;
SGLContext2.u32Flags = 0;
}
}
// This value is ignored if the SGLTT_GLOBALTRANS
// flag is not set.
if ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))
{
// Alpha blending
SGL2_ChangeRenderingParrametter(u32GlobalTrans,(unsigned long)(p_stGlobaleMT->xGlobalAlpha * 255.0f),SGLTT_GLOBALTRANS);
} else {
// No blending
}
// SGLContext.u32Flags |= SGLTT_HIGHLIGHT;
/* SGLContext.u32Flags |= SGLTT_DIRECT_EXTENSIONS;
SGLContext.u32Flags |= SGLTT_VERTEXFOG;
SGLContext2.u32Flags |= SGLTT2_VERTEXFOGCOLOUR;
SGLContext2.fVertexFogR = 0.0f;
SGLContext2.fVertexFogG = 1.0f;
SGLContext2.fVertexFogB = 0.0f;*/
}
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
extern void GLI_fnSwitchTwiddled(short *p_Texture , long size );
//extern KMVERTEXBUFFDESC VertexBufferDesc;
void GLI_vWaitEndOfRendering();
void GLI_vWaitEndOfVertexTransfert();
void GLI_vWaitEndOfVSync();
short VigDifferences[4];
void GLI_DRV_vWrite16bBitmapToBackBuffer( void *_p_vSourceBuffer, long _lWidth, long _lHeight, long _lDestLeft, long _lDestTop, long _lDestRight, long _lDestBottom )
{
SGLVERTEX gld_CurrentDestXYZ[4];
static bFirst = 0;
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT;
p_stGlobaleMT = GLI_BIG_GLOBALS;
if (!bFirst)
{
GLI_BigInitSGL2Rendering(p_stGlobaleMT);
}
bFirst++;
// if ((bFirst & 0x1F)== 0 ) // == QUADRUPLE SPEED!!
{
// sgl_intermediate_map SGL2_IM;
/* GLI_vWaitEndOfVSync();
GLI_vWaitEndOfRendering();*/
memset(&SGL2_IM_sPecialtexture , 0 , sizeof (sgl_intermediate_map));
GLD_MDRV_vBlitStretched16b( 512,480,VignetteBuffer ,512,_lWidth,_lHeight,_p_vSourceBuffer);
SGL2_IM_sPecialtexture . pixels = (void *)VignetteBuffer;
GLI_fnSwitchTwiddled(VignetteBuffer , 512 );
// sgl_preprocess_texture( sgl_map_rgb_565 , sgl_map_512x512 ,0,0,&SGL2_IM_sPecialtexture ,NULL ,&SGL2_IM);
sgl_set_texture( stSpecialTexture,FALSE,FALSE,&SGL2_IM_sPecialtexture,NULL);
}//*/
// GLI_vWaitEndOfVSync();
SGLContext.u32Flags |= SGLTT_TEXTURE | SGLTT_GOURAUD;
SGLContext2.u32Flags = 0;
SGLContext.nTextureName = stSpecialTexture;
SGL2_ChangeRenderingParrametterC2(
u32BlendCntl,
sgl_blend_cntl(sgl_blend_one,sgl_blend_zero,sgl_accum2_notused),
SGLTT2_BLENDCNTL);
// return;
/* ------------------------ BEURK ---------------------------------*/
/* ------------------------ End BEURK ------------------------------*/
gld_CurrentDestXYZ[0] . fX = 0.0f;
gld_CurrentDestXYZ[0] . fY = 0.0f;
gld_CurrentDestXYZ[1] . fX = 0.0f;
gld_CurrentDestXYZ[1] . fY = 480.0f;
gld_CurrentDestXYZ[2] . fX = 640.0f;
gld_CurrentDestXYZ[2] . fY = 480.0f;
gld_CurrentDestXYZ[3] . fX = 640.0f;
gld_CurrentDestXYZ[3] . fY = 0.0f;
gld_CurrentDestXYZ[0] . fUOverW = 0.0f;
gld_CurrentDestXYZ[0] . fVOverW = 0.0f;
gld_CurrentDestXYZ[1] . fUOverW = 0.0f;
gld_CurrentDestXYZ[1] . fVOverW = 0.9375f;
gld_CurrentDestXYZ[2] . fUOverW = 1.0f;
gld_CurrentDestXYZ[2] . fVOverW = 0.9375f;
gld_CurrentDestXYZ[3] . fUOverW = 1.0f;
gld_CurrentDestXYZ[3] . fVOverW = 0.0f;
gld_CurrentDestXYZ[0].u32Colour =
gld_CurrentDestXYZ[1].u32Colour =
gld_CurrentDestXYZ[2].u32Colour =
gld_CurrentDestXYZ[3].u32Colour = 0xffffffff;
gld_CurrentDestXYZ[0] . fInvW =
gld_CurrentDestXYZ[1] . fInvW =
gld_CurrentDestXYZ[2] . fInvW =
gld_CurrentDestXYZ[3] . fInvW = 0.01f;
sgltri_quads ( &SGLContext , 1 , NULL , gld_CurrentDestXYZ );
}
void GLI_INTERFACE_FUNC(GLI_vSetFogParams) ( tdstFogParams *_p_stFogParams )
{
SGL_FOG GLI_SGLFog;
GLI_SGLFog.w_start = 0.5f * GLI_C_xZClippingNear / _p_stFogParams->xDepthStart;
GLI_SGLFog.w_end = 0.5f * GLI_C_xZClippingNear / _p_stFogParams->xDepthEnd;
GLI_SGLFog.fog_density = _p_stFogParams->xBlendEnd / 255.0f;
SGLContext.fFogR = _p_stFogParams->stColor.xR;
SGLContext.fFogG = _p_stFogParams->stColor.xG;
SGLContext.fFogB = _p_stFogParams->stColor.xB;
sgl_linear_fog(&GLI_SGLFog);
}
#ifdef __cplusplus
} //extern "C"
#endif

View File

@@ -0,0 +1,248 @@
/*
Tested with LINT
*/
/**************
TEXTURE.C
Ver 1.0
***************/
#include "GLD.h"
#include "GEO.h"
#include "TEX.h"
#include "gli_st.h"
#include "textu_st.h"
#include "texture.h"
#include <string.h>
#ifdef SGL2
#include <SGL2.h>
#endif
#include "GLI_interface.h"
unsigned long ulTotalUsedMemory;
unsigned long ulAgpUsedMemory;
static long GLI_gs_lMaxTmuAvailable;
extern unsigned long GLI_gsCurrentMemoryChannel;
extern unsigned long gs_lRGBBitCount;
extern long gs_lTreeOfNamesNumberOfLastLetter;
extern long gs_lNumberOfTextureToCreate;
extern long gs_lLastIdxInDEFTableOfTextures;
extern long lNbTextureFormat;
extern long lCurrentTextureFormat;
//extern long gs_aDEFTableOfTextureMemoryChannels[ C_lMaxNumberOfTexture ];
extern unsigned char *gs_aCurrentTextures;
//extern GLI_tdstTexture *gs_aDEFTableOfTextureAlreadyRead [ C_lMaxNumberOfTexture ];
extern unsigned char g_ucGliModuleId;
//extern void *GLI_gs_p_ConvertBufferMipMapping;
short TEXTURETWIDDLED[1024L*1024L];
static unsigned long GLI_a256FastTwiddledTable[256];
long GLI_fnLinear2CasseTete(unsigned long lLinear , long lPitch)
{
unsigned long lreturnvalue = 0;
unsigned long CMPX = 1;
while (lLinear != 0)
{
if (lLinear & 128) lreturnvalue += CMPX<<3;
if (lLinear & 64) lreturnvalue += lPitch<<3;
if (lLinear & 32) lreturnvalue += CMPX<<2;
if (lLinear & 16) lreturnvalue += lPitch<<2;
if (lLinear & 8) lreturnvalue += CMPX<<1;
if (lLinear & 4) lreturnvalue += lPitch<<1;
if (lLinear & 2) lreturnvalue += CMPX;
if (lLinear & 1) lreturnvalue += lPitch;
CMPX<<=4;
lPitch<<=4;
lLinear >>= 8;
}
return lreturnvalue;
}
void GLI_InitTwiddlingTable(long largeur)
{
long i;
for (i = 0 ; i < 256 ; i++ )
GLI_a256FastTwiddledTable[i] = GLI_fnLinear2CasseTete(i, largeur);
}
void GLI_fnSwitchTwiddled(short *p_Texture , long size )
{
unsigned long xcounter, SizeXSize , SizeXSizeD8;
short *Pdest ;
unsigned long *GLI_a256FastTwiddledTableLocal;
static long largeur = 0;
short *p_TextureLocal,*p_DestLast;
Pdest = TEXTURETWIDDLED;
if (size != largeur)
{
GLI_InitTwiddlingTable(size);
largeur = size;
}
SizeXSize = size * size;
if (!(SizeXSize & 0xFF))
{
SizeXSizeD8 = SizeXSize >> 8;
for (xcounter = 0 ; xcounter < SizeXSizeD8 ; xcounter ++ )
{
p_TextureLocal = p_Texture + (GLI_a256FastTwiddledTable[xcounter & 0xFF]<<4);
p_TextureLocal += GLI_a256FastTwiddledTable[(xcounter>>8) & 0xFF]<<8;
p_DestLast = Pdest + 256;
GLI_a256FastTwiddledTableLocal = GLI_a256FastTwiddledTable;
while (Pdest < p_DestLast)
*(Pdest++)= *(p_TextureLocal + *(GLI_a256FastTwiddledTableLocal++));
}
}
else
{
xcounter = SizeXSize ;
for ( xcounter = 0 ; xcounter < SizeXSize ; xcounter++ )
*(Pdest++)= *(p_Texture +
GLI_a256FastTwiddledTable[xcounter & 0xFF] +
(GLI_a256FastTwiddledTable[(xcounter>>8) & 0xFF]<<4) +
(GLI_a256FastTwiddledTable[(xcounter>>16) & 0xFF]<<8));
}
memcpy( p_Texture, TEXTURETWIDDLED , SizeXSize<<1);
}
#ifdef SGL2
sgl_map_sizes GLI_GetSGL2EnumSize(unsigned long lSize)
{
switch (lSize)
{
case 8:return (sgl_map_8x8);
case 16:return (sgl_map_16x16);
case 32:return (sgl_map_32x32);
case 64:return (sgl_map_64x64);
case 128:return (sgl_map_128x128);
case 256:return (sgl_map_256x256);
case 512:return (sgl_map_512x512);
case 1024:return (sgl_map_1024x1024);
}
}
#endif
#ifdef SGL2
void GLI_DRV_vDownLoadTextures(long bRestore, long _lTextureMode, BOOL bReloading )
{
long lTextureCounter;
GLI_tdstTexture *p_stTexture;
sgl_mipmap_generation_options MipMapping;
long AddValue;
sgl_intermediate_map SGL2_IM;
memset(&SGL2_IM , 0 , sizeof (sgl_intermediate_map));
SGL2_IM . id[0] = 'I';
SGL2_IM . id[1] = 'M';
SGL2_IM . id[2] = 'A';
SGL2_IM . id[3] = 'P';
for (lTextureCounter = 0; lTextureCounter < GLI_C_lNBMaxOfTextures ; lTextureCounter ++)
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated )
{
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
while (p_stTexture != NULL)
{
p_stTexture -> bIsAvailable = 0;
GLI_MDRV_xLoadTextureInTexelField(p_stTexture, GLI_gs_p_ConvertBufferMipMapping);
AddValue = 0;
if (p_stTexture ->lNumberOfLod)
{
AddValue = sgl_map_mipmap_shift;
MipMapping = sgl_mipmap_generate_2x2;
}
else
MipMapping = sgl_mipmap_generate_none;
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
{
GLI_vInvertAlphaField(GLI_gs_p_ConvertBufferMipMapping , p_stTexture->lHeight * p_stTexture->lHeight);
SGL2_IM . pixels = GLI_gs_p_ConvertBufferMipMapping ;
SGL2_IM . y_dim = SGL2_IM . x_dim = p_stTexture->lHeight;
*(int *)&p_stTexture -> p_stSpecParam =
sgl_create_texture( sgl_map_argb_1555 + AddValue, GLI_GetSGL2EnumSize(p_stTexture->lHeight), MipMapping, FALSE , &SGL2_IM , NULL);
} else
{
if ((p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture) == 0)
{
SGL2_IM . pixels = GLI_gs_p_ConvertBufferMipMapping ;
SGL2_IM . y_dim = SGL2_IM . x_dim = p_stTexture->lHeight;
*(int *)&p_stTexture -> p_stSpecParam=
sgl_create_texture( sgl_map_rgb_565 + AddValue, GLI_GetSGL2EnumSize(p_stTexture->lHeight), MipMapping, FALSE , &SGL2_IM , NULL);
} else
{
GLI_vInvertAlphaField(GLI_gs_p_ConvertBufferMipMapping , p_stTexture->lHeight * p_stTexture->lHeight);
SGL2_IM . pixels = GLI_gs_p_ConvertBufferMipMapping ;
SGL2_IM . y_dim = SGL2_IM . x_dim = p_stTexture->lHeight;
*(int *)&p_stTexture -> p_stSpecParam=
sgl_create_texture( sgl_map_argb_4444 + AddValue, GLI_GetSGL2EnumSize(p_stTexture->lHeight), MipMapping ,FALSE, &SGL2_IM , NULL);
}
}
if (*(int *)&p_stTexture -> p_stSpecParam > 0)
{
p_stTexture->bIsAvailable = 1 ;
}
p_stTexture = NULL;
}
}
}
#endif
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
long GLI_DRV_lGetHardwareTotalTextureMemorySize(long _lTextureMode)
{
return (6388608L);
}
//********************************************************************************************
// Name: GLI_DRV_lGetHardwareMaxTextureSize() 1.0
// OPTIMMIZED : No
//********************************************************************************************
long GLI_DRV_lGetHardwareMaxTextureSize(void)
{
return (1024);
}
//********************************************************************************************
// Name: GLI_DRV_lIsHardwareAcceptNonSquaredTextures() 1.0
// OPTIMMIZED : No
//********************************************************************************************
long GLI_DRV_lIsHardwareAcceptNonSquaredTextures(void)
{
return (0);
}
void GLI_DRV_vUnLoadTextures()
{
long lTextureCounter;
GLI_tdstTexture *p_stTexture;
for ( lTextureCounter = 0 ; lTextureCounter < C_lMaxNumberOfTexture ;lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated )
{
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
if (p_stTexture != NULL)
{
if (p_stTexture->bIsAvailable)
{
sgl_delete_texture(*(int *)&p_stTexture -> p_stSpecParam);
p_stTexture->bIsAvailable = 0;
}
}
}
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@@ -0,0 +1,108 @@
/*
Tested with LINT
*/
#include <SGL2.H>
#include "init_gli.h"
#include "gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "GLI_interface.h"
int Device = 0;
SGLCONTEXT SGLContext;
SGLCONTEXT2 SGLContext2;
int stSpecialTexture;
sgl_intermediate_map SGL2_IM_sPecialtexture;
extern short TEXTURETWIDDLED[];
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
#ifdef __cplusplus
extern "C"
{
#endif
// Global initialisation.
void GLI_DRV_xInitDriver( HWND _hWnd, BOOL _bFullScreen, long _lWidth, long _lHeight, long _lBpp )
{
memset(&SGL2_IM_sPecialtexture , 0 , sizeof (sgl_intermediate_map));
SGL2_IM_sPecialtexture . id[0] = 'I';
SGL2_IM_sPecialtexture . id[1] = 'M';
SGL2_IM_sPecialtexture . id[2] = 'A';
SGL2_IM_sPecialtexture . id[3] = 'P';
SGL2_IM_sPecialtexture . pixels = TEXTURETWIDDLED;
SGL2_IM_sPecialtexture . y_dim = SGL2_IM_sPecialtexture . x_dim = 512;
Device = sgl_create_screen_device (0, 640, 480, sgl_device_16bit, sgl_double_buffer);
stSpecialTexture =
sgl_create_texture( sgl_map_rgb_565 , sgl_map_512x512 , FALSE , FALSE , &SGL2_IM_sPecialtexture , NULL);
}
// Temporary function.
/*
long GLI_INTERFACE_FUNC(GLI_DRV_lWhatIsGli)(void)
{
return GLI_C_VersionGlide;
}
*/
void GLI_DRV_vCloseDriver ()
{
}
// Return version number.
/*
long GLI_INTERFACE_FUNC(GLI_lGetNumOfVersion)(void)
{
return 0;//g_stCurLLInterface.iMode;
}
*/
// Return a pointer on the text version of GLI engine.
/*unsigned char *GLI_INTERFACE_FUNC(GLI_ucGetTextOfVersion)(void)
{
return NULL;//g_stCurLLInterface.ucTextMode;
}
*/
// Erase a rectangular region of Z buffer.
void GLI_INTERFACE_FUNC(GLI_DRV_vClearZBufferRegion)(long lXStart,long lXEnd,long lYStart,long lYEnd)
{
if (!bDrawMirrorSymetric)
GLI_BIG_GLOBALS->lDisplayMenuIsDetected = 1;
}
void GLI_INTERFACE_FUNC(GLI_vBeginDrawingTexturedMirrors)(void)
{
GLI_BIG_GLOBALS->bDrawMirrorSymetric = 1;
}
void GLI_INTERFACE_FUNC(GLI_vBeginDrawingTexturedMirrorsSurfaces)()
{
GLI_BIG_GLOBALS->lAMirrorIsDetected = 3;
}
void GLI_INTERFACE_FUNC(GLI_vEndDrawingTexturedMirrors)()
{
GLI_BIG_GLOBALS->lAMirrorIsDetected &= 1;
GLI_BIG_GLOBALS->bDrawMirrorSymetric = 0;
}
//extern long GLI_xIsGliInit();
void GLI_INTERFACE_FUNC(GLI_DRV_vFlipDevice)(long lNbFrames)
{
if (!GLI_MDRV_xIsGliInit())
return;
GLI_BIG_GLOBALS->lDisplayMenuIsDetected = 0;
GLI_BIG_GLOBALS->lAMirrorIsDetected = 0;
sgltri_render (&SGLContext);
sgltri_startofframe (&SGLContext);
}
void GLI_INTERFACE_FUNC(GLI_DRV_vClearDevice)(BOOL ZBuffer, BOOL ColorBuffer, unsigned long Color)
{
}
#ifdef __cplusplus
} //extern "C"
#endif

View File

@@ -0,0 +1,199 @@
/*
Tested with LINT
*/
#define MTH_LOW
#include"gli_st.h"
#include "GLI_Defn.h"
#include "vertex.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "camera.h"
#include "dllcom.h"
#ifdef __cplusplus
extern "C"
{
#endif
void GLI_DRV_vAddScrZ()
{
GLI_tdScreenVertx *pFirst , *pLast;
pFirst = GLI_ScreenVertices;
pLast = pFirst + GLI_BIG_GLOBALS->p_stObj->xNbPoints ;
for ( ; pFirst < pLast ; pFirst++)
PSetZ(pFirst, (PGetZ(pFirst) + 0.0001f));
}
void GLI_DRV_vMulScrZ()
{
GLI_tdScreenVertx *pFirst , *pLast;
pFirst = GLI_ScreenVertices;
pLast = pFirst + GLI_BIG_GLOBALS->p_stObj->xNbPoints ;
for ( ; pFirst < pLast ; pFirst++)
PSetZ(pFirst, (PGetZ(pFirst) * 30.0f));
}
/**********************************************************************************************/
/* Name: GLI_xSerialDotProduct */
/* Goal: */
/* Code: Philippe Vimont / 1.0*/
/* OPTIMMIZED : Is also in assembly pentium*/
/**********************************************************************************************/
static _inline void
GLI_xSerialDotProduct (long lNbOfVertex ,MTH3D_tdstVector *p_stSource ,float *p_stDest ,MTH3D_tdstVector *p_stMultiplicator, long lIncrement)
{
long lVertexIndex ;
for ( lVertexIndex = 0 ; lVertexIndex < lNbOfVertex ; lVertexIndex ++ , p_stSource++,p_stDest ++)
*p_stDest = MTH_M_xRealToFloat ( MTH3D_M_xDotProductVector( p_stSource,p_stMultiplicator) ) ;
}
void
GLI_DRV_vSerialLinearProjZClip ( GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BG )
{
GLI_tdstAligned3DVector *p_stDest;
GLI_tdstAligned3DVector *p_stLastDest;
GLI_tdstAligned2DVector *p_st2DDest;
GLI_tdScreenVertx *p_stScrDest;
MTH3D_tdstVector stX,stY,stZ,stTrans;
float fSwapValue,fScaleX,fScaleY;
MTH3D_tdstVector *p_stSource ;
long lNewX;
*(float * )&lNewX = 8000.0f;
fScaleX = GLI_BG -> p_stCurrentCamera -> xScreen * GLI_BG -> p_stCurrentCamera -> stScale . xX ;
fScaleY = GLI_BG -> p_stCurrentCamera -> xScreen * GLI_BG -> p_stCurrentCamera -> stScale . xY ;
POS_MDRV_vGetTransformMatrix( &GLI_BG -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix , &stX , &stY , &stZ);
GLI_M_SWAP (stX.xY,stY.xX);
GLI_M_SWAP (stX.xZ,stZ.xX);
GLI_M_SWAP (stY.xZ,stZ.xY);
POS_MDRV_vGetTranslationVector (&GLI_BG->gs_st_CurrentMatrixMultiplyedWithCameraMatrix , &stTrans);
p_stDest = GLI_BG -> GLI_TurnedScaledDisplecedPoint;
p_st2DDest = GLI_BG->GLI_ScreenPoint;
p_stScrDest = GLI_ScreenVertices;
p_stSource = GLI_BG->p_stObj->d_stListOfPoints ;
p_stLastDest = p_stDest + GLI_BG -> p_stObj -> xNbPoints;
for ( ; p_stDest < p_stLastDest ; p_stDest ++ , p_stSource++ , p_st2DDest++ , p_stScrDest++)
{
float fTmpZ;
p_stDest->xZ = MTH3D_M_xDotProductVector ( &stZ , p_stSource ) + stTrans . xZ;
p_stDest->xX = MTH3D_M_xDotProductVector ( &stX , p_stSource ) + stTrans . xX;
p_stDest->xY = MTH3D_M_xDotProductVector ( &stY , p_stSource ) + stTrans . xY;
if ( *(long *)&p_stDest->xZ < *(long *)&GLI_BG -> p_stCurrentCamera -> xNear)
{
float tmpFloat;
*(long *)&p_st2DDest -> xOoZ |= 0x80000000;
*((unsigned long *)&p_st2DDest ->xX) = lNewX | ((*((unsigned long *)&p_stDest->xX) & 0x80000000) ^ 0x80000000);
*((unsigned long *)&p_st2DDest ->xY) = lNewX | ((*((unsigned long *)&p_stDest->xY) & 0x80000000) ^ 0x80000000);
*((unsigned long *)&tmpFloat) = lNewX | ((*((unsigned long *)&p_stDest->xX) & 0x80000000) ^ 0x80000000);
PSetX(p_stScrDest, tmpFloat);
*((unsigned long *)&tmpFloat) = lNewX | ((*((unsigned long *)&p_stDest->xY) & 0x80000000) ^ 0x80000000);
PSetY(p_stScrDest, tmpFloat);
*((unsigned long *)&tmpFloat) = (0x80000000 | *(unsigned long*) &(PGetZ(p_stScrDest)));
PSetZ(p_stScrDest, tmpFloat);
continue ;
}
/* fTmpZ = MTH_M_xInvLow(p_stDest->xZ);*/
fTmpZ = 1.0f / p_stDest->xZ;
PSetX(p_stScrDest, GLI_BG->p_stCurrentCamera->stTrans.xX + p_stDest->xX * fScaleX * fTmpZ);
PSetY(p_stScrDest, GLI_BG->p_stCurrentCamera->stTrans.xY + p_stDest->xY * fScaleY * fTmpZ);
PSetZ(p_stScrDest, fTmpZ * GLI_BG->p_stCurrentCamera->xNear);
p_st2DDest->xX = GLI_BG -> p_stCurrentCamera -> stTrans . xX + p_stDest -> xX * fScaleX * fTmpZ;
p_st2DDest->xY = GLI_BG -> p_stCurrentCamera -> stTrans . xY + p_stDest -> xY * fScaleY * fTmpZ;
p_st2DDest->xOoZ = fTmpZ * GLI_BG -> p_stCurrentCamera -> xNear ;
}
}
void
GLI_DRV_vSerialLinearProjNoZClip ( GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BG )
{
GLI_tdstAligned3DVector *p_stDest;
GLI_tdstAligned3DVector *p_stLastDest;
GLI_tdstAligned2DVector *p_st2DDest;
GLI_tdScreenVertx *p_stScrDest;
MTH3D_tdstVector stX,stY,stZ,stTrans;
float fSwapValue,fScaleX,fScaleY;
MTH3D_tdstVector *p_stSource ;
fScaleX = GLI_BG -> p_stCurrentCamera->xScreen * GLI_BG -> p_stCurrentCamera -> stScale . xX ;
fScaleY = GLI_BG -> p_stCurrentCamera->xScreen * GLI_BG -> p_stCurrentCamera -> stScale . xY ;
POS_MDRV_vGetTransformMatrix (&GLI_BG->gs_st_CurrentMatrixMultiplyedWithCameraMatrix , &stX , &stY , &stZ);
GLI_M_SWAP (stX.xY,stY.xX);
GLI_M_SWAP (stX.xZ,stZ.xX);
GLI_M_SWAP (stY.xZ,stZ.xY);
POS_MDRV_vGetTranslationVector (&GLI_BG->gs_st_CurrentMatrixMultiplyedWithCameraMatrix, &stTrans);
p_stDest = GLI_BG -> GLI_TurnedScaledDisplecedPoint;
p_st2DDest = GLI_BG -> GLI_ScreenPoint;
p_stScrDest = GLI_ScreenVertices;
p_stSource = GLI_BG -> p_stObj->d_stListOfPoints ;
p_stLastDest = p_stDest + GLI_BG -> p_stObj -> xNbPoints;
for ( ; p_stDest < p_stLastDest ; p_stDest ++ , p_stSource++ , p_st2DDest++ , p_stScrDest++)
{
float fTmpZ;
p_stDest->xZ = MTH3D_M_xDotProductVector ( &stZ , p_stSource ) + stTrans . xZ;
p_stDest->xX = MTH3D_M_xDotProductVector ( &stX , p_stSource ) + stTrans . xX;
p_stDest->xY = MTH3D_M_xDotProductVector ( &stY , p_stSource ) + stTrans . xY;
/* fTmpZ = MTH_M_xInvLow(p_stDest->xZ);*/
fTmpZ = 1.0f / p_stDest->xZ;
/* TODO: don't copy this information*/
PSetX(p_stScrDest, GLI_BG->p_stCurrentCamera->stTrans.xX + p_stDest -> xX * fScaleX * fTmpZ);
PSetY(p_stScrDest, GLI_BG->p_stCurrentCamera->stTrans.xY + p_stDest -> xY * fScaleY * fTmpZ);
PSetZ(p_stScrDest, fTmpZ * GLI_BG->p_stCurrentCamera->xNear );
p_st2DDest -> xX = GLI_BG->p_stCurrentCamera->stTrans.xX + p_stDest -> xX * fScaleX * fTmpZ;
p_st2DDest -> xY = GLI_BG->p_stCurrentCamera->stTrans.xY + p_stDest -> xY * fScaleY * fTmpZ;
p_st2DDest -> xOoZ = fTmpZ * GLI_BG->p_stCurrentCamera->xNear ;
}
}
/* STM- this function is currently broken, but not used.*/
/* if we add water plane effects we'll have to fix this function to write to */
/* GLI_ScreenVertices*/
#if 0
void GLI_xNewSerialProjOp ( GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BG )
{
GLI_tdstAligned3DVector *p_stDest;
GLI_tdstAligned3DVector *p_stLastDest;
GLI_tdstAligned2DVector *p_st2DDest;
float /*fSwapValue,*/fScaleX,fScaleY;
long lNewX;
*(float * )&lNewX = 8000.0f;
fScaleX = GLI_BG -> p_stCurrentCamera -> xScreen * GLI_BG -> p_stCurrentCamera -> stScale . xX ;
fScaleY = GLI_BG -> p_stCurrentCamera -> xScreen * GLI_BG -> p_stCurrentCamera -> stScale . xY ;
p_stDest = GLI_BG -> GLI_TurnedScaledDisplecedPoint;
p_st2DDest = GLI_BG -> GLI_ScreenPoint;
p_stLastDest = p_stDest + GLI_BG -> p_stObj -> xNbPoints;
if (GLI_BG -> lClippingModeMask & GLI_C_ClipMaskZ)
for ( ; p_stDest < p_stLastDest ; p_stDest ++ , p_st2DDest++ )
{
if ( *(long *)&p_stDest->xZ < *(long *)&GLI_BG -> p_stCurrentCamera -> xNear)
{
*(long *)&p_st2DDest -> xOoZ |= 0x80000000;
*((unsigned long *)&p_st2DDest ->xX) = lNewX | ((*((unsigned long *)&p_stDest->xX) & 0x80000000) ^ 0x80000000);
*((unsigned long *)&p_st2DDest ->xY) = lNewX | ((*((unsigned long *)&p_stDest->xY) & 0x80000000) ^ 0x80000000);
continue ;
}
p_st2DDest -> xOoZ = MTH_M_xInvLow(p_stDest -> xZ ) ;
p_st2DDest -> xX = GLI_BG -> p_stCurrentCamera -> stTrans . xX + p_stDest -> xX * fScaleX * p_st2DDest -> xOoZ ;
p_st2DDest -> xY = GLI_BG -> p_stCurrentCamera -> stTrans . xY + p_stDest -> xY * fScaleY * p_st2DDest -> xOoZ ;
p_st2DDest -> xOoZ *= GLI_BG -> p_stCurrentCamera -> xNear ;
}
else
for ( ; p_stDest < p_stLastDest ; p_stDest ++ , p_st2DDest++ )
{
p_st2DDest -> xOoZ = MTH_M_xInvLow(p_stDest -> xZ ) ;
p_st2DDest -> xX = GLI_BG -> p_stCurrentCamera -> stTrans . xX + p_stDest -> xX * fScaleX * p_st2DDest -> xOoZ ;
p_st2DDest -> xY = GLI_BG -> p_stCurrentCamera -> stTrans . xY + p_stDest -> xY * fScaleY * p_st2DDest -> xOoZ ;
p_st2DDest -> xOoZ *= GLI_BG -> p_stCurrentCamera -> xNear ;
}
}
#endif /* if 0*/
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@@ -0,0 +1,404 @@
/*
Tested with LINT
*/
#include <assert.h>
#include"gli_st.h"
#include "GLI_Defn.h"
#include "vertex.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "watrplan.h"
#include "camera.h"
#include "matstack.h"
#include "COL.h"
#include "gmt.h"
#define GLI_TSINTA 64
float a64_fSinTable[128];
extern long GLD_RenderingCounter;
long gs_lXBase;
long gs_lYBase;
static float GLI_fF2pow24;
static float GLI_gsWaterPlaneRefraction = 0.6f;
static float GLI_gsWaterPlaneDepthSizeOf2DMove = 2.0f;
static float GLI_gsWaterPlaneDepthStartOf2DMove = -1.0f;
long bWaterPlaneState;
MTH3D_tdstVector stWaterPlaneNormale;
MTH_tdxReal fWaterPlaneDistance;
MTH_tdxReal GLI_gsfWaterPlaneFogStart = 2.0f;
GLI_tdstColor GLI_gsfWaterPlaneFogColor ;
extern long TRYIT;
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
void GLI_vWaitEndOfRendering();
void GLI_vWaitEndOfVertexTransfert();
void GLI_vWaitEndOfVSync();
/*ANNECY VL04/03/98{*/
/*
* var for sinus effect
*/
MTH_tdxReal a3_xSinEffectBase[3];
long a3_lSinEffectFreq[3];
MTH3D_tdstVector stSinEffectAmp;
MTH3D_tdstVector stSinEffectVector;
MTH_tdxReal xSinusEffectDepthStart;
char g_cSinusEffectState;
char g_cSinusEffectFlag;
/*ENDANNECY VL}*/
/**********************************************************************************************/
/* Name: GLI_vSetWaterplane*/
/* Goal : Set The Plane For Water Effect*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : */
/**********************************************************************************************/
void GLI_vSetWaterplane(struct GLD_tdstViewportAttributes_ *p_stVpt,
MTH3D_tdstVector *p_stNormale,
MTH_tdxReal xDistance)
{
stWaterPlaneNormale = *p_stNormale;
fWaterPlaneDistance = xDistance;
}
/**********************************************************************************************/
/* Name: GLI_vSetWaterplaneRefraction*/
/* Goal : 0.0f is nothing, 1.0f is maximum*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : */
/**********************************************************************************************/
void GLI_vSetWaterplane2DMoveSize(MTH_tdxReal xSizeInPixels)
{
GLI_gsWaterPlaneDepthSizeOf2DMove = xSizeInPixels;
}
void GLI_vSetWaterplane2DMoveDepthStart(MTH_tdxReal xDepth)
{
GLI_gsWaterPlaneDepthStartOf2DMove = xDepth;
}
/**********************************************************************************************/
/* Name: GLI_vSetWaterplaneRefraction*/
/* Goal : 0.0f is nothing, 1.0f is maximum*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : */
/**********************************************************************************************/
void GLI_vSetWaterplaneRefraction(MTH_tdxReal xRefraction)
{
GLI_gsWaterPlaneRefraction = xRefraction;
}
/**********************************************************************************************/
/* Name: GLI_vSetWaterplaneOn*/
/* Goal : watrplane ON*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : */
/**********************************************************************************************/
void GLI_vSetWaterplaneOn()
{
bWaterPlaneState |= GLI_C_l2DPlaneIsEnable;
}
/**********************************************************************************************/
/* Name: GLI_vSetWaterplaneOff*/
/* Goal : No watrplane*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : */
/**********************************************************************************************/
void GLI_vSetWaterplaneOff()
{
bWaterPlaneState &= 0xffffffff - GLI_C_l2DPlaneIsEnable;
}
void GLI_vWaterplaneEnableRefraction()
{
bWaterPlaneState &= 0xffffffff - GLI_C_lWaterPlaneNoRefraction;
}
long GLI_vIsWaterplaneEnable(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobalsParrameters)
{
return ((bWaterPlaneState & GLI_C_l2DPlaneIsEnable));
}
void GLI_vWaterplaneDisableRefraction()
{
bWaterPlaneState |= GLI_C_lWaterPlaneNoRefraction;
}
void GLI_vWaterplaneEnable2DSinus()
{
bWaterPlaneState &= 0xffffffff - GLI_C_lWaterPlaneNoSinusMoves;
}
void GLI_vWaterplaneDisable2DSinus()
{
bWaterPlaneState |= GLI_C_lWaterPlaneNoSinusMoves;
}
void GLI_vWaterplaneEnableFog()
{
bWaterPlaneState &= 0xffffffff - GLI_C_lWaterPlaneNoFog ;
}
void GLI_vWaterplaneDisableFog()
{
bWaterPlaneState |= GLI_C_lWaterPlaneNoFog ;
}
/**********************************************************************************************/
/* Name: GLI_vFogWaterPlaneEffect*/
/* Goal : Make a Dpth */
/* Code: Philippe Vimont */
/* OPTIMMIZE : FINAL VERSION SHOULD BE IN ASSEMBLY*/
/**********************************************************************************************/
void
GLI_vFogWaterPlaneEffect(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobalsParrameters,long xStart,long xNumber)
{
float *p_xCounter,fOoWaterPlaneFogStart,fLocal;
long lLocal2;
GLI_tdstColor *p_Color , *p_ColorEnd ;
if ((!(bWaterPlaneState & GLI_C_l2DPlaneIsEnable)) ||
(GLI_C_lWaterPlaneNoFog & bWaterPlaneState)) return;
p_Color = p_stGlobalsParrameters->GLI_aDEF_stColorsRLID + xStart;
p_ColorEnd = p_Color + xNumber;
p_xCounter = p_stGlobalsParrameters->GLI_aDEF_xWaterPlaneDepth + xStart;
fOoWaterPlaneFogStart = -1.0f / GLI_gsfWaterPlaneFogStart;
*((float *)&lLocal2) = -GLI_gsfWaterPlaneFogStart ;
for (;p_Color <p_ColorEnd;p_Color ++,p_xCounter++)
if (*((long *)p_xCounter) < 0)
{
if (*p_xCounter > -GLI_gsfWaterPlaneFogStart)
{
fLocal = fOoWaterPlaneFogStart * *p_xCounter;
p_Color -> xR += fLocal * GLI_gsfWaterPlaneFogColor . xR;
p_Color -> xG += fLocal * GLI_gsfWaterPlaneFogColor . xG;
p_Color -> xB += fLocal * GLI_gsfWaterPlaneFogColor . xB;
}
else
{
p_Color -> xR += GLI_gsfWaterPlaneFogColor . xR ;
p_Color -> xG += GLI_gsfWaterPlaneFogColor . xG ;
p_Color -> xB += GLI_gsfWaterPlaneFogColor . xB ;
}
}
}
/**********************************************************************************************/
/* Name: GLI_vSetWaterFog*/
/* Goal : Init waterplane module*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : */
/**********************************************************************************************/
void GLI_vSetWaterFog(MTH_tdxReal xDepth,GLI_tdstColor *p_stFogColor)
{
GLI_gsfWaterPlaneFogColor = *p_stFogColor;
GLI_gsfWaterPlaneFogStart = xDepth;
}
/**********************************************************************************************/
/* Name: GLI_vInitWaterplaneModule*/
/* Goal : Init waterplane module*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : */
/**********************************************************************************************/
void GLI_vInitWaterplaneModule()
{
/* !!! = Could be used as a REINIT function, so it could stay optimlised*/
long lCounter;
static unsigned char lIsAlreadyInit = 1;
GLI_fF2pow24 = (float)(3L * pow(2,23));
if (lIsAlreadyInit)
for (lCounter=0;lCounter<GLI_TSINTA;lCounter++)
{
a64_fSinTable[lCounter]= (MTH_M_xCos( ((2.0*3.1415927f/GLI_TSINTA) * (float)lCounter))) * 2;
}
lIsAlreadyInit = 0;
bWaterPlaneState = 0;
gs_lXBase = 0;
gs_lYBase = 32;
GLI_gsfWaterPlaneFogColor . xR = -0.6f;
GLI_gsfWaterPlaneFogColor . xG = -0.3f;
GLI_gsfWaterPlaneFogColor . xB = -0.4f;
GLI_gsWaterPlaneRefraction = 0.7f;
GLI_gsWaterPlaneDepthSizeOf2DMove = 1.4f;
GLI_gsWaterPlaneDepthStartOf2DMove = -5.0f;
GLI_gsfWaterPlaneFogStart = 7.0f;
stWaterPlaneNormale . xX = 0.0f;
stWaterPlaneNormale . xZ = 0.0f;
stWaterPlaneNormale . xY = 1.0f;
fWaterPlaneDistance = 0.0f;
/*ANNECY VL04/03/98{*/
stSinEffectAmp.xX = 1.0f;
stSinEffectAmp.xY = 0.0f;
stSinEffectAmp.xZ = 0.0f;
a3_lSinEffectFreq[0] = 1;
a3_lSinEffectFreq[1] = 0;
a3_lSinEffectFreq[2] = 0;
a3_xSinEffectBase[0] = MTH_C_ZERO;
a3_xSinEffectBase[1] = MTH_C_ZERO;
a3_xSinEffectBase[2] = MTH_C_ZERO;
xSinusEffectDepthStart = 10.0f;
g_cSinusEffectState = 0;
g_cSinusEffectFlag = 0;
/*ENDANNECY VL}*/
}
/*ANNECY VL04/03/98{*/
/*
=======================================================================================
Function for sinus Effect
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : get / set state
----------------------------------------------------------------------------------------
*/
void GLI_fn_SinusEffect_vSetState( char _cState )
{
g_cSinusEffectState = _cState;
}
char GLI_fn_SinusEffect_vGetState( void )
{
return g_cSinusEffectState;
}
/*
----------------------------------------------------------------------------------------
Description : get / set flag
----------------------------------------------------------------------------------------
*/
void GLI_fn_SinusEffect_vSetFlag( char _cFlag )
{
g_cSinusEffectFlag = _cFlag;
}
char GLI_fn_SinusEffect_vGetFlag( void )
{
return g_cSinusEffectFlag;
}
/*
----------------------------------------------------------------------------------------
Description : return non zero value if object in second viewport have to be
affected by sinus effect
----------------------------------------------------------------------------------------
*/
char GLI_fn_SinusEffect_cIsSecondViewportAffected( void )
{
return g_cSinusEffectFlag & C_SinusEffect_cAffectSecondViewPort;
}
/*
----------------------------------------------------------------------------------------
Description : set frequences
----------------------------------------------------------------------------------------
*/
void GLI_fn_SinusEffect_vSetFreq( long _lXFreq, long _lYFreq, long _lZFreq )
{
a3_lSinEffectFreq[0] = _lXFreq;
a3_lSinEffectFreq[1] = _lYFreq;
a3_lSinEffectFreq[2] = _lZFreq;
}
/*
----------------------------------------------------------------------------------------
Description : Set amplitude vector
----------------------------------------------------------------------------------------
*/
void GLI_fn_SinusEffect_vSetAmplitude( MTH3D_tdstVector *_p_stAmpVector )
{
MTH3D_M_vCopyVector( &stSinEffectAmp, _p_stAmpVector );
}
/*
----------------------------------------------------------------------------------------
Description : 2D Sinus effect
----------------------------------------------------------------------------------------
*/
void GLI_v2DSinusEffect(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobalsParrameters,long xStart,long xNumber)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lVerticeY;
long lVerticeX;
GLI_tdstAligned3DVector *p_Vertex3D ;
GLI_tdstAligned2DVector *p_Vertex2D , *p_Vertex2DEnd ;
MTH_tdxReal xFactor;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* init loop data
*/
p_Vertex3D = p_stGlobalsParrameters->GLI_TurnedScaledDisplecedPoint + xStart;
p_Vertex2D = p_stGlobalsParrameters->GLI_ScreenPoint + xStart;
p_Vertex2DEnd = p_Vertex2D + xNumber;
/*
* loop on vertex
*/
if (g_cSinusEffectFlag & C_SinusEffect_cUseZFactor )
{
for ( ;p_Vertex2D < p_Vertex2DEnd; p_Vertex2D++, p_Vertex3D ++)
{
if (p_Vertex3D->xZ > GLI_C_xZClippingNear)
{
*(float *)((void *)&lVerticeX) = (p_Vertex2D->xX) + a3_xSinEffectBase[0] + GLI_fF2pow24;
*(float *)((void *)&lVerticeY) = (p_Vertex2D->xY) + a3_xSinEffectBase[1] + GLI_fF2pow24;
xFactor = (p_Vertex2D->xOoZ > 0.005) ? 1 : 200 * p_Vertex2D->xOoZ;
p_Vertex2D->xX += p_Vertex2D->xX + a64_fSinTable [ lVerticeX & 63] * stSinEffectAmp.xX * xFactor;
p_Vertex2D->xY += p_Vertex2D->xY + a64_fSinTable [ lVerticeY & 63] * stSinEffectAmp.xY * xFactor;
}
}
}
else
{
for ( ;p_Vertex2D < p_Vertex2DEnd; p_Vertex2D++, p_Vertex3D ++)
{
if (p_Vertex3D->xZ > GLI_C_xZClippingNear)
{
*(float *)((void *)&lVerticeX) = (p_Vertex2D->xX) + a3_xSinEffectBase[0] + GLI_fF2pow24;
*(float *)((void *)&lVerticeY) = (p_Vertex2D->xY) + a3_xSinEffectBase[1] + GLI_fF2pow24;
p_Vertex2D->xX += a64_fSinTable[ lVerticeX & 63 ] * stSinEffectAmp.xX;
p_Vertex2D->xY += a64_fSinTable[ lVerticeY & 63 ] * stSinEffectAmp.xY;
}
}
}
}
/*
----------------------------------------------------------------------------------------
Description : update effect variable.
called only once by trame before world is displayed
----------------------------------------------------------------------------------------
*/
MTH_tdxReal gs_xFactor;
void GLI_vUpdateEffectData( unsigned long _ulDeltaT )
{
MTH_tdxReal xFactor;
gs_xFactor = xFactor = MTH_M_xMul( (float)_ulDeltaT, 0.0128f );
a3_xSinEffectBase[0] += a3_lSinEffectFreq[0] * xFactor;
a3_xSinEffectBase[1] += a3_lSinEffectFreq[1] * xFactor;
a3_xSinEffectBase[2] += a3_lSinEffectFreq[2] * xFactor;
}
/*ENDANNECY VL}*/
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@@ -0,0 +1,524 @@
/*
Tested with LINT
*/
#define MTH_LOW
#include "gli_st.h"
#include "GLI_Defn.h"
#include "mater_st.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "material.h"
#include "GeoSprit.h"
#include "proj.h"
#include "linear.h"
#include "vpt3D.h"
#include "camera.h"
#include "DLLInter.h"
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
#ifdef __cplusplus
extern "C"
{
#endif
/*extern void GLI_NJA_vSendSpriteToClip(GLI_tdstAligned2DVector *a4_st2DVertex , MTH_tdxReal xZ , GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);*/
/*extern void GLI_NJA_vSendSpriteToClipWithUV(GLI_tdstAligned2DVector *a4_st2DVertex ,MTH_tdxReal *a8_stUVVertex,MTH_tdxReal xZ ,GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);*/
extern void GLI_vDoMaterialSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
/**********************************************************************************************/
/* Name: GLI_xDraw2DSprite*/
/* Goal: */
/* Code: Philippe Vimont / 1.0*/
/**********************************************************************************************/
void GLI_vDraw2DSprite ( GLD_tdstViewportAttributes *p_stVpt ,MTH_tdxReal xXMin,MTH_tdxReal xXMax,MTH_tdxReal xYMin,MTH_tdxReal xYMax,ACP_tdxHandleOfMaterial hMaterial)
{
GLI_tdstAligned2DVector a4_st2DVertex [5];
GEO_tdstColor stLocalColor;
stLocalColor . xG = stLocalColor . xB = stLocalColor. xR = 0.0f;
GLI_xSetMaterialAmbientCoef(hMaterial , &stLocalColor);
stLocalColor . xG = stLocalColor . xB = stLocalColor. xR = 1.0f;
GLI_xSetMaterialDiffuseCoef(hMaterial , &stLocalColor);
stLocalColor . xG = stLocalColor . xB = stLocalColor. xR = 0.0f;
GLI_xSetMaterialSpecularCoef(hMaterial , 0 , &stLocalColor);
a4_st2DVertex [0] . xX = (float)(long)xXMin;
a4_st2DVertex [0] . xY = (float)(long)xYMin;
a4_st2DVertex [0] . xOoZ =1.0f;
a4_st2DVertex [1] . xX = (float)(long)xXMax;
a4_st2DVertex [1] . xY = (float)(long)xYMin;
a4_st2DVertex [1] . xOoZ =1.0f;
a4_st2DVertex [2] . xX = (float)(long)xXMax;
a4_st2DVertex [2] . xY = (float)(long)xYMax;
a4_st2DVertex [2] . xOoZ =1.0f;
a4_st2DVertex [3] . xX = (float)(long)xXMin;
a4_st2DVertex [3] . xY = (float)(long)xYMax;
a4_st2DVertex [3] . xOoZ =1.0f;
GLI_BIG_GLOBALS -> hCurrentMaterial = hMaterial;
GLI_BIG_GLOBALS -> hCurrentMaterial -> xMaterialType = 0xFFFFFFFF - GLI_C_lIsTestingBackface;
GLI_BIG_GLOBALS -> lCurrentDrawMask = 0xFFFFFFFF - GLI_C_lIsTestingBackface;
GLI_BIG_GLOBALS -> lHierachDrawMask = 0xFFFFFFFF - GLI_C_lIsTestingBackface;
GLI_vDoMaterialSelection(GLI_BIG_GLOBALS );
GLI_DRV_vSendSpriteToClip( a4_st2DVertex , 1.0f / GLI_C_xZClippingNear, GLI_BIG_GLOBALS);
}
/**********************************************************************************************/
/* Name: GLI_xDraw2DSpriteWithUV*/
/* Goal: */
/* Code: Philippe Vimont / 1.0*/
/**********************************************************************************************/
void
GLI_vDraw2DSpriteWithUV ( GLD_tdstViewportAttributes *p_stVpt ,
MTH_tdxReal xXMin,
MTH_tdxReal xXMax,
MTH_tdxReal xYMin,
MTH_tdxReal xYMax,
MTH_tdxReal xUMin,
MTH_tdxReal xUMax,
MTH_tdxReal xVMin,
MTH_tdxReal xVMax,
ACP_tdxHandleOfMaterial hMaterial)
{
GLI_tdstAligned2DVector a4_st2DVertex [5];
MTH_tdxReal a4_stUVVertex [10];
GEO_tdstColor stLocalColor;
stLocalColor . xG = stLocalColor . xB = stLocalColor. xR = 0.0f;
GLI_xSetMaterialAmbientCoef(hMaterial , &stLocalColor);
stLocalColor . xG = stLocalColor . xB = stLocalColor. xR = 1.0f;
GLI_xSetMaterialDiffuseCoef(hMaterial , &stLocalColor);
stLocalColor . xG = stLocalColor . xB = stLocalColor. xR = 0.0f;
GLI_xSetMaterialSpecularCoef(hMaterial , 0 , &stLocalColor);
a4_st2DVertex [0] . xX = (float)(long)xXMin;
a4_st2DVertex [0] . xY = (float)(long)xYMin;
a4_st2DVertex [0] . xOoZ =1.0f;
a4_st2DVertex [1] . xX = (float)(long)xXMax;
a4_st2DVertex [1] . xY = (float)(long)xYMin;
a4_st2DVertex [1] . xOoZ =1.0f;
a4_st2DVertex [2] . xX = (float)(long)xXMax;
a4_st2DVertex [2] . xY = (float)(long)xYMax;
a4_st2DVertex [2] . xOoZ =1.0f;
a4_st2DVertex [3] . xX = (float)(long)xXMin;
a4_st2DVertex [3] . xY = (float)(long)xYMax;
a4_st2DVertex [3] . xOoZ =1.0f;
a4_stUVVertex [0] = xUMin;
a4_stUVVertex [0+1] = xVMin;
a4_stUVVertex [2] = xUMax;
a4_stUVVertex [2+1] = xVMin;
a4_stUVVertex [4] = xUMax;
a4_stUVVertex [4+1] = xVMax;
a4_stUVVertex [6] = xUMin;
a4_stUVVertex [6+1] = xVMax;
GLI_BIG_GLOBALS -> hCurrentMaterial = hMaterial;
GLI_BIG_GLOBALS -> hCurrentMaterial -> xMaterialType = 0xFFFFFFFF - GLI_C_lIsTestingBackface;
GLI_BIG_GLOBALS -> lCurrentDrawMask = 0xFFFFFFFF - GLI_C_lIsTestingBackface;
GLI_BIG_GLOBALS -> lHierachDrawMask = 0xFFFFFFFF - GLI_C_lIsTestingBackface;
GLI_vDoMaterialSelection(GLI_BIG_GLOBALS );
GLI_DRV_vSendSpriteToClipWithUV ( a4_st2DVertex ,a4_stUVVertex ,1.0f / GLI_C_xZClippingNear,GLI_BIG_GLOBALS);
}
/* STM- get rid of this in final version if we really don't need the old rot. code*/
#define USE_NEW_SPRITE
#ifdef USE_NEW_SPRITE
#pragma message(__FILE__ ": Using new sprite code")
/**********************************************************************************************/
/* Name: GLI_xDrawIndexedSprite*/
/* Goal: */
/* Code: Steve McCalla / 2.0*/
/* This function assumes that scale is always diagonal*/
/**********************************************************************************************/
void
GLI_vDrawIndexedSprite ( GLD_tdstViewportAttributes *p_stVpt ,
GEO_tdstGeometricObject *p_stObj ,
GEO_tdstIndexedSprite *p_stISpr ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_tdstAligned3DVector stScaledPt[3];
GLI_tdstAligned2DVector a4_st2DVertex [4];
GLI_tdstAligned2DVector a2_st2DVertexLocal[3];
GLI_tdScreenVertx a4_ScrVertex[4];
GLI_tdScreenVertx *pVtx1, *pVtx2, *pVtx3, *pVtx4;
ACP_tdxIndex xSpriteNumber;
MTH_tdxReal xTempZ;
xSpriteNumber = 0;
if ((p_stISpr -> hSprite == NULL)
|| ((p_stGlobaleMT -> GLI_ScreenPoint + p_stISpr -> xCenterPoint) -> xOoZ < 0.0f)
|| (p_stISpr -> hSprite -> d_xSpriteDrawMode[xSpriteNumber] & GEO_C_lSpriteDrawDisable))
return;
assert (p_stISpr -> hSprite -> xNbSprites == 1);
assert (!(p_stISpr -> hSprite -> d_xSpriteDrawMode[xSpriteNumber] & GEO_C_lSpriteDrawMode2DRotativ));
assert (p_stISpr -> stSize.xX == 1.0);
assert (p_stISpr -> stSize.xY == 1.0);
pVtx1 = a4_ScrVertex;
pVtx2 = a4_ScrVertex+1;
pVtx3 = a4_ScrVertex+2;
pVtx4 = a4_ScrVertex+3;
stScaledPt[0].xX = p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xX;
stScaledPt[0].xY = 0.0;
stScaledPt[1].xX = 0.0;
stScaledPt[1].xY = -p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xY;
stScaledPt[2].xX = 0.0;
stScaledPt[2].xY = 0.0;
if (!POS_fn_ulIsNotScaledMatrix ( &p_stGlobaleMT -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix))
{
MTH_tdxReal xScaleX;
MTH_tdxReal xScaleY;
xScaleX = POS_fn_xGetXScale(&(p_stGlobaleMT->gs_st_CurrentMatrixMultiplyedWithCameraMatrix));
xScaleY = POS_fn_xGetYScale(&(p_stGlobaleMT->gs_st_CurrentMatrixMultiplyedWithCameraMatrix));
stScaledPt[0].xX = xScaleX * p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xX;
stScaledPt[1].xY = xScaleY * (-p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xY);
}
xTempZ = p_stGlobaleMT->GLI_TurnedScaledDisplecedPoint[p_stISpr->xCenterPoint].xZ;
stScaledPt[0].xZ = xTempZ;
stScaledPt[1].xZ = xTempZ;
stScaledPt[2].xZ = xTempZ;
if (p_stISpr -> hSprite -> d_xSpriteDrawMode[xSpriteNumber] & GEO_C_lSpriteDrawMode2DScaled) {
GLI_xSerialProjectionNoTrans ( (( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD)->p_stCam,
3, stScaledPt, a2_st2DVertexLocal);
SetX(pVtx1, p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xX - a2_st2DVertexLocal[0].xX - a2_st2DVertexLocal[1].xX + a2_st2DVertexLocal[2].xX);
SetY(pVtx1, p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xY - a2_st2DVertexLocal[0].xY - a2_st2DVertexLocal[1].xY + a2_st2DVertexLocal[2].xY);
SetX(pVtx2, p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xX + a2_st2DVertexLocal[0].xX - a2_st2DVertexLocal[1].xX + a2_st2DVertexLocal[2].xX);
SetY(pVtx2, p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xY + a2_st2DVertexLocal[0].xY - a2_st2DVertexLocal[1].xY + a2_st2DVertexLocal[2].xY);
SetX(pVtx3, p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xX + a2_st2DVertexLocal[0].xX + a2_st2DVertexLocal[1].xX + a2_st2DVertexLocal[2].xX);
SetY(pVtx3, p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xY + a2_st2DVertexLocal[0].xY + a2_st2DVertexLocal[1].xY + a2_st2DVertexLocal[2].xY);
SetX(pVtx4, p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xX - a2_st2DVertexLocal[0].xX + a2_st2DVertexLocal[1].xX + a2_st2DVertexLocal[2].xX);
SetY(pVtx4, p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xY - a2_st2DVertexLocal[0].xY + a2_st2DVertexLocal[1].xY + a2_st2DVertexLocal[2].xY);
a4_st2DVertex [0] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - a2_st2DVertexLocal[0] . xX - a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [0] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - a2_st2DVertexLocal[0] . xY - a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
a4_st2DVertex [1] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + a2_st2DVertexLocal[0] . xX - a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [1] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + a2_st2DVertexLocal[0] . xY - a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
a4_st2DVertex [2] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + a2_st2DVertexLocal[0] . xX + a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [2] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + a2_st2DVertexLocal[0] . xY + a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
a4_st2DVertex [3] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - a2_st2DVertexLocal[0] . xX + a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [3] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - a2_st2DVertexLocal[0] . xY + a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
}
else {
SetX(pVtx1, (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xX + stScaledPt[0].xX + stScaledPt[1].xX));
SetY(pVtx1, (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xY + stScaledPt[0].xY + stScaledPt[1].xY));
SetX(pVtx2, (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xX - stScaledPt[0].xX + stScaledPt[1].xX));
SetY(pVtx2, (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xY - stScaledPt[0].xY + stScaledPt[1].xY));
SetX(pVtx3, (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xX - stScaledPt[0].xX - stScaledPt[1].xX));
SetY(pVtx3, (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xY - stScaledPt[0].xY - stScaledPt[1].xY));
SetX(pVtx4, (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xX + stScaledPt[0].xX - stScaledPt[1].xX));
SetY(pVtx4, (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr->xCenterPoint].xY + stScaledPt[0].xY - stScaledPt[1].xY));
a4_st2DVertex [0] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + stScaledPt[0] . xX + stScaledPt[1] . xX);
a4_st2DVertex [0] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + stScaledPt[0] . xY + stScaledPt[1] . xY);
a4_st2DVertex [1] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - stScaledPt[0] . xX + stScaledPt[1] . xX);
a4_st2DVertex [1] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - stScaledPt[0] . xY + stScaledPt[1] . xY);
a4_st2DVertex [2] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - stScaledPt[0] . xX - stScaledPt[1] . xX);
a4_st2DVertex [2] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - stScaledPt[0] . xY - stScaledPt[1] . xY);
a4_st2DVertex [3] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + stScaledPt[0] . xX - stScaledPt[1] . xX);
a4_st2DVertex [3] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + stScaledPt[0] . xY - stScaledPt[1] . xY);
}
p_stGlobaleMT -> hCurrentMaterial = GMT_fn_hGetVisualMaterial(p_stISpr -> hSprite -> d_hMaterial[xSpriteNumber]);
{
unsigned long xSaveDrawMsk;
xSaveDrawMsk = p_stGlobaleMT -> lHierachDrawMask ;
p_stGlobaleMT -> lHierachDrawMask &= ~GLI_C_lIsTestingBackface;
GLI_vDoMaterialSelection(p_stGlobaleMT);
p_stGlobaleMT->ulSpecularColorForSprite = ((unsigned long *) p_stGlobaleMT->GLI_aDEF_stColorsRLIS)[p_stISpr -> xCenterPoint];
GLI_DRV_vSendSpriteToClip(a4_st2DVertex , p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint].xOoZ, p_stGlobaleMT);
p_stGlobaleMT -> lHierachDrawMask = xSaveDrawMsk;
}
}
#else /* using old sprite code*/
#pragma message(__FILE__ ": Using old sprite code")
/**********************************************************************************************/
/* Name: GLI_xDrawIndexedSprite*/
/* Goal: */
/* Code: Philippe Vimont / 1.0*/
/**********************************************************************************************/
/*typedef struct GEO_tdstIndexedSprite_
{ ACP_tdxIndex xCenterPoint;
ACP_tdxHandleOfSprite hSprite;
MTH2D_tdstVector stSize;
} GEO_tdstIndexedSprite;*/
void
GLI_vDrawIndexedSprite ( GLD_tdstViewportAttributes *p_stVpt ,
GEO_tdstGeometricObject *p_stObj ,
GEO_tdstIndexedSprite *p_stISpr ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_tdstAligned3DVector stRotatedAxis[5];
GLI_tdstAligned2DVector a4_st2DVertex [5];
GLI_tdstAligned2DVector a2_st2DVertexLocal[3];
MTH_tdxReal xCos,xSin,xLen;
ACP_tdxIndex xSpriteNumber;
MTH3D_tdstVector stYVector;
POS_tdstCompletePosition stTempMatrix1,stTempMatrix2;
xSpriteNumber = 0;
if (p_stISpr -> hSprite == NULL) return;
/* POS_fn_vSetIdentityMatrix(&stTempMatrix1);*/
/* POS_fn_vSetType(&stTempMatrix1,POS_C_xCompletePosition); // Optimization*/
/* POS_fn_vSetIdentityMatrix(&stTempMatrix2); // AR971214 not usefull*/
if ((p_stGlobaleMT -> GLI_ScreenPoint + p_stISpr -> xCenterPoint) -> xOoZ < 0.0f) return;
GLI_xSerialLinearOp ( 1, p_stObj->d_stListOfPointsNormals + p_stISpr -> xCenterPoint, stRotatedAxis , &p_stGlobaleMT -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix);
POS_fn_vGetTranslationVector ( p_stGlobaleMT -> gs_st_CurrentMatrix ,(MTH3D_tdstVector *) &stRotatedAxis[1]);
MTH3D_M_vSubVector ( (MTH3D_tdstVector *)&stRotatedAxis[0], (MTH3D_tdstVector *)&stRotatedAxis[0], (MTH3D_tdstVector *)&stRotatedAxis[1]);
if (p_stISpr -> hSprite -> xNbSprites > 1)
{
xLen = MTH3D_M_xDotProductVector( (MTH3D_tdstVector *)stRotatedAxis , (MTH3D_tdstVector *)(p_stGlobaleMT->GLI_TurnedScaledDisplecedPoint + p_stISpr -> xCenterPoint) );
xLen = xLen / MTH3D_M_xNormVector ( p_stGlobaleMT->GLI_TurnedScaledDisplecedPoint + p_stISpr -> xCenterPoint);
for (xSpriteNumber = 0;
xSpriteNumber < p_stISpr -> hSprite -> xNbSprites - 1;
xSpriteNumber ++)
{
if ( p_stISpr -> hSprite -> d_xThresholds [ xSpriteNumber + 1 ] > xLen ) break;
}
} else {
xSpriteNumber = 0;
}
if (p_stISpr -> hSprite -> d_xSpriteDrawMode[xSpriteNumber] & GEO_C_lSpriteDrawDisable) return;
if (p_stISpr -> hSprite -> d_xSpriteDrawMode[xSpriteNumber] & GEO_C_lSpriteDrawMode2DRotativ)
{
xLen = MTH_M_xSqr( stRotatedAxis[0] . xX ) + MTH_M_xSqr( stRotatedAxis[0] . xY ) ;
if (xLen > 0.1f)
{
xSin = stRotatedAxis[0] . xX ;
if (xSin != xLen)
xCos = xLen - MTH_M_xSqr( xSin );
else
xCos = 0.0f;
xLen = MTH_M_xInvSqrt( xLen );
xCos = MTH_M_xSqrt( xCos ) * xLen;
xSin *= xLen;
if (stRotatedAxis[0] . xY < 0.0)
xCos = -xCos ;
} else{
xSin = 0.0;
xCos = 1.0;
}
} else
{
xSin = 0.0;
xCos = 1.0;
}
if (p_stISpr -> hSprite -> d_xSpriteDrawMode[xSpriteNumber] & GEO_C_lSpriteDrawMode2DScaled)
{
stRotatedAxis[0] . xX = p_stISpr -> stSize . xX * xCos * p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xX;
stRotatedAxis[0] . xY = -p_stISpr -> stSize . xX * xSin * p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xX;
stRotatedAxis[1] . xX = -p_stISpr -> stSize . xY * xSin * p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xY;
stRotatedAxis[1] . xY = -p_stISpr -> stSize . xY * xCos * p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xY;
stRotatedAxis[2] . xX = (-p_stISpr -> hSprite -> d_xDisplacementOfSprite [xSpriteNumber].xX * xCos - p_stISpr -> hSprite -> d_xDisplacementOfSprite [xSpriteNumber].xY * xSin) ;
stRotatedAxis[2] . xY = ( p_stISpr -> hSprite -> d_xDisplacementOfSprite [xSpriteNumber].xX * xSin - p_stISpr -> hSprite -> d_xDisplacementOfSprite [xSpriteNumber].xY * xCos) ;
if (!POS_fn_ulIsNotScaledMatrix ( &p_stGlobaleMT -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix))
{
stRotatedAxis[0] . xZ = stRotatedAxis[1] . xZ = stRotatedAxis[2] . xZ = 0.f;
stTempMatrix2 = p_stGlobaleMT -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix;
POS_fn_vInvertIsoMatrix ( &stTempMatrix1 , &p_stGlobaleMT -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix) ;
POS_fn_vResetScaleMatrix ( &stTempMatrix1 ) ;
stYVector . xX = stYVector . xY = stYVector . xZ = 0.f;
POS_fn_vSetTranslationVector ( &stTempMatrix1 ,&stYVector);
POS_fn_vSetTranslationVector ( &stTempMatrix2 ,&stYVector);
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[0] , &stTempMatrix1 , (MTH3D_tdstVector *) &stRotatedAxis[0] ) ;
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[0] , &stTempMatrix2 , (MTH3D_tdstVector *) &stRotatedAxis[0] ) ;
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[1] , &stTempMatrix1 , (MTH3D_tdstVector *) &stRotatedAxis[1] ) ;
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[1] , &stTempMatrix2 , (MTH3D_tdstVector *) &stRotatedAxis[1] ) ;
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[2] , &stTempMatrix1 , (MTH3D_tdstVector *) &stRotatedAxis[2] ) ;
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[2] , &stTempMatrix2 , (MTH3D_tdstVector *) &stRotatedAxis[2] ) ;
}
/*stRotatedAxis[0] . xX = p_stISpr -> stSize . xX ;*/
/*stRotatedAxis[0] . xY = p_stISpr -> stSize . xY ;*/
stRotatedAxis[0] . xZ =p_stGlobaleMT->GLI_TurnedScaledDisplecedPoint[p_stISpr -> xCenterPoint].xZ;
stRotatedAxis[1] . xZ =p_stGlobaleMT->GLI_TurnedScaledDisplecedPoint[p_stISpr -> xCenterPoint].xZ;
stRotatedAxis[2] . xZ =p_stGlobaleMT->GLI_TurnedScaledDisplecedPoint[p_stISpr -> xCenterPoint].xZ;
GLI_xSerialProjection ( (( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD)->p_stCam,
3,
stRotatedAxis,
a2_st2DVertexLocal ) ;
a2_st2DVertexLocal [0] . xX -= (( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD) -> p_stCam -> stTrans . xX ;
a2_st2DVertexLocal [0] . xY -= (( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD) -> p_stCam -> stTrans . xY ;
a2_st2DVertexLocal [1] . xX -= (( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD) -> p_stCam -> stTrans . xX ;
a2_st2DVertexLocal [1] . xY -= (( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD) -> p_stCam -> stTrans . xY ;
a2_st2DVertexLocal [2] . xX -= (( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD) -> p_stCam -> stTrans . xX ;
a2_st2DVertexLocal [2] . xY -= (( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD) -> p_stCam -> stTrans . xY ;
a4_st2DVertex [0] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - a2_st2DVertexLocal[0] . xX - a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [0] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - a2_st2DVertexLocal[0] . xY - a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
a4_st2DVertex [1] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + a2_st2DVertexLocal[0] . xX - a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [1] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + a2_st2DVertexLocal[0] . xY - a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
a4_st2DVertex [2] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + a2_st2DVertexLocal[0] . xX + a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [2] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + a2_st2DVertexLocal[0] . xY + a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
a4_st2DVertex [3] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - a2_st2DVertexLocal[0] . xX + a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [3] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - a2_st2DVertexLocal[0] . xY + a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
}
else
{
stRotatedAxis[0] . xX = p_stISpr -> stSize . xX * xCos * p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xX;
stRotatedAxis[0] . xY = -p_stISpr -> stSize . xX * xSin * p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xX;
stRotatedAxis[1] . xX = -p_stISpr -> stSize . xY * xSin * p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xY;
stRotatedAxis[1] . xY = -p_stISpr -> stSize . xY * xCos * p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xY;
stRotatedAxis[2] . xX = ( p_stISpr -> hSprite -> d_xDisplacementOfSprite [xSpriteNumber].xX * xCos + p_stISpr -> hSprite -> d_xDisplacementOfSprite [xSpriteNumber].xY * xSin) ;
stRotatedAxis[2] . xY = (-p_stISpr -> hSprite -> d_xDisplacementOfSprite [xSpriteNumber].xX * xSin + p_stISpr -> hSprite -> d_xDisplacementOfSprite [xSpriteNumber].xY * xCos) ;
if (!POS_fn_ulIsNotScaledMatrix ( &p_stGlobaleMT -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix))
{
stRotatedAxis[0] . xZ = stRotatedAxis[1] . xZ = stRotatedAxis[2] . xZ = 0.f;
stTempMatrix2 = p_stGlobaleMT -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix;
POS_fn_vInvertIsoMatrix ( &stTempMatrix1 , &p_stGlobaleMT -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix) ;
POS_fn_vResetScaleMatrix ( &stTempMatrix1 ) ;
stYVector . xX = stYVector . xY = stYVector . xZ = 0.f;
POS_fn_vSetTranslationVector ( &stTempMatrix1 ,&stYVector);
POS_fn_vSetTranslationVector ( &stTempMatrix2 ,&stYVector);
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[0] , &stTempMatrix1 , (MTH3D_tdstVector *) &stRotatedAxis[0] ) ;
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[0] , &stTempMatrix2 , (MTH3D_tdstVector *) &stRotatedAxis[0] ) ;
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[1] , &stTempMatrix1 , (MTH3D_tdstVector *) &stRotatedAxis[1] ) ;
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[1] , &stTempMatrix2 , (MTH3D_tdstVector *) &stRotatedAxis[1] ) ;
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[2] , &stTempMatrix1 , (MTH3D_tdstVector *) &stRotatedAxis[2] ) ;
POS_fn_vMulMatrixVertex ( (MTH3D_tdstVector *) &stRotatedAxis[2] , &stTempMatrix2 , (MTH3D_tdstVector *) &stRotatedAxis[2] ) ;
}
a4_st2DVertex [0] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + stRotatedAxis[0] . xX + stRotatedAxis[1] . xX + stRotatedAxis[2] . xX );
a4_st2DVertex [0] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + stRotatedAxis[0] . xY + stRotatedAxis[1] . xY + stRotatedAxis[2] . xY );
a4_st2DVertex [1] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - stRotatedAxis[0] . xX + stRotatedAxis[1] . xX + stRotatedAxis[2] . xX );
a4_st2DVertex [1] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - stRotatedAxis[0] . xY + stRotatedAxis[1] . xY + stRotatedAxis[2] . xY );
a4_st2DVertex [2] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - stRotatedAxis[0] . xX - stRotatedAxis[1] . xX + stRotatedAxis[2] . xX );
a4_st2DVertex [2] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - stRotatedAxis[0] . xY - stRotatedAxis[1] . xY + stRotatedAxis[2] . xY );
a4_st2DVertex [3] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + stRotatedAxis[0] . xX - stRotatedAxis[1] . xX + stRotatedAxis[2] . xX );
a4_st2DVertex [3] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + stRotatedAxis[0] . xY - stRotatedAxis[1] . xY + stRotatedAxis[2] . xY );
}
p_stGlobaleMT -> hCurrentMaterial = GMT_fn_hGetVisualMaterial(p_stISpr -> hSprite -> d_hMaterial[xSpriteNumber]);
{
unsigned long xSaveDrawMsk;
xSaveDrawMsk = p_stGlobaleMT -> lHierachDrawMask ;
p_stGlobaleMT -> lHierachDrawMask &= ~GLI_C_lIsTestingBackface;
GLI_vDoMaterialSelection(p_stGlobaleMT);
GLI_DRV_vSendSpriteToClip( a4_st2DVertex , p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint].xOoZ, p_stGlobaleMT);
p_stGlobaleMT -> lHierachDrawMask = xSaveDrawMsk;
}
}
#endif /* USE_NEW_SPRITE*/
/**********************************************************************************************/
/* Name: GLI_vPickIndexedSprite*/
/* Goal: return's !0 if p_stScreenCoord is in the sprite.*/
/* Code: Philippe Vimont / 1.0*/
/**********************************************************************************************/
#define GLI_M_bIsOnTheLeft(a,b) ( (a4_st2DVertex[b].xY - a4_st2DVertex[a].xY) * (p_stScreenCoord->xX - a4_st2DVertex[a].xX) > (a4_st2DVertex[b].xX - a4_st2DVertex[a].xX) * (p_stScreenCoord->xY - a4_st2DVertex[a].xY) )
long GLI_vPickIndexedSprite
(
GLD_tdstViewportAttributes *p_stVpt ,
GEO_tdstGeometricObject *p_stObj ,
GEO_tdstIndexedSprite *p_stISpr ,
MTH2D_tdstVector *p_stScreenCoord,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT
)
{
#ifdef _DEBUG
ACP_tdxHandleOfMaterial hVisualMat;
GLI_tdstAligned3DVector stScaledPt[3];
GLI_tdstAligned2DVector a4_st2DVertex [4];
GLI_tdstAligned2DVector a2_st2DVertexLocal[3];
ACP_tdxIndex xSpriteNumber;
MTH_tdxReal xTempZ; /* make this a MTH_XXX something or another*/
xSpriteNumber = 0;
if ((p_stISpr -> hSprite == NULL) || ((p_stGlobaleMT -> GLI_ScreenPoint + p_stISpr -> xCenterPoint) -> xOoZ < 0.0f) || (p_stISpr -> hSprite -> d_xSpriteDrawMode[xSpriteNumber] & GEO_C_lSpriteDrawDisable))
return 0;
assert (p_stISpr -> hSprite -> xNbSprites == 1);
assert (!(p_stISpr -> hSprite -> d_xSpriteDrawMode[xSpriteNumber] & GEO_C_lSpriteDrawMode2DRotativ));
assert (p_stISpr -> stSize.xX == 1.0);
assert (p_stISpr -> stSize.xY == 1.0);
stScaledPt[0].xX = p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xX;
stScaledPt[0].xY = 0.0;
stScaledPt[1].xX = 0.0;
stScaledPt[1].xY = -p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xY;
stScaledPt[2].xX = 0.0;
stScaledPt[2].xY = 0.0;
if (!POS_fn_ulIsNotScaledMatrix ( &p_stGlobaleMT -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix))
{
MTH_tdxReal xScaleX;
MTH_tdxReal xScaleY;
xScaleX = POS_fn_xGetXScale(&(p_stGlobaleMT->gs_st_CurrentMatrixMultiplyedWithCameraMatrix));
xScaleY = POS_fn_xGetYScale(&(p_stGlobaleMT->gs_st_CurrentMatrixMultiplyedWithCameraMatrix));
stScaledPt[0].xX = xScaleX * p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xX;
stScaledPt[1].xY = xScaleY * (-p_stISpr -> hSprite -> d_xSizeOfSprite[xSpriteNumber].xY);
}
xTempZ = p_stGlobaleMT->GLI_TurnedScaledDisplecedPoint[p_stISpr->xCenterPoint].xZ;
stScaledPt[0].xZ = xTempZ;
stScaledPt[1].xZ = xTempZ;
stScaledPt[2].xZ = xTempZ;
if (p_stISpr -> hSprite -> d_xSpriteDrawMode[xSpriteNumber] & GEO_C_lSpriteDrawMode2DScaled) {
GLI_xSerialProjectionNoTrans ( (( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD)->p_stCam,
3, stScaledPt, a2_st2DVertexLocal);
a4_st2DVertex [0] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - a2_st2DVertexLocal[0] . xX - a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [0] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - a2_st2DVertexLocal[0] . xY - a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
a4_st2DVertex [1] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + a2_st2DVertexLocal[0] . xX - a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [1] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + a2_st2DVertexLocal[0] . xY - a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
a4_st2DVertex [2] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + a2_st2DVertexLocal[0] . xX + a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [2] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + a2_st2DVertexLocal[0] . xY + a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
a4_st2DVertex [3] . xX = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - a2_st2DVertexLocal[0] . xX + a2_st2DVertexLocal[1] . xX + a2_st2DVertexLocal[2] . xX ;
a4_st2DVertex [3] . xY = p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - a2_st2DVertexLocal[0] . xY + a2_st2DVertexLocal[1] . xY + a2_st2DVertexLocal[2] . xY ;
}
else {
a4_st2DVertex [0] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + stScaledPt[0] . xX + stScaledPt[1] . xX);
a4_st2DVertex [0] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + stScaledPt[0] . xY + stScaledPt[1] . xY);
a4_st2DVertex [1] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - stScaledPt[0] . xX + stScaledPt[1] . xX);
a4_st2DVertex [1] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - stScaledPt[0] . xY + stScaledPt[1] . xY);
a4_st2DVertex [2] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX - stScaledPt[0] . xX - stScaledPt[1] . xX);
a4_st2DVertex [2] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY - stScaledPt[0] . xY - stScaledPt[1] . xY);
a4_st2DVertex [3] . xX = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xX + stScaledPt[0] . xX - stScaledPt[1] . xX);
a4_st2DVertex [3] . xY = (float)(p_stGlobaleMT->GLI_ScreenPoint [p_stISpr -> xCenterPoint] . xY + stScaledPt[0] . xY - stScaledPt[1] . xY);
}
hVisualMat=GMT_fn_hGetVisualMaterial(p_stISpr -> hSprite -> d_hMaterial[xSpriteNumber]);
if (GLI_M_bIsOnTheLeft(0,1))
if (GLI_M_bIsOnTheLeft(1,2))
if (GLI_M_bIsOnTheLeft(2,3))
if (GLI_M_bIsOnTheLeft(3,0))
return ( 1 );
#endif
return(0);
}
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@@ -0,0 +1,248 @@
#define C_szSynchroOn "ON"
#define C_szSynchroOff "OFF"
/* change frame rate under 70 %*/
unsigned char g_ucSynchroLowLimit = 70;
unsigned char g_ucDftSynchro = C_AutoSynchro;
/* ##F===================================================================================
NAME : GLD_vSetFrameSynchro
DESCRIPTION : This function set the type of synchro used with its parameter
For script interpretation
INPUT : Synchro ON or OFF
NbTrame (0 for hysteresis system)
Percent use to decrease NbTrame
=========================================================================================
CREATION : Carlos Torres / 11-12-1997
=======================================================================================*/
void GLD_vSetFrameSynchro(char * szOnOff,char * szNbTrame,char * szPctLowLimit) {
int iNumber;
/* Synchro OFF*/
if (!stricmp(szOnOff,C_szSynchroOff))
g_ucDftSynchro = C_NoSynchro;
/* Synchro ON*/
else if (!stricmp(szOnOff,C_szSynchroOn))
{
iNumber = atoi(szNbTrame);
/* set nb trame use for synchro*/
if ((iNumber >= C_AutoSynchro) && (iNumber <= C_MaxFrameSynchro))
g_ucDftSynchro = (unsigned char) iNumber;
}
/* set % low limit*/
iNumber = atoi(szPctLowLimit);
if ((iNumber >= 0) && (iNumber <= 100))
g_ucSynchroLowLimit = (unsigned char) iNumber;
}
/* ##F===================================================================================
NAME : GLD_vIdle
DESCRIPTION : for NoSynchro -> just call grSstIdle
forAutosynchro -> wait a calculted number of trame
Defaultsynchro -> depends on the choice set with SetFrameSynchro
other -> wait the specified number of trame
INPUT : Synchro choice
=========================================================================================
CREATION : Carlos Torres / 11-12-1997
MODIF / 22-12-1997 change frame length evaluation
=======================================================================================*/
#ifdef GLIDE
void GLD_vIdle(enum Synchro eSynchro) {
static short s_wTime = 0;
static unsigned long s_ulFrameLength = 0;
static unsigned char s_ucFrameFrequency = 3;
stTimerCount C={0,0};
unsigned int uiTramePassed;
unsigned char ucUsedSynchro=(eSynchro == C_DefaultSynchro)?g_ucDftSynchro:eSynchro;
unsigned long ulState;
/* No synchro*/
if ((ucUsedSynchro == C_NoSynchro)) {
grSstIdle();
return;
}
/* first passage*/
if (!s_wTime) {
s_wTime = TMR_fn_wCreateTimer(C_wTimerFrequencyMedium);
ulState = grSstStatus();
/* mesurement of trame length*/
while (grSstVideoLine() != 0);
while (grSstVideoLine() != 1);
TMR_fn_wStartTimer(s_wTime);
while (grSstVideoLine() != 0);
while (grSstVideoLine() != 1);
TMR_fn_wReadTimer(s_wTime,&C);
TMR_fn_wStopTimer(s_wTime);
TMR_fn_wResetTimer(s_wTime);
/* Add a delta to majorate frmae length*/
s_ulFrameLength = (unsigned long)(C.m_ulLowPart*1.05);
s_ulFrameLength = C.m_ulLowPart;
}
else {
/* Auto Syncho*/
if (ucUsedSynchro == C_AutoSynchro) {
/* get the last length of time for rendering*/
TMR_fn_wReadTimer(s_wTime,&C);
/* length is over the previous limit -> increase Frame frequency*/
if ((C.m_ulLowPart > (s_ucFrameFrequency*s_ulFrameLength)) && (s_ucFrameFrequency < C_MaxFrameSynchro)) {
s_ucFrameFrequency++;
}
/* length is under the Synchro Limit -> decrease Frame frequency*/
else
if ((s_ucFrameFrequency > 1) && ((100*C.m_ulLowPart) < ((100*s_ucFrameFrequency - 200 + g_ucSynchroLowLimit)*s_ulFrameLength)))
s_ucFrameFrequency--;
ucUsedSynchro = s_ucFrameFrequency;
}
/* get the last length of time for rendering*/
TMR_fn_wStopTimer(s_wTime);
TMR_fn_wReadTimer(s_wTime,&C);
}
/* compute VBL already passed during rendering*/
for (uiTramePassed=0;C.m_ulLowPart>s_ulFrameLength;uiTramePassed++,C.m_ulLowPart-=s_ulFrameLength);
/* Wa it the next end of screen*/
do {
/* between end of screen and VBL -> wait*/
if (uiTramePassed &&
(grSstVideoLine() >= (unsigned long) 480) &&
(uiTramePassed < ucUsedSynchro)) {
while(grSstVideoLine()) ;
}
/* Avoid evaluation error*/
if (!grSstVideoLine() && ((C.m_ulLowPart << 1) > s_ulFrameLength))
uiTramePassed++;
/* Remain RAZ*/
C.m_ulLowPart=0;
while ((grSstVideoLine() < (unsigned long) 480) &&
(grSstVideoLine() || (uiTramePassed < ucUsedSynchro)));
} while (++uiTramePassed < ucUsedSynchro);
TMR_fn_wResetTimer(s_wTime);
TMR_fn_wStartTimer(s_wTime);
}
#endif /* GLIDE */
long GLD_lComputeWaitFrameForSynchro (enum Synchro eSynchro)
{
static short s_wTime = 0;
static unsigned char s_ucFrameFrequency = 1;
stTimerCount C={0,0};
unsigned char ucUsedSynchro = (eSynchro == C_DefaultSynchro) ? g_ucDftSynchro : eSynchro;
long lTramePassed , lTrameReturn;
/* No synchro*/
if (ucUsedSynchro == C_NoSynchro)
return 0;
/* first passage*/
if (!s_wTime)
{
s_wTime = TMR_fn_wCreateTimer(C_wTimerFrequencyMedium);
TMR_fn_wResetTimer(s_wTime);
TMR_fn_wStartTimer(s_wTime);
return 0;
}
/* Auto Synchro*/
if (ucUsedSynchro == C_AutoSynchro)
{
/* get the last length of time for rendering*/
TMR_fn_wReadTimer(s_wTime, &C);
/* length is over the previous limit -> increase Frame frequency*/
if ( (C.m_ulLowPart > (s_ucFrameFrequency * GLI_g_ulFrameLength) ) && (s_ucFrameFrequency < C_MaxFrameSynchro))
{
s_ucFrameFrequency++;
}
/* length is under the Synchro Limit -> decrease Frame frequency*/
else
{
if ( (s_ucFrameFrequency > 1) && ((100*C.m_ulLowPart) < ((100*s_ucFrameFrequency - 200 + g_ucSynchroLowLimit)*GLI_g_ulFrameLength)) )
s_ucFrameFrequency--;
}
ucUsedSynchro = s_ucFrameFrequency;
}
/* get the last length of time for rendering*/
TMR_fn_wStopTimer(s_wTime);
TMR_fn_wReadTimer(s_wTime,&C);
/* compute VBL already passed during rendering*/
for (lTramePassed = 0 ; C.m_ulLowPart > GLI_g_ulFrameLength; lTramePassed++, C.m_ulLowPart-=GLI_g_ulFrameLength);
if (lTramePassed > s_ucFrameFrequency )
lTrameReturn = 1;
else
lTrameReturn = s_ucFrameFrequency - lTramePassed + 1;
TMR_fn_wResetTimer(s_wTime);
TMR_fn_wStartTimer(s_wTime);
/*return s_ucFrameFrequency;*/
return lTrameReturn;
}
static unsigned short gs_wTimerForSmoothSyncro = 0xbeef;
long GLD_fn_lComputeWaitFrameForSmoothSynchro()
{
#define C_ulFrameRateHistorySize 5
static long gas_ulFrameRateHistory[] =
{ 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
static unsigned long ulTotalFrameRate = 0;
static unsigned long ulCurrentFrame = 0;
stTimerCount stDeltaTime;
unsigned long ulTramePassed;
unsigned long ulTrameReturn = 1;
if( gs_wTimerForSmoothSyncro == 0xbeef )
{
/* First time, create the timer. */
gs_wTimerForSmoothSyncro = TMR_fn_wCreateTimer(C_wTimerFrequencyMedium);
TMR_fn_wResetTimer(gs_wTimerForSmoothSyncro);
TMR_fn_wStartTimer(gs_wTimerForSmoothSyncro);
return 1;
}
TMR_fn_wReadTimer(gs_wTimerForSmoothSyncro, &stDeltaTime);
/* Compute duration passed for engine + rendering (rounded up) */
ulTramePassed = ( stDeltaTime.m_ulLowPart + ((GLI_g_ulFrameLength*95)/100) ) / GLI_g_ulFrameLength;
/* Too slow. We don't do anything */
if( ulTramePassed > 4 )
return 1;
/* Compute number of frames to wait for */
if( ulTramePassed << C_ulFrameRateHistorySize < ulTotalFrameRate )
ulTrameReturn =
1
+ ((ulTotalFrameRate + (1<<C_ulFrameRateHistorySize) - 1) >> C_ulFrameRateHistorySize)
- ulTramePassed;
/* Update frame history */
ulTotalFrameRate -= gas_ulFrameRateHistory[ulCurrentFrame];
ulTotalFrameRate += ulTramePassed;
gas_ulFrameRateHistory[ulCurrentFrame] = ulTramePassed;
ulCurrentFrame ++;
ulCurrentFrame &= (1<<C_ulFrameRateHistorySize) - 1;
return (long)ulTrameReturn;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
/* DevVpt.h*/
/* Prototypes and structures for Dev&Vpt.cpp*/
/* Author : Christophe MARTINAUD*/
/* Last update : 07/19/1996*/
/* Last update : 01/28/1997*/
#ifndef __DEVVPT_H
#define __DEVVPT_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*#include <d3dtypes.h >*/
#define C_NB_MAX_DEVICES 16
#define C_NB_MAX_VPT_IN_DEV 16
#define C_NB_MAX_SETS_OF_RASTERS 16
/* Handle conversion macro*/
#define M_GLD_ParentDeviceHandle( hViewport ) (GLD_tdhDevice)((hViewport) / C_NB_MAX_VPT_IN_DEV);
/* OldVP depends of the device, VP do not */
#define M_GLD_OldViewportHandle( hViewport ) (GLD_tdhViewport)( (hViewport) % C_NB_MAX_VPT_IN_DEV );
#define M_GLD_NewViewportHandleFromOld( hDevice, hViewport ) (GLD_tdhViewport)( ((hDevice) * C_NB_MAX_VPT_IN_DEV) + (hViewport) );
/* Viewport */
typedef struct GLD_stViewport
{
GLD_tdstViewportAttributes stViewAttrib; /* Viewport Attributes*/
BOOL bIsLocked; /* Access to viewport will be denied when TRUE*/
} GLD_tdstViewport, *GLD_tdpstViewport;
/* Device */
typedef struct GLD_stDevice
{
GLD_tdstDeviceAttributes stDevAttrib; /* Device attributes*/
GLD_tdpstViewport pstViewports[ C_NB_MAX_VPT_IN_DEV ]; /* Viewports of device*/
BOOL bIsLocked; /* Access to device will be denied when TRUE*/
DWORD dwStyleBeforeSwap;
DWORD dwExStyleBeforeSwap;
RECT rcWindowBeforeSwap;
DWORD dwBackgroundColor; /* Background Color*/
} GLD_tdstDevice, *GLD_tdpstDevice;
BOOL GLD_fn_bChangeDeviceDisplayMode( GLD_tdhDevice hDev );
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* __DEVVPT_H*/

View File

@@ -0,0 +1,36 @@
/* A few macros and typedef*/
#ifndef __GLDUTIL_H
#define __GLDUTIL_H
/*#include <math.h>*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef GLI_D3D
#ifdef _DEBUG
#define PARAM_LOCK DDLOCK_NOSYSLOCK
#else
#define PARAM_LOCK 0
#endif
#else
#define PARAM_LOCK 0
#endif
typedef float GLD_tdxValue ;
#define GLD_M_LongToValue(A) ( (GLD_tdxValue) ( A ) )
#define GLD_M_Mul(A,B) (GLD_tdxValue)( ( A ) * ( B ) )
#define GLD_M_Sub(A,B) (GLD_tdxValue)( ( A ) - ( B ) )
#define GLD_M_Add(A,B) (GLD_tdxValue)( ( A ) + ( B ) )
#define GLD_M_Div(A,B) (GLD_tdxValue)( ( A ) / ( B ) )
#define GLD_M_Neg(A) ( -( A ) )
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* __GLDUTIL_H*/

View File

@@ -0,0 +1,15 @@
/* All the include files to build GLD*/
/* DirectDraw stuff*/
/*#include "DDraw.h"*/
#include "GldUtil.h"
#include "GLD.h"
#include "MacroGLD.h"
/*#include "Rasters.h"*/
#include "TMR.h"
/*#include "Pictures.h"*/
/*
#include "Errors.h"
*/
#include "DevVpt.h"

View File

@@ -0,0 +1,62 @@
/*////////////////////*/
/* macro for Memory //*/
/*////////////////////*/
#ifndef _MacroGLD_
#define _MacroGLD_
#define _szPersonalMsg_ "V5.9.0 - August 11th 1997"
#define M_GLDInitMmg() Mmg_M_SetModeAlloc4Ch(GLD, E_ucDynamic,C_ucMmgDefaultChannel)
/*
#define M_GLDAlloc( Var, cast, ulSize, error )\
{\
M_GLDInitMmg();\
Var = (cast)Mmg_fn_p_vAlloc(ulSize);\
if ( Erm_M_uwCheckError( Mmg, C_ucErmDefaultChannel ) )\
{\
Var = NULL;\
Erm_M_ClearLastError( C_ucErmDefaultChannel );\
Erm_M_UpdateLastError( GLD, C_ucErmDefaultChannel, (error), C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, _szPersonalMsg_ );\
}\
}
*/
#define M_GLDAlloc( Var, cast, ulSize, error )\
{\
M_GLDInitMmg();\
Var = (cast)Mmg_fn_p_vAlloc(ulSize);\
}
/*#define M_GLDFree( p_cAdr ) \
{\
M_GLDInitMmg();\
Mmg_fn_vFree( p_cAdr );\
if ( Erm_M_uwCheckError( Mmg, C_ucErmDefaultChannel ) )\
{\
Erm_M_ClearLastError( C_ucErmDefaultChannel );\
Erm_M_UpdateLastError( GLD, C_ucErmDefaultChannel, E_uwGLDWarningCanNotFree, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, _szPersonalMsg_ );\
}\
}
*/
#define M_GLDFree( p_cAdr ) \
{\
M_GLDInitMmg();\
Mmg_fn_vFree( p_cAdr );\
}
typedef float GLD_tdxValue ;
#define GLD_M_LongToValue(A) ( (GLD_tdxValue) ( A ) )
#define GLD_M_Mul(A,B) (GLD_tdxValue)( ( A ) * ( B ) )
#define GLD_M_Sub(A,B) (GLD_tdxValue)( ( A ) - ( B ) )
#define GLD_M_Add(A,B) (GLD_tdxValue)( ( A ) + ( B ) )
#define GLD_M_Div(A,B) (GLD_tdxValue)( ( A ) / ( B ) )
#define GLD_M_Neg(A) ( -( A ) )
#endif /* __GLDMACROS_H__*/

View File

@@ -0,0 +1,780 @@
/* GLD : Devices and ViewPorts managing with DirectDraw.*/
/* PixFmt.c*/
/* Author : Frederic PHILIPPE*/
/* Last Update : 08/07/1997*/
#include "acp_base.h"
#include "GldInc.h"
#include "GLD/PixFmt.h"
#include "DLLCaps.h"
void GLD_vConvert16bColors2FloatColorMultipliedByFactorAndAddToDest( GLD_tdstPixelFormat *p_stDstPixelFormat, unsigned short *p_PixelSrc , float *p_ColorsDest , unsigned long Lenght , float fYBilinearFactor )
{
unsigned short *p_PixelSrcLast;
unsigned long ulRed, ulGreen, ulBlue,lRedDstShift,lGreenDstShift,lBlueDstShift;
p_PixelSrcLast = p_PixelSrc + Lenght;
lRedDstShift = 8-p_stDstPixelFormat->lRedNbBits;
lGreenDstShift = 8-p_stDstPixelFormat->lGreenNbBits;
lBlueDstShift = 8-p_stDstPixelFormat->lBlueNbBits;
for (;p_PixelSrc < p_PixelSrcLast;p_PixelSrc++,p_ColorsDest += 4)
{
ulRed = ((unsigned long)*p_PixelSrc) >> p_stDstPixelFormat->lRedShift;
ulRed = ulRed << lRedDstShift;
ulRed &= 0xff;
*(p_ColorsDest + 1) = ((float)(ulRed)) * fYBilinearFactor;
ulGreen = ((unsigned long )*p_PixelSrc) >> p_stDstPixelFormat->lGreenShift;
ulGreen = ulGreen << lGreenDstShift;
ulGreen &= 0xff;
*(p_ColorsDest + 2) = ((float)(ulGreen)) * fYBilinearFactor;
ulBlue = ((unsigned long )*p_PixelSrc) >> p_stDstPixelFormat->lBlueShift;
ulBlue = ulBlue << lBlueDstShift;
ulBlue &= 0xff;
*(p_ColorsDest + 3) = ((float)(ulBlue)) * fYBilinearFactor;
}
*(p_ColorsDest) = *(p_ColorsDest - 4);
p_ColorsDest++;
*(p_ColorsDest) = *(p_ColorsDest - 4);
p_ColorsDest++;
*(p_ColorsDest) = *(p_ColorsDest - 4);
p_ColorsDest++;
*(p_ColorsDest) = *(p_ColorsDest - 4);
}
void GLD_vConvertFloatColors2ARGBColor(float *p_ColorsSrc ,unsigned char *p_PixelDest , unsigned long Lenght )
{
float *p_ColorsSrcLast;
p_ColorsSrcLast = p_ColorsSrc + (Lenght << 2);
for (;p_ColorsSrc < p_ColorsSrcLast;p_ColorsSrc += 4)
{
*(p_PixelDest++) = (unsigned char)*(p_ColorsSrc+3);
*(p_PixelDest++) = (unsigned char)*(p_ColorsSrc+2);
*(p_PixelDest++) = (unsigned char)*(p_ColorsSrc+1);
}
}
void GLD_vCompressLineAddToDestAA(float *p_PixelSrc , float *p_ColorsDest , unsigned long LenghtSource , unsigned long LenghtDest , float fYBilinearFactor )
{
float fSlaveIncDst , fXSlaveCountDst , fXSlaveCountDstOld , fXLocalFactor;
float fSourceColorR,fSourceColorG,fSourceColorB;
float fXBilinearFactor;
float *p_fCurrentColorDST ;
unsigned long XCounter , XCounterOld ,XBoucle;
if (LenghtSource == LenghtDest)
{
for (XCounter = 0 ; XCounter < LenghtSource ; XCounter ++ , p_PixelSrc += 4 , p_ColorsDest += 4)
{
*p_PixelSrc = fYBilinearFactor;
*(p_ColorsDest + 1) += *(p_PixelSrc + 1) * fYBilinearFactor;
*(p_ColorsDest + 2) += *(p_PixelSrc + 2) * fYBilinearFactor;
*(p_ColorsDest + 3) += *(p_PixelSrc + 3) * fYBilinearFactor;
}
return;
}
if (LenghtSource > LenghtDest)
{
fSlaveIncDst = (float)LenghtDest / (float)LenghtSource;
fXSlaveCountDst = 0.0f;
for (XCounterOld = XCounter = XBoucle = 0 ; XBoucle < LenghtSource ; XBoucle ++ , p_PixelSrc += 4 , fXSlaveCountDst += fSlaveIncDst)
{
XCounter = (long)fXSlaveCountDst;
p_fCurrentColorDST = (p_ColorsDest + (XCounter << 2));
fXBilinearFactor = fXSlaveCountDst - XCounter;
fSourceColorR = *(p_PixelSrc + 1);
fSourceColorG = *(p_PixelSrc + 2);
fSourceColorB = *(p_PixelSrc + 3);
if (XCounterOld != XCounter)
{
fXLocalFactor = fYBilinearFactor * ((float)XCounter - fXSlaveCountDstOld);
*(p_fCurrentColorDST - 4) += fXLocalFactor;
*(p_fCurrentColorDST - 4 + 1) += fXLocalFactor * fSourceColorR;
*(p_fCurrentColorDST - 4 + 2) += fXLocalFactor * fSourceColorG;
*(p_fCurrentColorDST - 4 + 3) += fXLocalFactor * fSourceColorB;
fXLocalFactor = fYBilinearFactor * (fXSlaveCountDst - XCounter);
}
else
fXLocalFactor = fYBilinearFactor * fSlaveIncDst;
XCounterOld = XCounter;
fXSlaveCountDstOld = fXSlaveCountDst;
*(p_fCurrentColorDST) += fXLocalFactor;
*(p_fCurrentColorDST + 1) += fXLocalFactor * fSourceColorR;
*(p_fCurrentColorDST + 2) += fXLocalFactor * fSourceColorG;
*(p_fCurrentColorDST + 3) += fXLocalFactor * fSourceColorB;
}
}
else
{
fSlaveIncDst = (float)LenghtSource / (float)LenghtDest;
fXSlaveCountDst = 0.0f;
for (XBoucle = 0 ; XBoucle < LenghtDest ; XBoucle ++ , p_ColorsDest += 4 ,fXSlaveCountDst += fSlaveIncDst)
{
XCounter = (long)fXSlaveCountDst;
fXBilinearFactor = fXSlaveCountDst - XCounter;
fXLocalFactor = fYBilinearFactor ;
p_fCurrentColorDST = (p_PixelSrc + (XCounter << 2));
fSourceColorR = (1.0f - fXBilinearFactor) * *(p_fCurrentColorDST + 1) + (fXBilinearFactor) * *(p_fCurrentColorDST + 1 + 4);
fSourceColorG = (1.0f - fXBilinearFactor) * *(p_fCurrentColorDST + 2) + (fXBilinearFactor) * *(p_fCurrentColorDST + 2 + 4);
fSourceColorB = (1.0f - fXBilinearFactor) * *(p_fCurrentColorDST + 3) + (fXBilinearFactor) * *(p_fCurrentColorDST + 3 + 4);
fXLocalFactor = fYBilinearFactor;
*(p_ColorsDest) += fXLocalFactor;
*(p_ColorsDest + 1) += fXLocalFactor * fSourceColorR;
*(p_ColorsDest + 2) += fXLocalFactor * fSourceColorG;
*(p_ColorsDest + 3) += fXLocalFactor * fSourceColorB;
}
}
}
extern GLD_tdstViewport *GLD_pGetViewport(GLD_tdhDevice, GLD_tdhViewport);
extern GLD_tdstDevice *GLD_pGetDevice(GLD_tdhDevice);
GLD_tdstPixelFormat GLD_g_aDEFstDefinedPixelFormats[GLD_C_lMaxNumberOfPixelFormat] =
{ /* FORMAT |ALPHA | PIXEL | RED | GREEN | BLUE | ALPHA */
/* 0*/{ GLD_C_xUndefinedPixelFormat, FALSE, 0, 0x00000000, 0, 0, 0, 0x00000000, 0, 0, 0x00000000, 0, 0, 0x00000000, 0, 0, 0x00000000 },
/* 1*/{ GLD_C_xN1B5G5R5PixelFormat, FALSE, 16, 0x0000FFFF, 2, 5, 0, 0x0000001F, 5, 5, 0x000003E0, 5, 10, 0x00007C00, 0, 0, 0x00000000 },
/* 2*/{ GLD_C_xA1B5G5R5PixelFormat, TRUE, 16, 0x0000FFFF, 2, 5, 0, 0x0000001F, 5, 5, 0x000003E0, 5, 10, 0x00007C00, 1, 15, 0x00008000 },
/* 3*/{ GLD_C_xN1R5G5B5PixelFormat, FALSE, 16, 0x0000FFFF, 2, 5, 10, 0x00007C00, 5, 5, 0x000003E0, 5, 0, 0x0000001F, 0, 0, 0x00000000 },
/* 4*/{ GLD_C_xA4B4G4R4PixelFormat, TRUE, 16, 0x0000FFFF, 2, 4, 0, 0x0000000F, 4, 4, 0x000000F0, 4, 8, 0x00000F00, 4, 12, 0x0000F000 },
/* 5*/{ GLD_C_xB8G8R8PixelFormat, FALSE, 24, 0x00FFFFFF, 3, 8, 0, 0x000000FF, 8, 8, 0x0000FF00, 8, 16, 0x0000FF00, 0, 0, 0x00000000 },
/* 6*/{ GLD_C_xA8B8G8R8PixelFormat, TRUE, 32, 0xFFFFFFFF, 4, 8, 0, 0x000000FF, 8, 8, 0x0000FF00, 8, 16, 0x0000FF00, 8, 24, 0xFF000000 },
/* 7*/{ GLD_C_xB5G6R5PixelFormat, FALSE, 16, 0x0000FFFF, 2, 5, 0, 0x0000001F, 6, 5, 0x000007E0, 5, 11, 0x0000F800, 0, 0, 0x00000000 },
/* 8*/{ GLD_C_xB6G5R5PixelFormat, FALSE, 16, 0x0000FFFF, 2, 5, 0, 0x0000001F, 5, 5, 0x000003E0, 6, 10, 0x0000FC00, 0, 0, 0x00000000 },
/* 9*/{ GLD_C_xB5G5R6PixelFormat, FALSE, 16, 0x0000FFFF, 2, 6, 0, 0x0000002F, 5, 6, 0x000007C0, 5, 11, 0x0000F800, 0, 0, 0x00000000 },
/*10*/{ GLD_C_xB5G5R5A1PixelFormat, TRUE, 16, 0x0000FFFF, 2, 5, 1, 0x0000003E, 5, 6, 0x000007C0, 5, 11, 0x0000F800, 1, 0, 0x00000001 },
/*11*/{ GLD_C_xR5G6B5PixelFormat, FALSE, 16, 0x0000FFFF, 2, 5, 11, 0x0000F800, 6, 5, 0x000007E0, 5, 0, 0x0000001F, 0, 0, 0x00000000 },
/*12*/{ GLD_C_xR6G5B5PixelFormat, FALSE, 16, 0x0000FFFF, 2, 6, 10, 0x0000FC00, 5, 5, 0x000003E0, 5, 0, 0x0000001F, 0, 0, 0x00000000 },
/*13*/{ GLD_C_xR5G5B6PixelFormat, FALSE, 16, 0x0000FFFF, 2, 5, 11, 0x0000F800, 5, 6, 0x000007C0, 6, 0, 0x0000002F, 0, 0, 0x00000000 }
};
ACP_tdxIndex GLD_g_xNumberOfDefinedPixelFormats = 14;
void GLD_vSetDefinedPixelFormat ( GLD_tdpstPixelFormat p_stPixelFormat, ACP_tdxIndex xPixelFormatNumber )
{
memcpy ( p_stPixelFormat, &GLD_g_aDEFstDefinedPixelFormats[xPixelFormatNumber], sizeof ( GLD_tdstPixelFormat ) );
}
void GLD_vCopyPixelFormat ( GLD_tdpstPixelFormat p_stDstPixelFormat, GLD_tdpstPixelFormat p_stSrcPixelFormat )
{
memcpy ( p_stDstPixelFormat, p_stSrcPixelFormat, sizeof ( GLD_tdstPixelFormat ) );
}
GLD_tdstPixelFormat *GLD_fn_p_stGetDefinedPixelFormat( long _lFormatIndex )
{
if ( (unsigned long) _lFormatIndex >= (unsigned long) GLD_g_xNumberOfDefinedPixelFormats )
return NULL;
return &GLD_g_aDEFstDefinedPixelFormats[ _lFormatIndex ];
}
long GLD_fn_lAddDefinedPixelFormat( GLD_tdstPixelFormat *_p_stNewPF )
{
if ( GLD_g_xNumberOfDefinedPixelFormats == GLD_C_lMaxNumberOfPixelFormat )
return -1;
_p_stNewPF->xFormatNumber = GLD_g_xNumberOfDefinedPixelFormats;
GLD_vCopyPixelFormat( &GLD_g_aDEFstDefinedPixelFormats[ GLD_g_xNumberOfDefinedPixelFormats ], _p_stNewPF );
GLD_g_xNumberOfDefinedPixelFormats++;
return (_p_stNewPF->xFormatNumber );
}
/*
long GLD_lConvertMaskToShift ( unsigned long ulMask )
{
if ( ulMask & 0x00000001 ) return 0;
if ( ulMask & 0x00000002 ) return 1;
if ( ulMask & 0x00000004 ) return 2;
if ( ulMask & 0x00000008 ) return 3;
if ( ulMask & 0x00000010 ) return 4;
if ( ulMask & 0x00000020 ) return 5;
if ( ulMask & 0x00000040 ) return 6;
if ( ulMask & 0x00000080 ) return 7;
if ( ulMask & 0x00000100 ) return 8;
if ( ulMask & 0x00000200 ) return 9;
if ( ulMask & 0x00000400 ) return 10;
if ( ulMask & 0x00000800 ) return 11;
if ( ulMask & 0x00001000 ) return 12;
if ( ulMask & 0x00002000 ) return 13;
if ( ulMask & 0x00004000 ) return 14;
if ( ulMask & 0x00008000 ) return 15;
if ( ulMask & 0x00010000 ) return 16;
if ( ulMask & 0x00020000 ) return 17;
if ( ulMask & 0x00040000 ) return 18;
if ( ulMask & 0x00080000 ) return 19;
if ( ulMask & 0x00100000 ) return 20;
if ( ulMask & 0x00200000 ) return 21;
if ( ulMask & 0x00400000 ) return 22;
if ( ulMask & 0x00800000 ) return 23;
if ( ulMask & 0x01000000 ) return 24;
if ( ulMask & 0x02000000 ) return 25;
if ( ulMask & 0x04000000 ) return 26;
if ( ulMask & 0x08000000 ) return 27;
if ( ulMask & 0x10000000 ) return 28;
if ( ulMask & 0x20000000 ) return 29;
if ( ulMask & 0x40000000 ) return 30;
if ( ulMask & 0x80000000 ) return 31;
return 0;
}
unsigned long GLD_ulConvertNbBitsToMask ( long lNbBits )
{
if ( lNbBits == 0 ) return 0x00000000;
if ( lNbBits == 1 ) return 0x00000001;
if ( lNbBits == 2 ) return 0x00000003;
if ( lNbBits == 3 ) return 0x00000007;
if ( lNbBits == 4 ) return 0x0000000F;
if ( lNbBits == 5 ) return 0x0000001F;
if ( lNbBits == 6 ) return 0x0000003F;
if ( lNbBits == 7 ) return 0x0000007F;
if ( lNbBits == 8 ) return 0x000000FF;
if ( lNbBits == 9 ) return 0x000001FF;
if ( lNbBits == 10 ) return 0x000003FF;
if ( lNbBits == 11 ) return 0x000007FF;
if ( lNbBits == 12 ) return 0x00000FFF;
if ( lNbBits == 13 ) return 0x00001FFF;
if ( lNbBits == 14 ) return 0x00003FFF;
if ( lNbBits == 15 ) return 0x00007FFF;
if ( lNbBits == 16 ) return 0x0000FFFF;
if ( lNbBits == 17 ) return 0x0001FFFF;
if ( lNbBits == 18 ) return 0x0003FFFF;
if ( lNbBits == 19 ) return 0x0007FFFF;
if ( lNbBits == 20 ) return 0x000FFFFF;
if ( lNbBits == 21 ) return 0x001FFFFF;
if ( lNbBits == 22 ) return 0x003FFFFF;
if ( lNbBits == 23 ) return 0x007FFFFF;
if ( lNbBits == 24 ) return 0x00FFFFFF;
if ( lNbBits == 25 ) return 0x01FFFFFF;
if ( lNbBits == 26 ) return 0x03FFFFFF;
if ( lNbBits == 27 ) return 0x07FFFFFF;
if ( lNbBits == 28 ) return 0x0FFFFFFF;
if ( lNbBits == 29 ) return 0x1FFFFFFF;
if ( lNbBits == 30 ) return 0x3FFFFFFF;
if ( lNbBits == 31 ) return 0x7FFFFFFF;
if ( lNbBits == 32 ) return 0xFFFFFFFF;
return 0x00000000;
}
long GLD_lConvertMaskToNbBits ( unsigned long ulMask )
{
if ( ulMask == 0x00000000 ) return 0;
if ( ulMask == 0x00000001 ) return 1;
if ( ulMask == 0x00000003 ) return 2;
if ( ulMask == 0x00000007 ) return 3;
if ( ulMask == 0x0000000F ) return 4;
if ( ulMask == 0x0000001F ) return 5;
if ( ulMask == 0x0000003F ) return 6;
if ( ulMask == 0x0000007F ) return 7;
if ( ulMask == 0x000000FF ) return 8;
if ( ulMask == 0x000001FF ) return 9;
if ( ulMask == 0x000003FF ) return 10;
if ( ulMask == 0x000007FF ) return 11;
if ( ulMask == 0x00000FFF ) return 12;
if ( ulMask == 0x00001FFF ) return 13;
if ( ulMask == 0x00003FFF ) return 14;
if ( ulMask == 0x00007FFF ) return 15;
if ( ulMask == 0x0000FFFF ) return 16;
if ( ulMask == 0x0001FFFF ) return 17;
if ( ulMask == 0x0003FFFF ) return 18;
if ( ulMask == 0x0007FFFF ) return 19;
if ( ulMask == 0x000FFFFF ) return 20;
if ( ulMask == 0x001FFFFF ) return 21;
if ( ulMask == 0x003FFFFF ) return 22;
if ( ulMask == 0x007FFFFF ) return 23;
if ( ulMask == 0x00FFFFFF ) return 24;
if ( ulMask == 0x01FFFFFF ) return 25;
if ( ulMask == 0x03FFFFFF ) return 26;
if ( ulMask == 0x07FFFFFF ) return 27;
if ( ulMask == 0x0FFFFFFF ) return 28;
if ( ulMask == 0x1FFFFFFF ) return 29;
if ( ulMask == 0x3FFFFFFF ) return 30;
if ( ulMask == 0x7FFFFFFF ) return 31;
if ( ulMask == 0xFFFFFFFF ) return 32;
return 0;
}
/*
ACP_tdxBool GLD_bEqualRGBMask ( GLD_tdpstPixelFormat p_stPixelFormat, DDPIXELFORMAT *p_stDDPixelFormat )
{
return ( p_stPixelFormat->ulRedMask == p_stDDPixelFormat->dwRBitMask ) && ( p_stPixelFormat->ulGreenMask == p_stDDPixelFormat->dwGBitMask ) && ( p_stPixelFormat->ulBlueMask == p_stDDPixelFormat->dwBBitMask );
}
ACP_tdxBool GLD_bEqualRGBAMask ( GLD_tdpstPixelFormat p_stPixelFormat, DDPIXELFORMAT *p_stDDPixelFormat )
{
return ( p_stPixelFormat->ulRedMask == p_stDDPixelFormat->dwRBitMask ) && ( p_stPixelFormat->ulGreenMask == p_stDDPixelFormat->dwGBitMask )
&& ( p_stPixelFormat->ulBlueMask == p_stDDPixelFormat->dwBBitMask ) && ( p_stPixelFormat->ulAlphaMask == p_stDDPixelFormat->dwRGBAlphaBitMask );
}
void GLD_vConvertDDPixelFormatToPixelFormat ( ACP_tdxIndex xFormatNumber, GLD_tdpstPixelFormat p_stDstPixelFormat, LPDDPIXELFORMAT p_stDDPixelFormat )
{
p_stDstPixelFormat->xFormatNumber = xFormatNumber;
p_stDstPixelFormat->bAlpha = (unsigned char) (p_stDDPixelFormat->dwFlags & DDPF_ALPHAPIXELS);
p_stDstPixelFormat->lPixelNbBits = p_stDDPixelFormat->dwRGBBitCount;
p_stDstPixelFormat->ulPixelMask = GLD_ulConvertNbBitsToMask ( p_stDstPixelFormat->lPixelNbBits );
p_stDstPixelFormat->lPixelNbBytes = p_stDstPixelFormat->lPixelNbBits/8;
p_stDstPixelFormat->ulRedMask = p_stDDPixelFormat->dwRBitMask;
p_stDstPixelFormat->lRedShift = GLD_lConvertMaskToShift ( p_stDstPixelFormat->ulRedMask );
p_stDstPixelFormat->lRedNbBits = GLD_lConvertMaskToNbBits ( p_stDstPixelFormat->ulRedMask >> p_stDstPixelFormat->lRedShift );
p_stDstPixelFormat->ulGreenMask = p_stDDPixelFormat->dwGBitMask;
p_stDstPixelFormat->lGreenShift = GLD_lConvertMaskToShift ( p_stDstPixelFormat->ulGreenMask );
p_stDstPixelFormat->lGreenNbBits = GLD_lConvertMaskToNbBits ( p_stDstPixelFormat->ulGreenMask >> p_stDstPixelFormat->lGreenShift );
p_stDstPixelFormat->ulBlueMask = p_stDDPixelFormat->dwBBitMask;
p_stDstPixelFormat->lBlueShift = GLD_lConvertMaskToShift ( p_stDstPixelFormat->ulBlueMask );
p_stDstPixelFormat->lBlueNbBits = GLD_lConvertMaskToNbBits ( p_stDstPixelFormat->ulBlueMask >> p_stDstPixelFormat->lBlueShift );
if ( p_stDstPixelFormat->bAlpha )
{
p_stDstPixelFormat->ulAlphaMask = p_stDDPixelFormat->dwRGBAlphaBitMask;
p_stDstPixelFormat->lAlphaShift = GLD_lConvertMaskToShift ( p_stDstPixelFormat->ulAlphaMask );
p_stDstPixelFormat->lAlphaNbBits= GLD_lConvertMaskToNbBits ( p_stDstPixelFormat->ulAlphaMask >> p_stDstPixelFormat->lAlphaShift );
}
else
{
p_stDstPixelFormat->ulAlphaMask = 0x00000000;
p_stDstPixelFormat->lAlphaShift = 0;
p_stDstPixelFormat->lAlphaNbBits= 0;
}
}
*/
/*
ACP_tdxBool GLD_bConvertDDPixelFormatToDefinedPixelFormat ( GLD_tdpstPixelFormat p_stDstPixelFormat, LPDDPIXELFORMAT p_stDDPixelFormat )
{
ACP_tdxIndex xFormatIndex;
if ( p_stDDPixelFormat->dwFlags & DDPF_RGB )
{
for ( xFormatIndex = 0 ; xFormatIndex < GLD_g_xNumberOfDefinedPixelFormats ; xFormatIndex ++ )
{
if ( (unsigned long)(GLD_g_aDEFstDefinedPixelFormats[xFormatIndex].lPixelNbBits) == p_stDDPixelFormat->dwRGBBitCount )
{
if ( p_stDDPixelFormat->dwFlags & DDPF_ALPHAPIXELS )
{
if ( ( GLD_g_aDEFstDefinedPixelFormats[xFormatIndex].bAlpha ) && ( GLD_bEqualRGBAMask ( &GLD_g_aDEFstDefinedPixelFormats[xFormatIndex], p_stDDPixelFormat ) ) )
{
GLD_vSetDefinedPixelFormat ( p_stDstPixelFormat, xFormatIndex );
return TRUE;
}
}
else
{
if ( ( !GLD_g_aDEFstDefinedPixelFormats[xFormatIndex].bAlpha ) && ( GLD_bEqualRGBMask ( &GLD_g_aDEFstDefinedPixelFormats[xFormatIndex], p_stDDPixelFormat ) ) )
{
GLD_vSetDefinedPixelFormat ( p_stDstPixelFormat, xFormatIndex );
return TRUE;
}
}
}
}
/* ajout dans la table */
/*
GLD_vConvertDDPixelFormatToPixelFormat ( xFormatIndex, &(GLD_g_aDEFstDefinedPixelFormats[xFormatIndex]), p_stDDPixelFormat );
GLD_g_xNumberOfDefinedPixelFormats ++;
GLD_vSetDefinedPixelFormat ( p_stDstPixelFormat, xFormatIndex );
return TRUE;
}
else
{
return FALSE;
}
}
*/
ACP_tdxBool GLD_bGetPixelFormatOfDevice ( GLD_tdpstPixelFormat p_stDstPixelFormat, GLD_tdhDevice hDev, GLD_tdhViewport hVP )
{
GLD_tdpstDevice p_stDev; /* Pointer to structure Device*/
p_stDev = GLD_pGetDevice( hDev );
if (p_stDev == NULL)
return FALSE;
GLD_vSetDefinedPixelFormat ( p_stDstPixelFormat, GLI_g_stCaps.ucPrimarySurfacePixelFormat );
/*GLD_vSetDefinedPixelFormat ( p_stDstPixelFormat, GLD_C_xR5G6B5PixelFormat );*/
return TRUE;
}
/* attention : convertion entre les formats RGB 16 bits seulement */
void GLD_vBitmapConvert16bPixelFormat ( GLD_tdpstPixelFormat p_stDstPixelFormat, GLD_tdpstPixelFormat p_stSrcPixelFormat, unsigned short *p_usBuffer, long lBufferSize )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned short *p_usBufferIndex;
unsigned short *p_usBufferEnd;
unsigned short usRed;
unsigned short usGreen;
unsigned short usBlue;
long lRedSrcShift;
long lGreenSrcShift;
long lBlueSrcShift;
long lRedDstShift;
long lGreenDstShift;
long lBlueDstShift;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if ( p_stDstPixelFormat->xFormatNumber != p_stSrcPixelFormat->xFormatNumber )
{
lRedSrcShift = 8-p_stSrcPixelFormat->lRedNbBits;
lGreenSrcShift = 8-p_stSrcPixelFormat->lGreenNbBits;
lBlueSrcShift = 8-p_stSrcPixelFormat->lBlueNbBits;
lRedDstShift = 8-p_stDstPixelFormat->lRedNbBits;
lGreenDstShift = 8-p_stDstPixelFormat->lGreenNbBits;
lBlueDstShift = 8-p_stDstPixelFormat->lBlueNbBits;
/* format intermediaire 888 */
for ( p_usBufferEnd = p_usBuffer + lBufferSize/2, p_usBufferIndex = p_usBuffer ; p_usBufferIndex < p_usBufferEnd ; p_usBufferIndex ++ )
{
usRed = (*p_usBufferIndex & (unsigned short)(p_stSrcPixelFormat->ulRedMask)) >> p_stSrcPixelFormat->lRedShift;
usRed = usRed << lRedSrcShift;
usRed = usRed >> lRedDstShift;
usGreen = (*p_usBufferIndex & (unsigned short)(p_stSrcPixelFormat->ulGreenMask)) >> p_stSrcPixelFormat->lGreenShift;
usGreen = usGreen << lGreenSrcShift;
usGreen = usGreen >> lGreenDstShift;
usBlue = (*p_usBufferIndex & (unsigned short)(p_stSrcPixelFormat->ulBlueMask)) >> p_stSrcPixelFormat->lBlueShift;
usBlue = usBlue << lBlueSrcShift;
usBlue = usBlue >> lBlueDstShift;
*p_usBufferIndex = (usRed << p_stDstPixelFormat->lRedShift) | (usGreen << p_stDstPixelFormat->lGreenShift) | (usBlue << p_stDstPixelFormat->lBlueShift);
}
}
}
/* attention : inversion Y d un buffer RGB 24 bits (source BMP) */
void GLD_vYInvertBitmap24b ( unsigned char *_p_ucBuffer, long _lWidth, long _lHeight )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long ly;
unsigned char *p_ucUpOffset;
unsigned char *p_ucBottomOffset;
long lLineSize;
unsigned char a6144_ucTmp[6144];
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
lLineSize = 3*_lWidth;
p_ucUpOffset = _p_ucBuffer;
p_ucBottomOffset = _p_ucBuffer+lLineSize*(_lHeight-1);
for ( ly = 0 ; ly < _lHeight/2 ; ly ++ )
{
memcpy ( a6144_ucTmp, p_ucBottomOffset, lLineSize );
memcpy ( p_ucBottomOffset, p_ucUpOffset, lLineSize );
memcpy ( p_ucUpOffset, a6144_ucTmp, lLineSize );
p_ucUpOffset += lLineSize;
p_ucBottomOffset -= lLineSize;
}
}
/* attention : convertion d une bitmap B8G8R8 24 bits au B5G6R5 16 bits */
void GLD_vBitmapConvert24bTo16bPixelFormat ( unsigned short *_p_usDstBuffer, unsigned char *_p_ucSrcBuffer, long _lWidth, long _lHeight )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lx, ly;
unsigned long ulRed, ulGreen, ulBlue;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
for ( ly = 0 ; ly < _lHeight ; ly ++ )
{
for ( lx = 0 ; lx < _lWidth ; lx ++ )
{
ulBlue = (unsigned long)(*_p_ucSrcBuffer++);
ulGreen = (unsigned long)(*_p_ucSrcBuffer++);
ulRed = (unsigned long)(*_p_ucSrcBuffer++);
_p_usDstBuffer[lx+_lWidth*ly] = (unsigned short)(((ulBlue>>3)<<11) | ((ulGreen>>2)<<5) | (ulRed>>3));
}
}
}
/* attention : convertion d une bitmap B8G8R8 24 bits au B5G6R5 16 bits */
void GLD_vBitmapConvert24bTo16bPixelFormatAndFiltre ( unsigned short *_p_usDstBuffer, long _lWDst, long _lHDst, unsigned char *_p_ucSrcBuffer, long _lWSrc, long _lHSrc )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lXDst;
long lYDst;
long lXSrc;
long lYSrc;
float fWSrcDWDst;
float fHSrcDHDst;
float fXSrc;
float fYSrc;
float fFactX;
float fFactY;
unsigned char *p_ucPixel;
float fRed, fGreen, fBlue;
float fRed1, fGreen1, fBlue1;
float fRed2, fGreen2, fBlue2;
float fRed3, fGreen3, fBlue3;
float fRed4, fGreen4, fBlue4;
float fRed5, fGreen5, fBlue5;
float fRed6, fGreen6, fBlue6;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
_lWSrc --;
_lHSrc --;
fWSrcDWDst = ((float)_lWSrc)/((float)_lWDst);
fHSrcDHDst = ((float)_lHSrc)/((float)_lHDst);
for ( lYDst = 0, fYSrc = 0.0f ; lYDst < _lHDst ; lYDst ++, fYSrc += fHSrcDHDst )
{
for ( lXDst = 0, fXSrc = 0.0f ; lXDst < _lWDst ; lXDst ++, fXSrc += fWSrcDWDst )
{
lXSrc = (lXDst * _lWSrc)/_lWDst;
lYSrc = (lYDst * _lHSrc)/_lHDst;
fFactX = fXSrc - (float)lXSrc;
fFactY = fYSrc - (float)lYSrc;
p_ucPixel = _p_ucSrcBuffer + 3*(lXSrc+(_lWSrc+1)*lYSrc);
/* ulRed1, ulGreen1, ulBlue1 */
fBlue1 = (float)(*p_ucPixel++);
fGreen1 = (float)(*p_ucPixel++);
fRed1 = (float)(*p_ucPixel++);
/* ulRed2, ulGreen2, ulBlue2 */
fBlue2 = (float)(*p_ucPixel++);
fGreen2 = (float)(*p_ucPixel++);
fRed2 = (float)(*p_ucPixel);
p_ucPixel += 3*(_lWSrc+1)-5;
/* ulRed3, ulGreen3, ulBlue3 */
fBlue3 = (float)(*p_ucPixel++);
fGreen3 = (float)(*p_ucPixel++);
fRed3 = (float)(*p_ucPixel++);
/* ulRed4, ulGreen4, ulBlue4 */
fBlue4 = (float)(*p_ucPixel++);
fGreen4 = (float)(*p_ucPixel++);
fRed4 = (float)(*p_ucPixel);
fRed5 = fRed1 + fFactX * (fRed2 - fRed1);
fGreen5 = fGreen1 + fFactX * (fGreen2 - fGreen1);
fBlue5 = fBlue1 + fFactX * (fBlue2 - fBlue1);
fRed6 = fRed3 + fFactX * (fRed4 - fRed3);
fGreen6 = fGreen3 + fFactX * (fGreen4 - fGreen3);
fBlue6 = fBlue3 + fFactX * (fBlue4 - fBlue3);
fRed = fRed5 + fFactY * (fRed6 - fRed5);
fGreen = fGreen5 + fFactY * (fGreen6 - fGreen5);
fBlue = fBlue5 + fFactY * (fBlue6 - fBlue5);
*_p_usDstBuffer = (unsigned short)((((unsigned long)fBlue>>3)<<11) | (((unsigned long)fGreen>>2)<<5) | ((unsigned long)fRed>>3));
_p_usDstBuffer ++;
}
}
}
void GLD_fn_vBlit16b ( long _lW, long _lH, unsigned short *_p_usBufferDst, long _lPitch, unsigned short *_p_usBufferSrc )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lXDst;
long lYDst;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
for ( lYDst = 0 ; lYDst < _lH ; lYDst ++ )
{
for ( lXDst = 0 ; lXDst < _lW ; lXDst ++ )
{
*_p_usBufferDst = *_p_usBufferSrc;
_p_usBufferDst ++;
_p_usBufferSrc ++;
}
_p_usBufferDst += _lPitch - _lW;
}
}
void GLD_fn_vBlitStretched16b ( long _lWDst, long _lHDst, unsigned short *_p_usBufferDst, long _lPitch, long _lWSrc, long _lHSrc, unsigned short *_p_usBufferSrc )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lXDst;
long lYDst;
long a2048_lOffsetXSrc[2048];
long a2048_lOffsetYSrc[2048];
unsigned short *p_usOffsetDst;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
p_usOffsetDst = _p_usBufferDst;
for ( lXDst = 0 ; lXDst < _lWDst ; lXDst ++ )
{
a2048_lOffsetXSrc[lXDst] = (lXDst * _lWSrc)/_lWDst;
}
for ( lYDst = 0 ; lYDst < _lHDst ; lYDst ++ )
{
a2048_lOffsetYSrc[lYDst] = _lWSrc * ((lYDst * _lHSrc)/_lHDst);
}
for ( lYDst = 0 ; lYDst < _lHDst ; lYDst ++ )
{
for ( lXDst = 0 ; lXDst < _lWDst ; lXDst ++ )
{
*p_usOffsetDst = *(_p_usBufferSrc + a2048_lOffsetXSrc[lXDst] + a2048_lOffsetYSrc[lYDst]);
p_usOffsetDst ++;
}
p_usOffsetDst += _lPitch - _lWDst;
}
}
void GLD_vBitmapConvertAndBlit24bTo16bPixelFormat ( GLD_tdhDevice _hGLDDevice, GLD_tdhViewport _hGLDViewport, long _lWidth, long _lHeight, unsigned char *_p_ucBufferSrc )
{
GLD_bFlipDevice ( _hGLDDevice );
}
void GLD_vGetFrontBufferIn24BitsAA( GLD_tdhDevice _hGLDDevice,GLD_tdhViewport _hGLDViewport,unsigned long _lWidth,unsigned long _lHeight,unsigned char *p_lBufferDst )
{
static float a2048ConvertBufferForAntialias[2048*4]; /* Count , Red , Green , Blue */
static float a2048ConvertBufferForAntialiasDest[2048*4]; /* Count , Red , Green , Blue */
GLD_tdstViewportAttributes stViewportAttr;
GLD_tdstPixelFormat stDstPixelFormat;
BOOL bCanWrite;
unsigned short *p_usBufferSrc;
unsigned long PitchSrc;
unsigned long WidthSrc,HeightSrc;
unsigned long YCounter,LocalCounter , XMAX;
unsigned long XCounter;
unsigned long ulYC1 , ulYCOLD ;
float fYInc, fYPos;
GLD_bGetPixelFormatOfDevice ( &stDstPixelFormat, _hGLDDevice, _hGLDViewport );
if ( !GLD_bRequestWriteToViewport2D ( _hGLDDevice, _hGLDViewport, &stViewportAttr, &bCanWrite ) )
return;
if ( !bCanWrite )
return;
PitchSrc = stViewportAttr.lPitch >> 1;
WidthSrc = stViewportAttr.dwWidth;
HeightSrc = stViewportAttr.dwHeight;
if (stDstPixelFormat.lPixelNbBits == 32 )
{
unsigned char *p_ucSrc;
if (HeightSrc != _lHeight)
return;
p_ucSrc = (unsigned char *) stViewportAttr.p_cVirtualScreen;
for (YCounter = 0; YCounter < _lHeight; YCounter++ )
{
for (XCounter = 0; XCounter < _lWidth; XCounter++)
{
*p_lBufferDst++ = *p_ucSrc++;
*p_lBufferDst++ = *p_ucSrc++;
*p_lBufferDst++ = *p_ucSrc++;
p_ucSrc++;
}
}
}
else if (stDstPixelFormat.lPixelNbBits == 16 )
{
if (WidthSrc > _lWidth)
XMAX = WidthSrc;
else
XMAX = _lWidth;
p_usBufferSrc = (unsigned short *)stViewportAttr.p_cVirtualScreen ;
if (HeightSrc == _lHeight)
{
/* nothing */
for (YCounter= 0 ; YCounter < _lHeight ; YCounter++ , p_lBufferDst += 3*_lWidth , p_usBufferSrc += PitchSrc)
{
for (LocalCounter = 0 ; LocalCounter < XMAX * 4 ; LocalCounter ++ )
{
a2048ConvertBufferForAntialias[LocalCounter] = 0.0f;
a2048ConvertBufferForAntialiasDest[LocalCounter] = 0.0f;
}
GLD_vConvert16bColors2FloatColorMultipliedByFactorAndAddToDest(&stDstPixelFormat, p_usBufferSrc , a2048ConvertBufferForAntialias , XMAX , 1.0f );
GLD_vCompressLineAddToDestAA(a2048ConvertBufferForAntialias , a2048ConvertBufferForAntialiasDest , WidthSrc , _lWidth , 1.0f);
GLD_vConvertFloatColors2ARGBColor(a2048ConvertBufferForAntialiasDest,p_lBufferDst , _lWidth);
}
}
else if (_lHeight > HeightSrc)
{
/* linear */
float *P_LineSrc;
float *P_LineDst;
float fYPosOld;
long YPos,YPosOld;
ulYC1 = ulYCOLD = 0;
fYInc = (float)HeightSrc / (float)_lHeight;
fYPosOld = fYPos = 0.0f;
P_LineSrc = a2048ConvertBufferForAntialias;
P_LineDst = a2048ConvertBufferForAntialiasDest;
YPos = YPosOld = 0;
for (YCounter= 0 ; YCounter < _lHeight ; YCounter++ , p_lBufferDst += 3*_lWidth , fYPos += fYInc)
{
YPos = (long)fYPos ;
if (YPos != YPosOld)
p_usBufferSrc += PitchSrc;
YPosOld = YPos ;
for (LocalCounter = 0 ; LocalCounter < XMAX * 4 ; LocalCounter ++ )
P_LineDst[LocalCounter] = 0.0f;
GLD_vConvert16bColors2FloatColorMultipliedByFactorAndAddToDest(&stDstPixelFormat, p_usBufferSrc , P_LineSrc , XMAX , 1.0f );
GLD_vCompressLineAddToDestAA(P_LineSrc , P_LineDst , WidthSrc , _lWidth , 1.0f - (fYPos - YPos) );
GLD_vConvert16bColors2FloatColorMultipliedByFactorAndAddToDest(&stDstPixelFormat, p_usBufferSrc + PitchSrc, P_LineSrc , XMAX , 1.0f );
GLD_vCompressLineAddToDestAA(P_LineSrc , P_LineDst , WidthSrc , _lWidth , (fYPos - YPos));
GLD_vConvertFloatColors2ARGBColor(P_LineDst,p_lBufferDst , _lWidth);
}
}
else if (_lHeight < HeightSrc)
{
/* Antialias */
float *P_LineSrc;
float *P_LineDst;
float fPonderation,fYPosOld;
ulYC1 = ulYCOLD = 0;
fYInc = (float)_lHeight / (float)HeightSrc;
fYPosOld = fYPos = 0.0f;
P_LineSrc = a2048ConvertBufferForAntialias;
P_LineDst = a2048ConvertBufferForAntialiasDest;
for (LocalCounter = 0 ; LocalCounter < XMAX * 4 ; LocalCounter ++ )
{
a2048ConvertBufferForAntialias[LocalCounter] = 0.0f;
a2048ConvertBufferForAntialiasDest[LocalCounter] = 0.0f;
}
for (YCounter= 0 ; YCounter < HeightSrc ; YCounter++ , p_usBufferSrc += PitchSrc , fYPos += fYInc)
{
ulYC1 = (long)fYPos;
if (ulYC1 != ulYCOLD)
{
GLD_vCompressLineAddToDestAA(P_LineSrc , P_LineDst , WidthSrc , _lWidth , (float)ulYC1 - fYPosOld);
GLD_vConvertFloatColors2ARGBColor(P_LineDst,p_lBufferDst , _lWidth);
for (LocalCounter = 0 ; LocalCounter < XMAX * 4 ; LocalCounter ++ )
P_LineDst[LocalCounter] = 0.0f;
p_lBufferDst += 3*_lWidth;
fPonderation = fYPos - ulYC1;
}
else
fPonderation = fYInc;
ulYCOLD = ulYC1 ;
fYPosOld = fYPos;
GLD_vConvert16bColors2FloatColorMultipliedByFactorAndAddToDest(&stDstPixelFormat, p_usBufferSrc , P_LineSrc , XMAX , 1.0f );
GLD_vCompressLineAddToDestAA(P_LineSrc , P_LineDst , WidthSrc , _lWidth , fPonderation);
}
}
}
GLD_bWriteToViewportFinished2D ( _hGLDDevice, _hGLDViewport );
}

View File

@@ -0,0 +1,69 @@
Microsoft Developer Studio Workspace File, Format Version 5.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "DirectX6"=.\Drivers\DirectX6\DirectX6.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "GLIGLOU"=.\MultiDRV\GliGlou.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "Glide2"=.\Drivers\GLIDE2\Glide2.dsp - Package Owner=<4>
Package=<5>
{{{
begin source code control
"$/cpa/tempgrp/GliGlou/Drivers/GLIDE2", MVPAAAAA
.\drivers\glide2
end source code control
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "Main"=..\..\main\Make\Main.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -0,0 +1,567 @@
# Microsoft Developer Studio Project File - Name="GLIGLOU" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=GLIGLOU - Win32 Exgeom debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "GliGlou.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "GliGlou.mak" CFG="GLIGLOU - Win32 Exgeom debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "GLIGLOU - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "GLIGLOU - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "GLIGLOU - Win32 Retail" (based on "Win32 (x86) Static Library")
!MESSAGE "GLIGLOU - Win32 Exgeom debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""$/cpa/tempgrp/GliGlou/MultiDRV", KWPAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
!IF "$(CFG)" == "GLIGLOU - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Tmp\Release"
# PROP Intermediate_Dir "Tmp\Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /G6 /W3 /GX /Z7 /O2 /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /D "NDEBUG" /D "USE_PROFILER" /D "VISUAL" /D "WIN32" /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"x:\cpa\lib\GLIGLOUR.lib"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "GLIGLOU_"
# PROP BASE Intermediate_Dir "GLIGLOU_"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Temp\Debug"
# PROP Intermediate_Dir "Temp\Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /MDd /W3 /GX /Z7 /Od /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "..\PC" /I "x:\cpa\public" /I ".\\" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "x:\cpa\tempgrp\gli\PC" /D "_DEBUG" /D "VISUAL" /D "WIN32" /D "USE_PROFILER" /D "MTH_CHECK" /D "GLIDE2" /D "GLI_RAYMAN2" /D "CPA_WANTS_EXPORT" /FR /YX /FD /c
# ADD CPP /nologo /G5 /MDd /W3 /GX /Z7 /Od /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /D "_DEBUG" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /D "VISUAL" /D "WIN32" /FR /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"x:\cpa\lib\GLIVD1vD.lib"
# ADD LIB32 /nologo /out:"x:\cpa\lib\GLIGLOUD.lib"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Retail"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "GLIGLOU0"
# PROP BASE Intermediate_Dir "GLIGLOU0"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Temp\Retail"
# PROP Intermediate_Dir "Temp\Retail"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /W3 /GX /O2 /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "..\PC" /I "x:\cpa\public" /I ".\\" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "x:\cpa\tempgrp\gli\PC" /D "NDEBUG" /D "VISUAL" /D "WIN32" /D "RETAIL" /D "GLIDE2" /D "GLI_RAYMAN2" /YX /FD /c
# ADD CPP /nologo /G6 /W3 /GX /O2 /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /D "NDEBUG" /D "RETAIL" /D "VISUAL" /D "WIN32" /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"x:\cpa\lib\GLIVD1vf.lib"
# ADD LIB32 /nologo /out:"x:\cpa\lib\GLIGLOUF.lib"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Exgeom debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "GLIGLOU_"
# PROP BASE Intermediate_Dir "GLIGLOU_"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "GLIGLOU_"
# PROP Intermediate_Dir "GLIGLOU_"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /MDd /W3 /GX /Z7 /Od /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /D "_DEBUG" /D "VISUAL" /D "WIN32" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /FR /YX /FD /c
# ADD CPP /nologo /G5 /MDd /W3 /GX /Z7 /Od /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\appli\exgeom" /D "_DEBUG" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /D "EXGEOM_APPLI" /D "USE_PROFILER" /D "MULTI_TEXTURE" /D "PROCEDURAL_TEXTURE" /D "VISUAL" /D "WIN32" /FR /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"x:\cpa\lib\GLIGLOUD.lib"
# ADD LIB32 /nologo /out:"x:\cpa\lib\Exgeom_GLIGLOUD.lib"
!ENDIF
# Begin Target
# Name "GLIGLOU - Win32 Release"
# Name "GLIGLOU - Win32 Debug"
# Name "GLIGLOU - Win32 Retail"
# Name "GLIGLOU - Win32 Exgeom debug"
# Begin Group "GLI Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\Src\Camera.c
# End Source File
# Begin Source File
SOURCE=.\Src\camera.cxx
!IF "$(CFG)" == "GLIGLOU - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Retail"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Exgeom debug"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\Src\DispMode.c
# End Source File
# Begin Source File
SOURCE=.\Src\DLLCaps.c
# End Source File
# Begin Source File
SOURCE=.\Src\DLLInter.c
# End Source File
# Begin Source File
SOURCE=.\Src\Fog.c
# End Source File
# Begin Source File
SOURCE=.\Src\GLI_Menu.c
# End Source File
# Begin Source File
SOURCE=.\Src\GLI_Util.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\Src\GLIText.c
# End Source File
# Begin Source File
SOURCE=.\Src\Init_Gli.c
# End Source File
# Begin Source File
SOURCE=.\Src\LgtLoad.c
# End Source File
# Begin Source File
SOURCE=.\Src\Light.c
# End Source File
# Begin Source File
SOURCE=.\Src\Linear.c
# End Source File
# Begin Source File
SOURCE=.\Src\Lines.c
# End Source File
# Begin Source File
SOURCE=.\Src\LinkTab.c
# End Source File
# Begin Source File
SOURCE=.\Src\load.c
# End Source File
# Begin Source File
SOURCE=.\Src\MATBench.c
# End Source File
# Begin Source File
SOURCE=.\Src\Material.c
# End Source File
# Begin Source File
SOURCE=.\Src\Matstack.c
# End Source File
# Begin Source File
SOURCE=.\Src\Object.c
# End Source File
# Begin Source File
SOURCE=.\Src\PrCoVert.c
# End Source File
# Begin Source File
SOURCE=.\Src\Proj.c
# End Source File
# Begin Source File
SOURCE=.\Src\sprite.c
# End Source File
# Begin Source File
SOURCE=.\Src\VisuaSet.c
# End Source File
# Begin Source File
SOURCE=.\Src\WatrPlan.c
# End Source File
# End Group
# Begin Group "GLD Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Gld\DevVp1.c
!IF "$(CFG)" == "GLIGLOU - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Retail"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Exgeom debug"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\Gld\DevVpt.c
# End Source File
# Begin Source File
SOURCE=..\Gld\PixFmt.c
# End Source File
# End Group
# Begin Group "GLI header"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\public\GLI\camera.h
# End Source File
# Begin Source File
SOURCE=.\Inc\DispMode.h
# End Source File
# Begin Source File
SOURCE=.\Inc\DLLCaps.h
# End Source File
# Begin Source File
SOURCE=.\Inc\DLLInter.h
# End Source File
# Begin Source File
SOURCE=.\Inc\DrawFlags.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\ErrGLI.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\GLI_Defn.h
# End Source File
# Begin Source File
SOURCE=.\Inc\GLI_Menu.h
# End Source File
# Begin Source File
SOURCE=.\Inc\Gli_st.h
# End Source File
# Begin Source File
SOURCE=.\Inc\GLI_Util.h
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\Gli_Vig.h
# End Source File
# Begin Source File
SOURCE=.\Inc\GliBench.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\glierr.h
# End Source File
# Begin Source File
SOURCE=.\Inc\GliText.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\Init_Gli.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\LgtLoad.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\light.h
# End Source File
# Begin Source File
SOURCE=.\Inc\Light_st.h
# End Source File
# Begin Source File
SOURCE=.\Inc\linear.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\lines.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\LinkTab.h
# End Source File
# Begin Source File
SOURCE=.\Inc\liste.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\load.h
# End Source File
# Begin Source File
SOURCE=.\Inc\MATBench.h
# End Source File
# Begin Source File
SOURCE=.\Inc\Mater_st.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\material.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\matstack.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\object.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\polygon.h
# End Source File
# Begin Source File
SOURCE=.\Inc\PrCoVert.h
# End Source File
# Begin Source File
SOURCE=.\Inc\Priv_Obj.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\proj.h
# End Source File
# Begin Source File
SOURCE=.\Inc\PvObj_st.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\send.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\sprite.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\util.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\vertex.h
# End Source File
# Begin Source File
SOURCE=.\Inc\VisuS_st.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\VisuSet.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\Vpt3D.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\watrplan.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\ZBuffer.h
# End Source File
# End Group
# Begin Group "GLD Header"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Gld\DevVpt.h
# End Source File
# Begin Source File
SOURCE=..\Gld\GldInc.h
# End Source File
# Begin Source File
SOURCE=..\Gld\GLDUtil.h
# End Source File
# Begin Source File
SOURCE=..\Gld\MacroGLD.h
# End Source File
# End Group
# Begin Group "Textures files"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\Src\Tex.c
# End Source File
# Begin Source File
SOURCE=.\Src\TexArray.c
# End Source File
# Begin Source File
SOURCE=.\Inc\TexArray.h
# End Source File
# Begin Source File
SOURCE=.\Src\TexBench.c
# End Source File
# Begin Source File
SOURCE=.\Inc\TexBench.h
# End Source File
# Begin Source File
SOURCE=.\Src\TexCompress.c
# End Source File
# Begin Source File
SOURCE=.\Inc\TexCompress.h
# End Source File
# Begin Source File
SOURCE=.\Src\TexConvert.c
# End Source File
# Begin Source File
SOURCE=.\Src\TexName.c
# End Source File
# Begin Source File
SOURCE=.\Inc\TexName.h
# End Source File
# Begin Source File
SOURCE=.\Src\TexProcedural.c
# End Source File
# Begin Source File
SOURCE=.\Inc\TexProcedural.h
# End Source File
# Begin Source File
SOURCE=.\Src\TexSna.c
!IF "$(CFG)" == "GLIGLOU - Win32 Release"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Debug"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Retail"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Exgeom debug"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\Inc\Textu_st.h
# End Source File
# Begin Source File
SOURCE=.\Src\Texture.c
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\texture.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\GliGlou.mak
# End Source File
# Begin Source File
SOURCE=.\help.txt
# End Source File
# End Target
# End Project

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,80 @@
/*
=======================================================================================
Name : DLLCaps.h
Author : vincent lhullier Date :23/09/98
Description : Constant for DLL capabilities
=======================================================================================
*/
#ifndef __DLLCAPS_H__
#define __DLLCAPS_H__
/*
=======================================================================================
Constant for Caps1
=======================================================================================
*/
#ifdef __cplusplus
extern "C"
{
#endif
/*
=======================================================================================
Constants
=======================================================================================
*/
#define GLICAPS_DRV_C_ulIsHardware 0x00000001
#define GLICAPS_DRV_C_ulCanUseAGP 0x00000002
#define GLICAPS_DRV_C_ulCanUseSystemMemory 0x00000004
#define GLICAPS_DRV_C_ulCanBeWindowed 0x00000008
#define GLICAPS_DRV_C_ulSupportAlphaTest 0x00000010
#define GLICAPS_DRV_C_ulReadjustViewport 0x00000020
#define GLICAPS_TEX_C_ulSupport8P 0x00000001
#define GLICAPS_TEX_C_ulSupportNonSquare 0x00000002
#define GLICAPS_TEX_C_ulSupportMipmap 0x00000004
#define GLICAPS_TEX_C_ulSupportMirror 0x00000008
/*
* constant for request to DLL
*/
#define GLIDLL_Request_ReloadTexture 1
/*
=======================================================================================
Structures
=======================================================================================
*/
typedef struct tdstGliCaps_
{
unsigned long ulSize;
unsigned long ulDriverCaps;
unsigned long ulTextureCaps;
unsigned long ulSurfaceCaps;
unsigned long ulMemoryCaps;
unsigned long ulTextureMaxSize;
unsigned long ulTotalTextureMemory;
unsigned long ulTotalVideoMemory;
unsigned long ulTotalAGPMemory;
unsigned char ucPrimarySurfacePixelFormat;
float fRefreshRate;
} tdstGliCaps;
/*
=======================================================================================
Globals
=======================================================================================
*/
extern tdstGliCaps GLI_g_stCaps;
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*__DLLCAPS_H__*/

View File

@@ -0,0 +1,148 @@
/*
=======================================================================================
Name : DLLInter.h
Author : vincent lhullier Date :14/09/98
Description : initialize Specific driver DLL
=======================================================================================
*/
#ifndef __DLLINTER_H__
#define __DLLINTER_H__
#include "GLD.h"
#include "PvObj_st.h"
/*
=======================================================================================
DLL Function prototypes
=======================================================================================
*/
/* General */
extern long (*GLI_DRV_lSendDataToDll)(char *, void *);
/* DOMATxxx.C */
extern void (* GLI_DRV_vDoOpaqueTextureSelection)( GLI_tdstInternalGlobalValuesFor3dEngine * );
extern void (* GLI_DRV_vWrite16bBitmapToBackBuffer) ( void *,long ,long ,long ,long, long, long );
extern void (* GLI_DRV_vAddBlackPolygon)( long , long , long , long );
extern void (* GLI_DRV_vNoBlackPolygon)( void );
extern void (* GLI_DRV_vComputeFogEffect)(GLI_tdstInternalGlobalValuesFor3dEngine *);
extern BOOL (* GLI_DRV_bBeginScene)(void);
extern BOOL (* GLI_DRV_bEndScene)(void);
/* ACCES_XXXX.C */
extern void (* GLI_DRV_vSendSpriteToClip)(GLI_tdstAligned2DVector *,MTH_tdxReal ,GLI_tdstInternalGlobalValuesFor3dEngine *);
extern void (* GLI_DRV_vSendSpriteToClipWithUV)( GLI_tdstAligned2DVector *, MTH_tdxReal *, MTH_tdxReal , GLI_tdstInternalGlobalValuesFor3dEngine *);
/* ACCES_ALL.C */
extern void (* GLI_DRV_vSendSingleLineToClip)( GLD_tdstViewportAttributes *, GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *, GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *, GLI_tdstInternalGlobalValuesFor3dEngine *, long , GEO_tdstColor *);
/* HDWTex_xxx.C */
extern void (* GLI_DRV_vDownLoadTextures)(long, long, BOOL);
extern void (* GLI_DRV_vUnLoadTextures)(void);
extern long (* GLI_DRV_lGetTextureSize)( GLI_tdstTexture *);
/* init_XXX.c */
extern void (* GLI_DRV_vFlipDevice)(long );
extern void (* GLI_DRV_vFlipDeviceWithSyncro)(void);
extern void (* GLI_DRV_vClearDevice)(BOOL, BOOL , unsigned long );
extern void (* GLI_DRV_xInitDriver) ( HWND, BOOL, long, long, long );
extern void (* GLI_DRV_vCloseDriver) (void);
extern void (* GLI_DRV_vClearZBufferRegion)(long ,long ,long ,long );
//extern long (* GLI_DRV_fn_lEnumerateDisplayMode)(void);
extern long (* GLI_DRV_fnl_EnumModes)(char *, char *);
extern HRESULT (* GLI_DRV_hChangeMode)( BOOL, long, long, long );
extern BOOL (* GLI_DRV_bLockDevice)( void **, long *);
extern BOOL (* GLI_DRV_bUnlockDevice)( void );
extern BOOL (* GLI_DRV_bPrepareForGliWindowed)(HWND);
extern void (* GLI_DRV_vPrepareForGliFullScreen)(HWND);
extern void (* GLI_DRV_vActivateGli)(HWND, BOOL);
extern void (* GLI_DRV_vReadaptDisplay)(void);
extern BOOL (* GLI_DRV_bWindowedModeIsOptimized)( void );
extern void (* GLI_DRV_vOptimizedWindowedMode)( void );
extern void (* GLI_DRV_vNonOptimizedWindowedMode)( void );
extern void (* GLI_DRV_vSetMainWindowForRender)(HWND);
extern void (* GLI_DRV_vRecomputeViewportToMaximizeDisplay)(int);
/* ClipTriangles */
extern void (* GLI_DRV_xClearViewingList)( void );
extern void (* GLI_DRV_xSendListToViewport)( GLD_tdstViewportAttributes * );
extern void (* GLI_DRV_vSetZClip)(float ,GLI_tdstInternalGlobalValuesFor3dEngine *);
extern void (* GLI_DRV_vSetClipWindow)(float ,float ,float ,float ,GLI_tdstInternalGlobalValuesFor3dEngine *);
extern void (* GLI_DRV_xSendElementTIToClip_TRIANGLES)( GEO_tdstElementIndexedTriangles *, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
extern void (* GLI_DRV_xSendSingleTriangleToClip_TRIANGLES)( GLI_tdstAligned2DVector *a3_st2DVertex, ACP_tdst2DUVValues *a3_stUV, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
/* misc request (see request type n dllcaps.h file) */
extern long (* GLI_DRV_lRequest)( long, long, long );
extern void GLI_fn_vDrawMirror(BOOL);
#ifndef RETAIL
extern void (*GLI_DRV_vGetStats)(unsigned long *, unsigned long *);
#else
#define GLI_DRV_vGetStats( a, b)
#endif
extern void (*GLI_DRV_vWaitRetrace)(void);
/*
=======================================================================================
Structures
=======================================================================================
*/
typedef struct GLI_tdst_DllInfos_
{
HINSTANCE h_Module;
char sz_Name[64];
char sz_Desc[256];
char sz_Version[16];
unsigned long ul_Code;
char sz_FileName[ _MAX_PATH ];
char sz_DriverName[ 32 ];
char sz_DeviceName[ 32 ];
long l_InitWidth;
long l_InitHeight;
long l_InitFullScreen;
long l_InitBpp;
long l_RealWidth;
long l_RealHeight;
float f_WidthRatio;
float f_HeightRatio;
} GLI_tdst_DllInfos;
/*
=======================================================================================
globals
=======================================================================================
*/
extern GLI_tdst_DllInfos GLI_gst_DllInfo;
/*
=======================================================================================
Functions
=======================================================================================
*/
long GLI_fnl_InitDll( void );
long GLI_fn_lCloseGliDriver( void );
void GLI_fnv_SetDllFileName( char *_sz_Name );
void GLI_fnv_SetDllName( char *_sz_Name );
void GLI_fnv_SetDriverName( char *_sz_Name );
void GLI_fnv_SetDeviceName( char *_sz_Name );
void GLI_fnv_SetMode( long _l_FullScreen, long _l_Width, long _l_Height, long _l_Bpp );
void GLI_fnv_SetModeByString( char *_sz_Line );
#endif /* __DLLINTER_H__ */

View File

@@ -0,0 +1,113 @@
/*
=======================================================================================
Name : DispMode.h
Author : vincent lhullier Date :04/09/98
Description : Manage the different display mode available
=======================================================================================
*/
#ifndef __DISPMODE_H__
#define __DISPMODE_H__
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <stdio.h>
#include "GLI_util.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*
=======================================================================================
Structure
=======================================================================================
*/
/*
* to store display mode
*/
typedef struct GLI_tdstDisplayMode_
{
long lFullScreen;
long lWidth;
long lHeight;
long lBpp;
} GLI_tdstDisplayMode;
/*
=======================================================================================
Constants
=======================================================================================
*/
#define GLI_C_lMaxDisplayMode 32
/*
=======================================================================================
Globals
=======================================================================================
*/
extern GLI_tdstDisplayMode GLI_gs_a_stDisplayMode[ GLI_C_lMaxDisplayMode ];
extern long GLI_gs_lNumberOfDisplayModes;
extern long GLI_gs_lCurrentDisplayMode;
extern long GLI_gs_lRequestedDisplayMode;
/*
=======================================================================================
Access function
=======================================================================================
*/
/*
* for display mode
*/
long GLI_fn_lIsFullScreenMode( void );
long GLI_fn_lDisplayModeWidth( void );
long GLI_fn_lDisplayModeHeight( void );
long GLI_fn_lDisplayModeBPP( void );
long GLI_fn_lGetDisplayMode( void );
long GLI_fn_lAddDisplayMode( long _lFullScreen, long _lWidth, long _lHeight, long _lBpp );
long GLI_fn_lGetNumberOfDisplayModes( void );
long GLI_fn_lGetCurrentDisplayMode( void );
long GLI_fn_lGetDisplayModeParameters( long _lDisplayMode, long *_p_lWidth, long *_p_lHeight );
long GLI_fn_lGetDisplayModeDescription( long _lDisplayMode, char *_szDesc );
void GLI_fn_lRequestNewDisplayMode( long _lDisplayMode );
long GLI_fn_lChangeDisplayMode( void );
/*
=======================================================================================
Function
=======================================================================================
*/
/*
* choose / select
*/
long GLI_fn_lSelectDisplayModeByIndex( long _lIndex );
long GLI_fn_lSelectDisplayModeByDimension( long _lWidth, long _lHeight, long _lBpp );
/*
* init
*/
void GLI_fn_vLoadDisplayMode( void );
/*
*
*/
void GLI_fn_vSetBrightness( long _lValue );
long GLI_fn_lGetBrightness();
#ifdef __cplusplus
}
#endif
#endif /*__DISPMODE_H__*/

View File

@@ -0,0 +1,53 @@
/* File: DrawFlags.h*/
/* Author: Steve McCalla*/
/* Date: 9 Sept 1998*/
/* these flags tell us which functions are called.*/
/* This allows us to find the common sets of functions and group them, saving thousands of*/
/* function calls and helping out our poor little 8k DCache on the Pentium.*/
/* When you want to find out which functions are called, just print the flag out */
/* to the error.log before calling the first func. Attention: ca va ramer quand tu le fais!*/
/**/
#ifndef DRAW_FLAGS_H
#define DRAW_FLAGS_H
#define Flag_GLI_vSetSpecular (1<<0)
#define Flag_GLI_vComputeXYZ (1<<1)
#define Flag_GLI_FastZCull (1<<3)
#define Flag_GLI_FastMirrorCulling (1<<4)
#define Flag_GLI_bCullingXYALL (1<<5)
#define Flag_GLI_bCullingXMin (1<<6)
#define Flag_GLI_bCullingXMax (1<<7)
#define Flag_GLI_bCullingXMax_XMin (1<<8)
#define Flag_GLI_bCullingYMin (1<<9)
#define Flag_GLI_bCullingYMax (1<<10)
#define Flag_GLI_bCullingYMax_YMin (1<<11)
#define Flag_GLI_FastWaterCLipping (1<<12)
#define Flag_GLI_FastMirrorCLipping (1<<13)
#define Flag_GLI_vZClipping (1<<14)
#define Flag_GLI_TestBackfaceClockwise (1<<15)
#define Flag_GLI_TestBackfaceCounterClockwize (1<<16)
#define Flag_GLI_XMaxCLipping (1<<17)
#define Flag_GLI_XMinCLipping (1<<18)
#define Flag_GLI_YMinCLipping (1<<20)
#define Flag_GLI_YMaxCLipping (1<<21)
#define Flag_GLI_vComputeMirrorUVW (1<<23)
#define Flag_GLI_vComputeMovingUVW (1<<24)
#define Flag_GLI_vComputeNormalUVW (1<<25)
#define Flag_GLI_vZSortTriangle (1<<26)
#define Flag_GLI_vDrawWiredTriangle (1<<27)
#define Flag_GLI_vDrawTriangle (1<<28)
#define Flag_GLI_vCorrect3DFXBug1 (1<<29)
/* These values were determined experimentally - they may change as the maps change*/
#define MaskBigFunc1 (Flag_GLI_vSetSpecular|Flag_GLI_vComputeXYZ|Flag_GLI_TestBackfaceClockwise|Flag_GLI_vComputeNormalUVW|Flag_GLI_vDrawTriangle|Flag_GLI_vCorrect3DFXBug1)
/* this variable is defined in ClipTriangles.c*/
extern unsigned long ulFuncMask;
#endif /*DRAW_FLAGS_H*/

View File

@@ -0,0 +1,44 @@
/*
=======================================================================================
Name : GLI_Menu.h
Author : vincent lhullier Date :10/03/99
Description : function to display gli menu
=======================================================================================
=======================================================================================
!!!! Warning : In retail version this file define only empty symbols !!!!
=======================================================================================
=======================================================================================
*/
#if defined(RETAIL) || defined(PRESS_DEMO)
#define GLI_fnv_ManageMenu()
#define GLI_fn_vAddDisplayedVisualMaterial( _hVisualMaterial )
#define GLI_M_vAddDisplayedVisualMaterialForSprite( p_stEltSprite )
#define GLI_M_vAddDisplayedVisualMaterialForEltIndexedTriangle( p_stEltIndexedTriangle )
#else
void GLI_fnv_ManageMenu( void );
void GLI_fn_vAddDisplayedVisualMaterial( ACP_tdxHandleOfMaterial _hVisualMaterial );
#define GLI_M_vAddDisplayedVisualMaterialForSprite( p_stEltSprite ) \
{ \
if( p_stEltSprite -> d_stListOfSprites[lSpriteIndex].hSprite -> d_hMaterial[0] \
&& p_stEltSprite -> d_stListOfSprites[lSpriteIndex].hSprite -> d_hMaterial[0] -> hVisualMaterial ) \
{ \
GLI_fn_vAddDisplayedVisualMaterial( p_stEltSprite -> d_stListOfSprites[lSpriteIndex].hSprite -> d_hMaterial[0] -> hVisualMaterial ); \
} \
}
#define GLI_M_vAddDisplayedVisualMaterialForEltIndexedTriangle( p_stEltIndexedTriangle ) \
{ \
if( p_stEltIndexedTriangle -> hMaterial \
&& p_stEltIndexedTriangle -> hMaterial -> hVisualMaterial ) \
{ \
GLI_fn_vAddDisplayedVisualMaterial( p_stEltIndexedTriangle -> hMaterial -> hVisualMaterial ); \
} \
}
#endif /* RETAIL */

View File

@@ -0,0 +1,19 @@
/*
=======================================================================================
Name : GLI_UTIL.h
Author : vincent lhullier Date :03/09/98
Description : Utility for GLI
=======================================================================================
*/
#ifndef __GLI_UTIL_H__
#define __GLI_UTIL_H__
/*
=======================================================================================
Function
=======================================================================================
*/
DLGTEMPLATE *fn_p_stPrepareDialogBox_LB( char *szTitle );
#endif /*__GLI_UTIL_H__*/

View File

@@ -0,0 +1,78 @@
/*
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Name : GliBench.h Author : vincent lhullier Date :12/10/98 Description : Bench Data
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
#ifndef __GLIBENCH_H__
#define __GLIBENCH_H__
/* BENCH ACTIVE */
#ifdef GLI_BENCH
/*
---------------------------------------------------------------------------------------------------
Structure
---------------------------------------------------------------------------------------------------
*/
typedef struct tdstGliBench_
{
long lNumberOfElementsSended;
long lNumberOfObjectsSended;
long lNumberOfPolygonsSended;
long lNumberOfLinesSended;
long lNumberOfPolygonsBackfaces;
long lNumberOfPolygonsZculled;
long lNumberOfPolygonsZClipped;
long lNumberOfPolygonsXYCulled;
long lNumberOfPolygonsXYClipped;
long lNumberOfPolygonsXYUnClipped;
long lRateInPolygons;
long lRateInPixels;
long lPolycounter;
long lPolyTransparentcounter;
long lPolyOpaquecounter;
/* Light */
long lNumberOfHotSpotLightedVertices;
long lNumberOfSpecularLightedVertices;
long lNumberOfParallelLightedVertices;
/* triangle surface */
long lTrianglePerSurface[ 1024 ];
} tdstGliBench;
/*
===================================================================================================
Macros to be used by m<>ain appli (not by DLL)
===================================================================================================
*/
#define GLI_M_vBenchInc(a) GLI_g_stBench.##a++;
#define GLI_M_vBenchAdd(a, b) GLI_g_stBench.##a += b;
#define GLI_M_vBenchReset() memset(&GLI_g_stBench, 0, sizeof(tdstGliBench));
/*
===================================================================================================
Macros to be used by DLL
===================================================================================================
*/
#define GLI_MDRV_M_vBenchInc(a) GLI_MDRV_g_p_stBench->##a++;
#define GLI_MDRV_M_vBenchAdd(a, b) GLI_MDRV_g_p_stBench->##a += b;
/* Globals */
extern tdstGliBench GLI_g_stBench;
extern tdstGliBench *GLI_MDRV_g_p_stBench;
/* BENCH NOT ACTIVE */
#else /* GLI_BENCH */
#define GLI_M_vBenchInc(a)
#define GLI_M_vBenchAdd(a, b)
#define GLI_M_vBenchReset()
#define GLI_MDRV_M_vBenchInc(a)
#define GLI_MDRV_M_vBenchAdd(a, b)
#endif
#endif /* __GLIBENCH_H */

View File

@@ -0,0 +1,36 @@
/*
=======================================================================================
Name : GLIText.h
Author : vincent lhullier Date :12/10/98
Description : function to display text on screen
=======================================================================================
=======================================================================================
!!!! Warning : In retail version this file is empty !!!!
=======================================================================================
=======================================================================================
*/
#ifndef __GLITEXT_H__
#define __GLITEXT_H__
#ifndef RETAIL
void GLITEXT_fnv_Init( void );
void GLITEXT_fnv_Close( void );
void GLI_vDisplayPolices(unsigned char *d_ucFileName, long lX, long lY);
void GLITEXT_fnv_SetProportionalMode( long _l_Mode );
long GLITEXT_fnl_GetProportionalMode( void );
#else
#define GLITEXT_fnv_Init()
#define GLITEXT_fnv_Close()
#define GLI_vDisplayPolices(a,b,c)
#define GLITEXT_fnv_SetProportionalMode( a )
#define GLITEXT_fnl_GetProportionalMode( b ) 0
#endif
#endif /*__GLITEXT_H__*/

View File

@@ -0,0 +1,43 @@
#ifndef GLI_ST_H
#define GLI_ST_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef EXTERN_GLI
#undef EXTERN_GLI
#endif
#ifdef MAIN_GLI
#define EXTERN_GLI
#else
#define EXTERN_GLI extern
#endif
#ifdef U64
#define NO_ASSEMBLY_IN_GLI /* Julien Merceron */
#else
#define NO_ASSEMBLY_IN_GLI
#endif
#ifdef NO_ASSEMBLY_IN_GLI
#define ASM_CAST
#else
#define ASM_CAST (long)
#pragma message("Compile l'assembleur dans GLI..")
#endif
#include "Acp_Base.h"
#include "cpa_std.h"
#ifdef VISUAL
#define GLI_INTERNAL_FAST_CALLING_CONV __fastcall
#else
#define GLI_INTERNAL_FAST_CALLING_CONV
#endif
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,59 @@
#ifndef LIGHT_ST_H
#define LIGHT_ST_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "GEO.h"
/* For DLL using these function :*/
#include "cpa_expt.h"
#include "POS.h"
typedef struct GLI_tdstZBufferForLight_
{
long lSizeX;
long lSizeY;
/* Projection x = X * coefX / Z . y = Y * CoefY / Z;*/
float fCoefX;
float fCoefY;
float *p_stZBufferMap;
float *p_stMiddleZBufferMap;
} GLI_tdstZBufferForLight;
typedef struct GLI_tdstLight_
{
long b_lOnOff ;
long bThisLightIsZBuffered;
long lTypeOfLight ;
MTH_tdxReal xFar,xNear;
/* for hotspot.*/
MTH_tdxReal xLittleAlpha,xBigAlpha;
MTH_tdxReal xLittleTangent,xBigTangent;
POS_tdstCompletePosition stMatrix ;
GLI_tdstZBufferForLight stZBuffer;
GEO_tdstColor stColor ;
unsigned char bValid;
unsigned char ucObjectLighted;
unsigned char bIsPainting;
unsigned char ucIsAlpha; /* 0: Normal (RGB&A) 1: A Only 2: RGB Only */
MTH3D_tdstVector xInter_Min_Pos;
MTH3D_tdstVector xExter_Min_Pos;
MTH3D_tdstVector xInter_Max_Pos;
MTH3D_tdstVector xExter_Max_Pos;
MTH3D_tdstVector xCenterBox;
MTH_tdxReal xRadius;
MTH_tdxReal xIntensity_Min;
MTH_tdxReal xIntensity_Max;
GEO_tdstColor stBackgroundColor;
}
GLI_tdstLight;
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* LIGHT_H*/

View File

@@ -0,0 +1,22 @@
#ifndef __MATBENCH_H__
#define __MATBENCH_H__
/*#define BENCH_MATERIAL*/
#ifdef BENCH_MATERIAL
#include "mater_st.h"
void MATBENCH_fn_vAddMaterialRef( GLI_tdstMaterial *_pst_Material );
void MATBENCH_fn_vDeleteMaterialRef( GLI_tdstMaterial *_pst_Material );
void MATBENCH_fn_vWriteMaterialInfoInFile( char *_szTitle );
#else
#define MATBENCH_fn_vAddMaterialRef(a)
#define MATBENCH_fn_vDeleteMaterialRef(a)
#define MATBENCH_fn_vWriteMaterialInfoInFile(a);
#endif
#endif /*__MATBENCH_H__*/

View File

@@ -0,0 +1,142 @@
/*
=======================================================================================
Name : Mater_st.h
Description : structure for material
=======================================================================================
*/
#ifndef GLI_MATERIAL_ST_H
#define GLI_MATERIAL_ST_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "GEO.h"
#include "textu_st.h"
/*
=======================================================================================
Multi texture material structure
=======================================================================================
*/
#ifdef MULTI_TEXTURE
#define C_MTMF_cUVStaticTransEnable 0x01
#define C_MTMF_cUVDynamicTransEnable 0x02
#define C_MTMF_cUVStaticMatEnable 0x04
#define C_MTMF_cUVDynamicMatEnable 0x08
#define C_MTMF_cIsNotLastTexture 0x10
#define C_MTMCO_cDisable 0
#define C_MTMCO_cSpecular 1
#define C_MTMCO_cDiffuse 2
#define C_MTMCO_cConstant 3
#define C_MTMCO_cSpecularAlpha 4
#define C_MTMCO_cDiffuseAlpha 5
#define C_MTMCO_cConstantAlpha 6
#define C_MTMCO_cSpecularColor 7
#define C_MTMCO_cDiffuseColor 8
#define C_MTMCO_cConstantColor 9
#define C_MTMOP_cMul 0
#define C_MTMOP_cAdd 1
#define C_MTMOP_cCopy 2
#define C_MTMOP_cAlphaTrans 3
#define C_MTMOP_cAlphaPremult 4
#define C_MTMOP_cMul2X 5
#define C_MTMOP_cInvert 6
#define C_MTMOP_cAddSmooth 7
#define C_MTMUV_cNoSource 0
#define C_MTMUV_cObject1 1
#define C_MTMUV_cObject2 2
#define C_MTMUV_cChrome 3
#define C_MTMUV_cScreen 4
#define C_MTMUV_cCartoon 5
#define C_MTMUV_cSolarPhong 6
typedef struct
{
float stMat[2][2];
float stTrans[2];
} GLI_tdstUVTransformation;
typedef struct
{
GLI_tdstTexture *pst_Texture;
char c_Operator;
char c_ColorOperator;
char c_UVSource;
char c_Flags;
GLI_tdstUVTransformation st_UVStaticPos;
GLI_tdstUVTransformation st_UVDynamicPos;
} GLI_tdstMultiTextureMaterial;
#endif /*MULTI_TEXTURE*/
/*
=======================================================================================
Standard structure
=======================================================================================
*/
/*
* Animated texture node
*/
typedef struct GLI_tdstAnimatedTextureNode_
{
GLI_tdstTexture *p_stTexture;
MTH_tdxReal xDisplayTime;
struct GLI_tdstAnimatedTextureNode_ *p_stNextDisplayNode;
} GLI_tdstAnimatedTextureNode;
/*
* Material structure
*/
typedef struct GLI_tdstMaterial_
{
unsigned long xMaterialType;
GEO_tdstColor stAmbient;
GEO_tdstColor stDiffuse;
GEO_tdstColor stSpecular;
GEO_tdstColor stColor;
long lSpecularExponent;
GLI_tdstTexture *p_stTexture;
/*
* scrolling material
*/
float fAddU;
float fAddV;
float fConstantAddU;
float fConstantAddV;
long lIncrementIsEnable;
/*
* for Animated textures.
*/
unsigned long lActualRefreshNumber;
GLI_tdstAnimatedTextureNode *p_stFistAnimatedTExtureNode;
GLI_tdstAnimatedTextureNode *p_stActualAnimatedTExtureNode;
long lNumberOfDisplayNode;
MTH_tdxReal xActualDisplayTimeSinceStartOfLastTexture;
ACP_tdxBool xIsLocked;
#ifdef MULTI_TEXTURE
GLI_tdstMultiTextureMaterial a_stMultiMaterial[8];
#endif /*MULTI_TEXTURE*/
} GLI_tdstMaterial ;
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* GLI_MATERIAL_H*/

View File

@@ -0,0 +1,19 @@
/*
=======================================================================================
Name : PrCoVert.h
Author : Date :24/07/98
Description : function prototype for vertex serail colorisation
=======================================================================================
Modification -> Author : Date :
Description :
=======================================================================================
*/
#ifndef __PRCOVERT_H__
#define __PRCOVERT_H__
void GLI_vSerialComputeVertexColorIndexedAlpha(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP, ACP_tdxIndex xNumber,ACP_tdxIndex *p_ListOfIndexes);
void GLI_vSerialComputeVertexColorIndexedNoAlpha(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP, ACP_tdxIndex xNumber,ACP_tdxIndex *p_ListOfIndexes);
void GLI_vSerialComputeVertexColor2(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP, ACP_tdxIndex xNumber);
#endif

View File

@@ -0,0 +1,53 @@
#ifndef PRIVATEOBJECTH
#define PRIVATEOBJECTH
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* For DLL using these function :*/
#include "cpa_expt.h"
/*#ifdef USE_EXECUTE_BUFFER
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vResetAnExecuteBuffer(GLI_tdstExecuteBuffer *p_stExecuteBuffer);
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vAddOneTriangleToAnExecuteBuffer(GLI_tdstExecuteBuffer *p_stExecuteBuffer,GLI_tdstScreenVertex *p_FirstPoint,long lLenght);
GLI_tdstScreenVertex * GLI_INTERNAL_FAST_CALLING_CONV
GLI_vGetNewScreenVerticesOfExecuteBuffer(GLI_tdstExecuteBuffer *p_stExecuteBuffer,long lNbVertices);
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vFreeScreenVerticesOfExecuteBuffer(GLI_tdstExecuteBuffer *p_stExecuteBuffer,long lNbVertices);
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vAddOneMaterialToAnExecuteBuffer(GLI_tdstExecuteBuffer *p_stExecuteBuffer,ACP_tdxHandleOfMaterial hMaterial,long lDrawMask);
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vDrawAnExecuteBuffer(GLD_tdstViewportAttributes *p_stVpt ,
GLI_tdstExecuteBuffer *p_stExecuteBuffer);
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vInitExecutesBuffers();
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vEndExecuteBufferDraw();
#endif*/
/**********************************************************************************************/
/* Name: GLI_vInitModuleObject 1.0*/
/* Goal: Creates threads, reserve memory for all, init buffers...*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : */
/**********************************************************************************************/
void
GLI_vInitModuleObject();
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* PRIVATEOBJECTH*/

View File

@@ -0,0 +1,155 @@
#ifndef PRIVATEOBJECTST
#define PRIVATEOBJECTST
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* For DLL using these function :*/
#include "cpa_expt.h"
#include "cpa_expt.h"
#include "textu_st.h"
#include "GLD.h"
#include "light.h"
typedef struct GLI_tdstAligned3DVector_
{
MTH_tdxReal xX,xY,xZ;
MTH_tdxReal ALIGN;
} GLI_tdstAligned3DVector;
typedef struct GLI_tdstAligned2DVector_
{
float xX ;
float xY ;
float xOoZ ;
unsigned long ulPackedColor;
} GLI_tdstAligned2DVector;
/* ------------------------- ZLISTE ----------------------------*/
typedef struct GLI_tdstOneNodeOfZListe_
{
void *p_ThreePoints;
GLI_tdstTexture *p_TextureOfTheTriangle;
struct GLI_tdstOneNodeOfZListe_ *p_NextNode;
unsigned long lCurrentDrawMask;
tdstFogParams *p_stFogParams;
ACP_tdxHandleOfMaterial p_stMaterial;
} GLI_tdstOneNodeOfZListe;
#define GLI_MaxZEntryPO2 12 /* == 4096 entries * n tables */
#define GLI_MaxZListeTrianglesPO2 11
#define GLI_NumberOfZListes 1
typedef struct GLI_tdstZListe_
{
long lMinValue[GLI_NumberOfZListes];
long lMaxValue[GLI_NumberOfZListes];
GLI_tdstOneNodeOfZListe *aDEF_p_tdstTableOfZentryNearestOfWaterPlane[GLI_NumberOfZListes<<GLI_MaxZEntryPO2];
GLI_tdstOneNodeOfZListe *p_stCurrentZNode;
GLI_tdstOneNodeOfZListe aDEF_tdstZListeNodes[1<<GLI_MaxZListeTrianglesPO2];
long lPointCounters;
void *p_CurrentPoint;
void *p_TableOfPoints;
} GLI_tdstZListe;
/* ----------------------- END ZLISTE --------------------------*/
#define GLI_C_ClipMaskXMin 0x00000001
#define GLI_C_ClipMaskXMax 0x00000002
#define GLI_C_ClipMaskYMin 0x00000004
#define GLI_C_ClipMaskYMax 0x00000008
#define GLI_C_CutMaskXMin 0x00000010
#define GLI_C_CutMaskXMax 0x00000020
#define GLI_C_CutMaskYMin 0x00000040
#define GLI_C_CutMaskYMax 0x00000080
#define GLI_C_ClipMaskZ 0x00000100
#define GLI_C_ClipMaskWater 0x00000200
#define GLI_C_IsCameraInBoundingVolume 0x00000400
#define GLI_C_IsObjectMatrixAlreadyInverted 0x00000800
#define GLI_C_AtLeastOneNegativeColorWasDetected 0x00001000
#define GLI_C_TrianglesMustBeSorted 0x00008000
#define GLI_C_ClipMaskAllDirection (GLI_C_ClipMaskXMin | GLI_C_ClipMaskXMax | GLI_C_ClipMaskYMin | GLI_C_ClipMaskYMax | GLI_C_ClipMaskZ)
typedef struct GLI_tdstInternalGlobalValuesFor3dEngine_
{
GLD_tdstViewportAttributes *p_stVpt ;
GEO_tdstGeometricObject *p_stObj ;
long lDrawModeMask;
long lHierachDrawMask;
long lCurrentDrawMask;
long GLD_RenderingCounter;
long lClippingModeMask;
MTH3D_tdstVector stCenterOfCurrentBoundingSphere;
MTH_tdxReal stRadiusOfCurrentBoundingSphere;
/* BIG TABLES*/
GLI_tdstAligned3DVector GLI_TurnedScaledDisplecedPoint [C_lMaxVertexPerObject] ;
GLI_tdstAligned2DVector GLI_ScreenPoint [C_lMaxVertexPerObject] ;
MTH_tdxReal GLI_aDEF_xWaterPlaneDepth [(C_lMaxVertexPerObject>>1)-8] ;
GEO_tdstColor GLI_aDEF_stColorsRLID [C_lMaxVertexPerObject] ;
GEO_tdstColor GLI_aDEF_stColorsRLIS [C_lMaxVertexPerObject] ;
GEO_tdstColor GLI_aDEF_stColorsRLIA;
ACP_tdst2DUVValues GLI_aDEF_stEnvUV [C_lMaxVertexPerObject] ; /*used for environment UV (chromed)*/
GEO_tdstColor GLI_stColorsAdd;
GEO_tdstColor GLI_stColorsMul;
POS_tdstCompletePosition *gs_st_CameraMatrix;
POS_tdstCompletePosition *gs_st_CurrentMatrix;
POS_tdstCompletePosition gs_st_CurrentMatrixInverted;
POS_tdstCompletePosition gs_st_CurrentMatrixMultiplyedWithCameraMatrix;
float fZClipping;
float fWClipping;
float fXMinClipping;
float fXMaxClipping;
float fYMinClipping;
float fYMaxClipping;
GLI_tdstTexture *p_stCurrentTexture;
ACP_tdxHandleOfMaterial hCurrentMaterial;
struct GLI_tdstCamera_ *p_stCurrentCamera;
MTH_tdxReal xWaterPlaneDistance;
GLI_tdstAligned3DVector stWaterPlanNormale;
unsigned long ulColorInitForSprite;
unsigned long ulSpecularColorForSprite;
float fMulU;
float fMulV;
GLI_tdstZListe *p_TheZListe;
unsigned long ulCurrentZTable;
/*For fog*/
tdstFogParams *p_stActiveFog;
tdstFogParams *p_stLastComputedFog;
long xFogIsOn;
long xTextureDontAcceptFog;
/*For mirror*/
long lAMirrorIsDetected;
BOOL bDrawMirrorSymetric;
long lDisplayMenuIsDetected;
/*For alpha*/
float xGlobalAlpha;
} GLI_tdstInternalGlobalValuesFor3dEngine;
/* This must be a power of two.*/
void GLI_vSerialComputeVerticesPositions(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobalsParrameters,long xStart,long xNumber);
void GLI_vSerialComputeVertexColor(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobalsParrameters,long xStart,long xNumber,void *p_VertexScreen);
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* PRIVATEOBJECTST*/

View File

@@ -0,0 +1,43 @@
/*
=======================================================================================
Name : TexArray.h
Author : Gliglou corporation
Description : manage array of texture data
=======================================================================================
*/
#ifndef __TEXARRAY_H__
#define __TEXARRAY_H__
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "texture.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Globals
=======================================================================================
*/
/*
* array of texture / texture state
*/
extern GLI_tdstTexture *gs_aDEFTableOfTextureAlreadyRead [ GLI_C_lNBMaxOfTextures ];
extern long gs_aDEFTableOfTextureMemoryChannels[ GLI_C_lNBMaxOfTextures ];
extern unsigned long GLI_g_ulNumberOfLoadedTexture;
/*
=======================================================================================
Functions
=======================================================================================
*/
void GLI_fn_vUnallocTextureInChannel( unsigned char _ucChannel );
void GLI_fn_vUnallocAllTextures( void );
long GLI_lComputeTexturesSize( void );
long GLI_lGetBigestSizeOfTexture( void );
void GLI_vUnCompressExistantTexture(void);
GLI_tdstTexture *TEX_fnpst_DoesTextureExist( char *_szFileName );
void TEX_fnv_MakeItExisting( GLI_tdstTexture *_pst_TextureCreated );
#endif /*__TEXARRAY_H__*/

View File

@@ -0,0 +1,47 @@
#ifndef __TEXBENCH_H__
#define __TEXBENCH_H__
/*#define BENCH_TEXTURE*/
#ifdef BENCH_TEXTURE
#include "textu_st.h"
#define TEXBENCH_C_cComputedSize 0
#define TEXBENCH_C_cRealSize 1
#define TEXBENCH_C_cBeginUnload 0
#define TEXBENCH_C_cEndUnload 1
#define TEXBENCH_C_cBeginUncompress 2
#define TEXBENCH_C_cEndUncompress 3
#define TEXBENCH_C_cBeginCompression 4
#define TEXBENCH_C_cEndcompression 5
#define TEXBENCH_C_cBeginComputeLod 6
#define TEXBENCH_C_cEndComputeLod 7
#define TEXBENCH_C_cBeginDownload 8
#define TEXBENCH_C_cEndDownload 9
#define TEXBENCH_C_cBeginDownload1 10
#define TEXBENCH_C_cEndDownload1 11
#define TEXBENCH_C_cBeginDownload2 12
#define TEXBENCH_C_cEndDownload2 13
#define TEXBENCH_C_cBeginDownload3 14
#define TEXBENCH_C_cEndDownload3 15
void TEXBENCH_fn_vInitTextureSize( void );
void TEXBENCH_fn_vSetTextureSizeWithIndex( long _lTextureIndex, char _cSizeType, long _lSize );
void TEXBENCH_fn_vSetTextureSize( GLI_tdstTexture *_p_stTexture, char _cSizeType, long _lSize );
void TEXBENCH_fn_vWriteSizeInFile( void );
void TEXBENCH_fn_vSetTime( char _cFor );
#else
#define TEXBENCH_fn_vInitTextureSize()
#define TEXBENCH_fn_vSetTextureSizeWithIndex( a, b, c)
#define TEXBENCH_fn_vSetTextureSize( a, b, c )
#define TEXBENCH_fn_vWriteSizeInFile()
#define TEXBENCH_fn_vSetTime( a )
#endif
#endif /*__TEXBENCH_H__*/

View File

@@ -0,0 +1,19 @@
/*
=======================================================================================
Name : TexArray.h
Author : Gliglou corporation
Description : texture compression
=======================================================================================
*/
#ifndef __TEXCOMPRESS_H__
#define __TEXCOMPRESS_H__
/*
=======================================================================================
FUNCTIONS
=======================================================================================
*/
long TEX_lComputeCompression( void );
#endif /*__TEXCOMPRESS_H__*/

View File

@@ -0,0 +1,31 @@
/*
=======================================================================================
Name : TexName.h
Author : GLIGLOU corporation
Description : Fonction for texture name analysis / storage
=======================================================================================
*/
#ifndef __TEXNAME_H__
#define __TEXNAME_H__
#include "texture.h"
#ifdef __cplusplus
extern "C"
{
#endif
/*
* Analyse name of texture
*/
long GLI_fn_lAnalyseTextureName( char *_szFileName, long *_p_lTextureCaps, unsigned char *_p_ucCyclingMode );
void TEX_fnv_FixTextureName(char *_pszOut, char *_pszIn);
#ifdef __cplusplus
}
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More