104 lines
2.9 KiB
C
104 lines
2.9 KiB
C
/*
|
|
=======================================================================================
|
|
Name : MATBench.c
|
|
Author : vincent lhullier Date :27/01/99
|
|
Description : Bench function for materials
|
|
=======================================================================================
|
|
*/
|
|
|
|
#include "gli_st.h"
|
|
#include "MATBench.h"
|
|
|
|
#ifdef BENCH_MATERIAL
|
|
|
|
/*
|
|
=======================================================================================
|
|
Globals
|
|
=======================================================================================
|
|
*/
|
|
static GLI_tdstMaterial *gapst_Material[ 1024 ];
|
|
static long gl_NumberOfMaterials = 0;
|
|
|
|
/*
|
|
=======================================================================================
|
|
Function
|
|
=======================================================================================
|
|
*/
|
|
|
|
void MATBENCH_fn_vAddMaterialRef( GLI_tdstMaterial *_pst_Material )
|
|
{
|
|
gapst_Material[ gl_NumberOfMaterials++ ] = _pst_Material;
|
|
}
|
|
|
|
void MATBENCH_fn_vDeleteMaterialRef( GLI_tdstMaterial *_pst_Material )
|
|
{
|
|
long i;
|
|
|
|
for (i = 0; i < gl_NumberOfMaterials; i++)
|
|
{
|
|
if ( _pst_Material == gapst_Material[ i ] )
|
|
{
|
|
memmove( gapst_Material[ i ], gapst_Material[ i + 1 ], (gl_NumberOfMaterials - (i + 1)) * sizeof( GLI_tdstMaterial *) );
|
|
gl_NumberOfMaterials--;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
void MATBENCH_fn_vWriteMaterialInfoInFile( char *_szTitle )
|
|
{
|
|
FILE *hpFile;
|
|
long i;
|
|
char szFileName[ 20 ];
|
|
long lScroll, lAnimate;
|
|
|
|
i = 0;
|
|
while(1)
|
|
{
|
|
sprintf( szFileName, "MatBench%03d.log", i );
|
|
if (_access( szFileName, 0 ) != 0)
|
|
break;
|
|
if (i++ == 1000)
|
|
return;
|
|
}
|
|
|
|
if ( (hpFile = fopen( szFileName, "wt" )) == NULL )
|
|
return;
|
|
|
|
fprintf(hpFile, "Material stats : %s, %d materials\r\n\r\n", _szTitle, gl_NumberOfMaterials );
|
|
|
|
lScroll = lAnimate = 0;
|
|
|
|
for (i = 0; i < gl_NumberOfMaterials; i++ )
|
|
{
|
|
fprintf( hpFile, "%08X, %08X, %2d, %2d , %08X %s\r\n",
|
|
gapst_Material[i],
|
|
gapst_Material[i]->xMaterialType,
|
|
gapst_Material[i]->lIncrementIsEnable,
|
|
gapst_Material[i]->lNumberOfDisplayNode,
|
|
gapst_Material[i]->p_stTexture,
|
|
gapst_Material[i]->p_stTexture ? gapst_Material[i]->p_stTexture->a255_cFileName :""
|
|
);
|
|
if (gapst_Material[i]->lIncrementIsEnable)
|
|
lScroll++;
|
|
if (gapst_Material[i]->lNumberOfDisplayNode)
|
|
lAnimate++;
|
|
}
|
|
|
|
fprintf( hpFile, "\r\n" );
|
|
fprintf( hpFile, "Material structure size : %d => %d \r\n", sizeof ( GLI_tdstMaterial ), gl_NumberOfMaterials * sizeof( GLI_tdstMaterial ) );
|
|
fprintf( hpFile, "Optimized size = %d\r\n", gl_NumberOfMaterials * 84 + lScroll * 20 + lAnimate * 24 );
|
|
|
|
gl_NumberOfMaterials = 0;
|
|
|
|
|
|
fclose( hpFile );
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* BENCH_MATERIAL */
|