modify original vtex and add png support for it
This commit is contained in:
parent
3daa537791
commit
54f174d262
@ -54,6 +54,8 @@ extern void longjmp( jmp_buf, int ) __attribute__((noreturn));
|
|||||||
extern IEngineReplay *g_pEngine;
|
extern IEngineReplay *g_pEngine;
|
||||||
#elif ENGINE_DLL
|
#elif ENGINE_DLL
|
||||||
#include "EngineInterface.h"
|
#include "EngineInterface.h"
|
||||||
|
#elif UTILS
|
||||||
|
// OwO
|
||||||
#else
|
#else
|
||||||
#include "cdll_int.h"
|
#include "cdll_int.h"
|
||||||
extern IVEngineClient *engine;
|
extern IVEngineClient *engine;
|
||||||
@ -61,10 +63,23 @@ extern void longjmp( jmp_buf, int ) __attribute__((noreturn));
|
|||||||
|
|
||||||
// use the JPEGLIB_USE_STDIO define so that we can read in jpeg's from outside the game directory tree.
|
// use the JPEGLIB_USE_STDIO define so that we can read in jpeg's from outside the game directory tree.
|
||||||
#define JPEGLIB_USE_STDIO
|
#define JPEGLIB_USE_STDIO
|
||||||
|
#if ANDROID
|
||||||
|
#include "android/jpeglib/jpeglib.h"
|
||||||
|
#else
|
||||||
#include "jpeglib/jpeglib.h"
|
#include "jpeglib/jpeglib.h"
|
||||||
|
#endif
|
||||||
#undef JPEGLIB_USE_STDIO
|
#undef JPEGLIB_USE_STDIO
|
||||||
|
|
||||||
|
|
||||||
|
#if HAVE_PNG
|
||||||
|
|
||||||
|
#if ANDROID
|
||||||
#include "libpng/png.h"
|
#include "libpng/png.h"
|
||||||
|
#else
|
||||||
|
#include <png.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
|
||||||
@ -665,11 +680,29 @@ unsigned char *ImgUtl_ReadPNGAsRGBA( const char *pngPath, int &width, int &heigh
|
|||||||
|
|
||||||
// Just load the whole file into a memory buffer
|
// Just load the whole file into a memory buffer
|
||||||
CUtlBuffer bufFileContents;
|
CUtlBuffer bufFileContents;
|
||||||
|
|
||||||
|
#if UTILS
|
||||||
|
static char buf[8192];
|
||||||
|
FILE *readfile = fopen(pngPath, "rb");
|
||||||
|
if( !readfile )
|
||||||
|
{
|
||||||
|
errcode = CE_CANT_OPEN_SOURCE_FILE;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t size;
|
||||||
|
while( ( size = fread(buf, 1, sizeof(buf), readfile ) ) > 0 )
|
||||||
|
bufFileContents.Put( buf, size );
|
||||||
|
|
||||||
|
// Load it
|
||||||
|
return ImgUtl_ReadPNGAsRGBAFromBuffer( bufFileContents, width, height, errcode );
|
||||||
|
#else
|
||||||
if ( !g_pFullFileSystem->ReadFile( pngPath, NULL, bufFileContents ) )
|
if ( !g_pFullFileSystem->ReadFile( pngPath, NULL, bufFileContents ) )
|
||||||
{
|
{
|
||||||
errcode = CE_CANT_OPEN_SOURCE_FILE;
|
errcode = CE_CANT_OPEN_SOURCE_FILE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Load it
|
// Load it
|
||||||
return ImgUtl_ReadPNGAsRGBAFromBuffer( bufFileContents, width, height, errcode );
|
return ImgUtl_ReadPNGAsRGBAFromBuffer( bufFileContents, width, height, errcode );
|
||||||
@ -1473,7 +1506,7 @@ ConversionErrorType ImgUtl_ConvertTGAToVTF(const char *tgaPath, int nMaxWidth/*=
|
|||||||
inbuf.SeekPut( CUtlBuffer::SEEK_HEAD, nBytesRead );
|
inbuf.SeekPut( CUtlBuffer::SEEK_HEAD, nBytesRead );
|
||||||
|
|
||||||
// load vtex_dll.dll and get the interface to it.
|
// load vtex_dll.dll and get the interface to it.
|
||||||
CSysModule *vtexmod = Sys_LoadModule("vtex_dll");
|
CSysModule *vtexmod = Sys_LoadModule("vtex_dll" DLL_EXT_STRING);
|
||||||
if (vtexmod == NULL)
|
if (vtexmod == NULL)
|
||||||
{
|
{
|
||||||
Msg( "Failed to open TGA conversion module vtex_dll: %s\n", tgaPath);
|
Msg( "Failed to open TGA conversion module vtex_dll: %s\n", tgaPath);
|
||||||
@ -1522,6 +1555,17 @@ static void DoCopyFile( const char *source, const char *destination )
|
|||||||
::COM_CopyFile( source, destination );
|
::COM_CopyFile( source, destination );
|
||||||
#elif REPLAY_DLL
|
#elif REPLAY_DLL
|
||||||
g_pEngine->CopyFile( source, destination );
|
g_pEngine->CopyFile( source, destination );
|
||||||
|
#elif UTILS
|
||||||
|
static char buf[16384];
|
||||||
|
FILE *readfile = fopen(source, "rb");
|
||||||
|
FILE *writefile = fopen(destination, "wb");
|
||||||
|
|
||||||
|
size_t size = 0;
|
||||||
|
while( (size = fread(buf, sizeof(buf), 1, readfile)) != 0 )
|
||||||
|
fwrite(buf, size, 1, writefile);
|
||||||
|
|
||||||
|
fclose(readfile);
|
||||||
|
fclose(writefile);
|
||||||
#else
|
#else
|
||||||
engine->CopyLocalFile( source, destination );
|
engine->CopyLocalFile( source, destination );
|
||||||
#endif
|
#endif
|
||||||
@ -1712,12 +1756,12 @@ ConversionErrorType ImgUtl_ConvertToVTFAndDumpVMT( const char *pInPath, const ch
|
|||||||
Q_strncpy(finalPath, com_gamedir, sizeof(finalPath));
|
Q_strncpy(finalPath, com_gamedir, sizeof(finalPath));
|
||||||
#elif REPLAY_DLL
|
#elif REPLAY_DLL
|
||||||
Q_strncpy(finalPath, g_pEngine->GetGameDir(), sizeof(finalPath));
|
Q_strncpy(finalPath, g_pEngine->GetGameDir(), sizeof(finalPath));
|
||||||
#else
|
#elif !UTILS
|
||||||
Q_strncpy(finalPath, engine->GetGameDirectory(), sizeof(finalPath));
|
Q_strncpy(finalPath, engine->GetGameDirectory(), sizeof(finalPath));
|
||||||
#endif
|
#endif
|
||||||
Q_strncat(finalPath, szOutDir, sizeof(finalPath), COPY_ALL_CHARACTERS);
|
Q_strncat(finalPath, szOutDir, sizeof(finalPath), COPY_ALL_CHARACTERS);
|
||||||
Q_strncat(finalPath, vtfFilename, sizeof(finalPath), COPY_ALL_CHARACTERS);
|
Q_strncat(finalPath, vtfFilename, sizeof(finalPath), COPY_ALL_CHARACTERS);
|
||||||
|
|
||||||
c = finalPath + strlen(finalPath);
|
c = finalPath + strlen(finalPath);
|
||||||
while ((c > finalPath) && (*(c-1) != '.'))
|
while ((c > finalPath) && (*(c-1) != '.'))
|
||||||
{
|
{
|
||||||
@ -1829,6 +1873,7 @@ ConversionErrorType ImgUtl_WriteGenericVMT( const char *vtfPath, const char *pMa
|
|||||||
return CE_SUCCESS;
|
return CE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_PNG
|
||||||
static void WritePNGData( png_structp png_ptr, png_bytep inBytes, png_size_t byteCountToWrite )
|
static void WritePNGData( png_structp png_ptr, png_bytep inBytes, png_size_t byteCountToWrite )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1847,7 +1892,6 @@ static void FlushPNGData( png_structp png_ptr )
|
|||||||
// We're writing to a memory buffer, it's a NOP
|
// We're writing to a memory buffer, it's a NOP
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_PNG
|
|
||||||
ConversionErrorType ImgUtl_WriteRGBAAsPNGToBuffer( const unsigned char *pRGBAData, int nWidth, int nHeight, CUtlBuffer &bufOutData, int nStride )
|
ConversionErrorType ImgUtl_WriteRGBAAsPNGToBuffer( const unsigned char *pRGBAData, int nWidth, int nHeight, CUtlBuffer &bufOutData, int nStride )
|
||||||
{
|
{
|
||||||
#if !defined( _X360 )
|
#if !defined( _X360 )
|
||||||
|
@ -109,7 +109,8 @@ def build(bld):
|
|||||||
'../public/tier0',
|
'../public/tier0',
|
||||||
'../public/tier1',
|
'../public/tier1',
|
||||||
'../common',
|
'../common',
|
||||||
'../common/GameUI'
|
'../common/GameUI',
|
||||||
|
'../thirdparty'
|
||||||
]
|
]
|
||||||
|
|
||||||
defines = []
|
defines = []
|
||||||
|
2
lib
2
lib
@ -1 +1 @@
|
|||||||
Subproject commit dd9c273d2deaf4d75b6e371a9707755e65d26010
|
Subproject commit 9ffeba566ef076b829041f19f015155e21f325ed
|
@ -1 +1 @@
|
|||||||
Subproject commit 2e8dde2e935d4779da5cdaa6c6e5c1b872b0401e
|
Subproject commit cc41c319aabc287b1f7439228af5a9edeb31ee05
|
@ -42,10 +42,8 @@
|
|||||||
#include "appframework/IAppSystemGroup.h"
|
#include "appframework/IAppSystemGroup.h"
|
||||||
|
|
||||||
#include "tier2/tier2.h"
|
#include "tier2/tier2.h"
|
||||||
#include "tier2/p4helpers.h"
|
|
||||||
#include "p4lib/ip4.h"
|
|
||||||
|
|
||||||
#include "tier1/checksum_crc.h"
|
#include "tier1/checksum_crc.h"
|
||||||
|
#include "imageutils.h"
|
||||||
|
|
||||||
#define FF_TRYAGAIN 1
|
#define FF_TRYAGAIN 1
|
||||||
#define FF_DONTPROCESS 2
|
#define FF_DONTPROCESS 2
|
||||||
@ -59,20 +57,14 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define DEBUG_NO_COMPRESSION
|
//#define DEBUG_NO_COMPRESSION
|
||||||
static bool g_NoPause = false;
|
|
||||||
static bool g_Quiet = false;
|
static bool g_Quiet = false;
|
||||||
static const char *g_ShaderName = NULL;
|
static const char *g_ShaderName = NULL;
|
||||||
static bool g_CreateDir = true;
|
static bool g_CreateDir = true;
|
||||||
static bool g_UseGameDir = true;
|
static bool g_UseGameDir = true;
|
||||||
|
|
||||||
static bool g_bUseStandardError = false;
|
|
||||||
static bool g_bWarningsAsErrors = false;
|
static bool g_bWarningsAsErrors = false;
|
||||||
|
|
||||||
static bool g_bUsedAsLaunchableDLL = false;
|
static bool g_bUsedAsLaunchableDLL = false;
|
||||||
|
|
||||||
static bool g_bNoTga = false;
|
|
||||||
static bool g_bNoPsd = false;
|
|
||||||
|
|
||||||
static char g_ForcedOutputDir[MAX_PATH];
|
static char g_ForcedOutputDir[MAX_PATH];
|
||||||
|
|
||||||
|
|
||||||
@ -110,22 +102,11 @@ protected:
|
|||||||
static VTexVMTParam_t g_VMTParams[MAX_VMT_PARAMS];
|
static VTexVMTParam_t g_VMTParams[MAX_VMT_PARAMS];
|
||||||
|
|
||||||
static int g_NumVMTParams = 0;
|
static int g_NumVMTParams = 0;
|
||||||
static enum Mode { eModePSD, eModeTGA, eModePFM } g_eMode = eModePSD;
|
static enum Mode { eModePSD, eModeTGA, eModePFM, eModePNG } g_eMode = eModePSD;
|
||||||
|
|
||||||
// NOTE: these must stay in the same order as CubeMapFaceIndex_t.
|
// NOTE: these must stay in the same order as CubeMapFaceIndex_t.
|
||||||
static const char *g_CubemapFacingNames[7] = { "rt", "lf", "bk", "ft", "up", "dn", "sph" };
|
static const char *g_CubemapFacingNames[7] = { "rt", "lf", "bk", "ft", "up", "dn", "sph" };
|
||||||
|
|
||||||
static void Pause( void )
|
|
||||||
{
|
|
||||||
if( !g_NoPause )
|
|
||||||
{
|
|
||||||
printf( "Hit a key to continue\n" );
|
|
||||||
#ifdef WIN32
|
|
||||||
getch();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool VTexErrorAborts()
|
static bool VTexErrorAborts()
|
||||||
{
|
{
|
||||||
if ( CommandLine()->FindParm( "-crcvalidate" ) )
|
if ( CommandLine()->FindParm( "-crcvalidate" ) )
|
||||||
@ -149,16 +130,9 @@ static void VTexError( const char *pFormat, ... )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( g_bUseStandardError )
|
|
||||||
{
|
fprintf( stderr, "ERROR: %s", str );
|
||||||
Error( "ERROR: %s", str );
|
exit( 1 );
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf( stderr, "ERROR: %s", str );
|
|
||||||
Pause();
|
|
||||||
exit( 1 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -177,7 +151,6 @@ static void VTexWarning( const char *pFormat, ... )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf( stderr, "WARN: %s", str );
|
fprintf( stderr, "WARN: %s", str );
|
||||||
Pause();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,6 +639,8 @@ static const char *GetSourceExtension( void )
|
|||||||
return ".tga";
|
return ".tga";
|
||||||
case eModePFM:
|
case eModePFM:
|
||||||
return ".pfm";
|
return ".pfm";
|
||||||
|
case eModePNG:
|
||||||
|
return ".png";
|
||||||
default:
|
default:
|
||||||
return ".tga";
|
return ".tga";
|
||||||
}
|
}
|
||||||
@ -932,8 +907,6 @@ static bool LoadFile( const char *pFileName, CUtlBuffer &buf, bool bFailOnError,
|
|||||||
|
|
||||||
buf.SeekPut( CUtlBuffer::SEEK_HEAD, nBytesRead );
|
buf.SeekPut( CUtlBuffer::SEEK_HEAD, nBytesRead );
|
||||||
|
|
||||||
{ CP4AutoAddFile autop4( pFileName ); /* add loaded file to P4 */ }
|
|
||||||
|
|
||||||
// Auto-compute buffer hash if necessary
|
// Auto-compute buffer hash if necessary
|
||||||
if ( puiHash )
|
if ( puiHash )
|
||||||
ComputeBufferHash( buf.Base(), nBytesRead, *puiHash );
|
ComputeBufferHash( buf.Base(), nBytesRead, *puiHash );
|
||||||
@ -991,6 +964,34 @@ static void InitializeSrcTexture_TGA( IVTFTexture *pTexture, const char *pInputF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void InitializeSrcTexture_PNG( IVTFTexture *pTexture, const char *pInputFileName,
|
||||||
|
CUtlBuffer &pngBuffer, int nDepth, int nFrameCount,
|
||||||
|
const VTexConfigInfo_t &info )
|
||||||
|
{
|
||||||
|
int nWidth, nHeight;
|
||||||
|
ImageFormat imageFormat;
|
||||||
|
float flSrcGamma;
|
||||||
|
|
||||||
|
ConversionErrorType error = CE_SUCCESS;
|
||||||
|
unsigned char *data = ImgUtl_ReadPNGAsRGBAFromBuffer( pngBuffer, nWidth, nHeight, error );
|
||||||
|
if (error != CE_SUCCESS)
|
||||||
|
Error( "PNG %s is bogus!\n", pInputFileName );
|
||||||
|
|
||||||
|
pngBuffer.SeekPut( CUtlBuffer::SEEK_HEAD, 0 );
|
||||||
|
pngBuffer.Put( data, nWidth*nHeight*4 );
|
||||||
|
|
||||||
|
nWidth /= info.m_nReduceX;
|
||||||
|
nHeight /= info.m_nReduceY;
|
||||||
|
|
||||||
|
FILE *f = fopen("shit", "wb");
|
||||||
|
fwrite(pngBuffer.Base(), 1, 256*256*4, f);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
if (!pTexture->Init( nWidth, nHeight, nDepth, IMAGE_FORMAT_DEFAULT, info.m_nFlags, nFrameCount ))
|
||||||
|
{
|
||||||
|
Error( "Error initializing texture %s\n", pInputFileName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// HDRFIXME: Put this somewhere better than this.
|
// HDRFIXME: Put this somewhere better than this.
|
||||||
// This reads an integer from a binary CUtlBuffer.
|
// This reads an integer from a binary CUtlBuffer.
|
||||||
@ -1089,6 +1090,9 @@ static void InitializeSrcTexture( IVTFTexture *pTexture, const char *pInputFileN
|
|||||||
case eModeTGA:
|
case eModeTGA:
|
||||||
InitializeSrcTexture_TGA( pTexture, pInputFileName, tgaBuffer, nDepth, nFrameCount, info );
|
InitializeSrcTexture_TGA( pTexture, pInputFileName, tgaBuffer, nDepth, nFrameCount, info );
|
||||||
break;
|
break;
|
||||||
|
case eModePNG:
|
||||||
|
InitializeSrcTexture_PNG( pTexture, pInputFileName, tgaBuffer, nDepth, nFrameCount, info );
|
||||||
|
break;
|
||||||
case eModePFM:
|
case eModePFM:
|
||||||
InitializeSrcTexture_PFM( pTexture, pInputFileName, tgaBuffer, nDepth, nFrameCount, info );
|
InitializeSrcTexture_PFM( pTexture, pInputFileName, tgaBuffer, nDepth, nFrameCount, info );
|
||||||
break;
|
break;
|
||||||
@ -1388,6 +1392,31 @@ static bool LoadFaceFromTGA( IVTFTexture *pTexture, CUtlBuffer &tgaBuffer, int z
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Loads a face from a PNG image
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
static bool LoadFaceFromPNG( IVTFTexture *pTexture, CUtlBuffer &tgaBuffer, int z, int nFrame, int nFace, float flGamma, const VTexConfigInfo_t &info )
|
||||||
|
{
|
||||||
|
// NOTE: This only works because all mip levels are stored sequentially
|
||||||
|
// in memory, starting with the highest mip level. It also only works
|
||||||
|
// because the VTF Texture store *all* mip levels down to 1x1
|
||||||
|
|
||||||
|
// Get the information from the file...
|
||||||
|
int nWidth, nHeight;
|
||||||
|
ImageFormat imageFormat;
|
||||||
|
float flSrcGamma;
|
||||||
|
|
||||||
|
ConversionErrorType error = CE_SUCCESS;
|
||||||
|
|
||||||
|
// Load the tga and create all mipmap levels
|
||||||
|
unsigned char *pDestBits = pTexture->ImageData( nFrame, nFace, 0, 0, 0, z );
|
||||||
|
|
||||||
|
memcpy( pDestBits, tgaBuffer.Base(), tgaBuffer.TellPut() );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Loads a face from a PFM image
|
// Loads a face from a PFM image
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1451,6 +1480,9 @@ static bool LoadFaceFromX( IVTFTexture *pTexture, CUtlBuffer &tgaBuffer, int z,
|
|||||||
case eModeTGA:
|
case eModeTGA:
|
||||||
return LoadFaceFromTGA( pTexture, tgaBuffer, z, nFrame, nFace, flGamma, info );
|
return LoadFaceFromTGA( pTexture, tgaBuffer, z, nFrame, nFace, flGamma, info );
|
||||||
break;
|
break;
|
||||||
|
case eModePNG:
|
||||||
|
return LoadFaceFromPNG( pTexture, tgaBuffer, z, nFrame, nFace, flGamma, info );
|
||||||
|
break;
|
||||||
case eModePFM:
|
case eModePFM:
|
||||||
return LoadFaceFromPFM( pTexture, tgaBuffer, z, nFrame, nFace, flGamma, info );
|
return LoadFaceFromPFM( pTexture, tgaBuffer, z, nFrame, nFace, flGamma, info );
|
||||||
break;
|
break;
|
||||||
@ -1905,7 +1937,7 @@ bool ProcessFiles( const char *pFullNameWithoutExtension,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write it!
|
// Write it!
|
||||||
if ( g_CreateDir == true )
|
if ( g_CreateDir )
|
||||||
MakeDirHier( pOutputDir ); //It'll create it if it doesn't exist.
|
MakeDirHier( pOutputDir ); //It'll create it if it doesn't exist.
|
||||||
|
|
||||||
// Make sure the CRC hasn't been modified since finalized
|
// Make sure the CRC hasn't been modified since finalized
|
||||||
@ -1918,7 +1950,6 @@ bool ProcessFiles( const char *pFullNameWithoutExtension,
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
CP4AutoEditAddFile autop4( dstFileName );
|
|
||||||
FILE *fp = fopen( dstFileName, "wb" );
|
FILE *fp = fopen( dstFileName, "wb" );
|
||||||
if( !fp )
|
if( !fp )
|
||||||
{
|
{
|
||||||
@ -2022,10 +2053,9 @@ static bool LoadConfigFile( const char *pFileBaseName, VTexConfigInfo_t &info, b
|
|||||||
|
|
||||||
info.m_LookDir = LOOK_DOWN_Z;
|
info.m_LookDir = LOOK_DOWN_Z;
|
||||||
|
|
||||||
|
|
||||||
// Try TGA file with config
|
// Try TGA file with config
|
||||||
memcpy( pFileName + lenBaseName, ".tga", 4 );
|
memcpy( pFileName + lenBaseName, ".tga", 4 );
|
||||||
if ( !bOK && !g_bNoTga && ( 00 == access( pFileName, 00 ) ) ) // TGA file exists
|
if ( !bOK && ( 00 == access( pFileName, 00 ) ) ) // TGA file exists
|
||||||
{
|
{
|
||||||
g_eMode = eModeTGA;
|
g_eMode = eModeTGA;
|
||||||
|
|
||||||
@ -2059,14 +2089,10 @@ static bool LoadConfigFile( const char *pFileBaseName, VTexConfigInfo_t &info, b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy( pFileName + lenBaseName, ".tga", 4 );
|
memcpy( pFileName + lenBaseName, ".tga", 4 );
|
||||||
if ( g_bNoTga && ( 00 == access( pFileName, 00 ) ) )
|
|
||||||
{
|
|
||||||
printf( "Warning: -notga disables \"%s\"\n", pFileName );
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSD file attempt
|
// PSD file attempt
|
||||||
memcpy( pFileName + lenBaseName, ".psd", 4 );
|
memcpy( pFileName + lenBaseName, ".psd", 4 );
|
||||||
if ( !bOK && !g_bNoPsd ) // If PSD mode was not disabled
|
if ( !bOK && ( 00 == access( pFileName, 00 ) ) ) // If PSD mode was not disabled
|
||||||
{
|
{
|
||||||
g_eMode = eModePSD;
|
g_eMode = eModePSD;
|
||||||
|
|
||||||
@ -2108,12 +2134,14 @@ static bool LoadConfigFile( const char *pFileBaseName, VTexConfigInfo_t &info, b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( 00 == access( pFileName, 00 ) )
|
|
||||||
|
// PNG file attempt
|
||||||
|
memcpy( pFileName + lenBaseName, ".png", 4 );
|
||||||
|
if ( !bOK ) // If PNG mode was not disabled
|
||||||
{
|
{
|
||||||
if ( !bOK )
|
g_eMode = eModePNG;
|
||||||
printf( "Warning: -nopsd disables \"%s\"\n", pFileName );
|
info.m_nFlags |= TEXTUREFLAGS_NOMIP;
|
||||||
else
|
bOK = true;
|
||||||
printf( "Warning: psd file \"%s\" exists, but not used, delete tga and txt files to use psd file directly\n", pFileName );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try TXT file as config again for TGA cubemap / PFM
|
// Try TXT file as config again for TGA cubemap / PFM
|
||||||
@ -2155,11 +2183,7 @@ static bool LoadConfigFile( const char *pFileBaseName, VTexConfigInfo_t &info, b
|
|||||||
|
|
||||||
if ( !bOK )
|
if ( !bOK )
|
||||||
{
|
{
|
||||||
VTexError( "\"%s\" does not specify valid %s%sPFM+TXT files!\n",
|
VTexError( "\"%s\" does not specify valid PSD or TGA or PFM+TXT files!\n");
|
||||||
pFileBaseName,
|
|
||||||
g_bNoPsd ? "" : "PSD or ",
|
|
||||||
g_bNoTga ? "" : "TGA or "
|
|
||||||
);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2242,15 +2266,13 @@ static bool LoadConfigFile( const char *pFileBaseName, VTexConfigInfo_t &info, b
|
|||||||
void Usage( void )
|
void Usage( void )
|
||||||
{
|
{
|
||||||
VTexError(
|
VTexError(
|
||||||
"Usage: vtex [-outdir dir] [-quiet] [-nopause] [-mkdir] [-shader ShaderName] [-vmtparam Param Value] tex1.txt tex2.txt . . .\n"
|
"Usage: vtex [-quiet] [-mkdir] [-shader ShaderName] [-vmtparam Param Value] tex1.txt tex2.txt . . .\n"
|
||||||
"-quiet : don't print anything out, don't pause for input\n"
|
"-quiet : don't print anything out, don't pause for input\n"
|
||||||
"-warningsaserrors : treat warnings as errors\n"
|
"-warningsaserrors : treat warnings as errors\n"
|
||||||
"-nopause : don't pause for input\n"
|
|
||||||
"-nomkdir : don't create destination folder if it doesn't exist\n"
|
"-nomkdir : don't create destination folder if it doesn't exist\n"
|
||||||
"-vmtparam : adds parameter and value to the .vmt file\n"
|
"-vmtparam : adds parameter and value to the .vmt file\n"
|
||||||
"-outdir <dir> : write output to the specified dir regardless of source filename and vproject\n"
|
|
||||||
"-deducepath : deduce path of sources by target file names\n"
|
"-deducepath : deduce path of sources by target file names\n"
|
||||||
"-quickconvert : use with \"-nop4 -dontusegamedir -quickconvert\" to upgrade old .vmt files\n"
|
"-quickconvert : use with \"-dontusegamedir -quickconvert\" to upgrade old .vmt files\n"
|
||||||
"-crcvalidate : validate .vmt against the sources\n"
|
"-crcvalidate : validate .vmt against the sources\n"
|
||||||
"-crcforce : generate a new .vmt even if sources crc matches\n"
|
"-crcforce : generate a new .vmt even if sources crc matches\n"
|
||||||
"\teg: -vmtparam $ignorez 1 -vmtparam $translucent 1\n"
|
"\teg: -vmtparam $ignorez 1 -vmtparam $translucent 1\n"
|
||||||
@ -2431,7 +2453,7 @@ bool Process_File( char *pInputBaseName, int maxlen )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Usage:
|
// Usage:
|
||||||
// vtex -nop4 -dontusegamedir -quickconvert u:\data\game\tf\texture.vtf
|
// vtex -dontusegamedir -quickconvert u:\data\game\tf\texture.vtf
|
||||||
// Will read the old texture format and write the new texture format
|
// Will read the old texture format and write the new texture format
|
||||||
//
|
//
|
||||||
if ( CommandLine()->FindParm( "-quickconvert" ) )
|
if ( CommandLine()->FindParm( "-quickconvert" ) )
|
||||||
@ -2550,8 +2572,6 @@ bool Process_File( char *pInputBaseName, int maxlen )
|
|||||||
|
|
||||||
fprintf( fp, "}\n" );
|
fprintf( fp, "}\n" );
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
|
|
||||||
CP4AutoAddFile autop4( buf );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2574,7 +2594,6 @@ static SpewRetval_t VTexOutputFunc( SpewType_t spewType, char const *pMsg )
|
|||||||
printf( "%s", pMsg );
|
printf( "%s", pMsg );
|
||||||
if (spewType == SPEW_ERROR)
|
if (spewType == SPEW_ERROR)
|
||||||
{
|
{
|
||||||
Pause();
|
|
||||||
return SPEW_ABORT;
|
return SPEW_ABORT;
|
||||||
}
|
}
|
||||||
return (spewType == SPEW_ASSERT) ? SPEW_DEBUGGER : SPEW_CONTINUE;
|
return (spewType == SPEW_ASSERT) ? SPEW_DEBUGGER : SPEW_CONTINUE;
|
||||||
@ -2665,7 +2684,7 @@ bool CSuggestGameDirHelper::MySuggestFn( CFSSteamSetupInfo const *pFsSteamSetupI
|
|||||||
|
|
||||||
int CVTex::VTex( int argc, char **argv )
|
int CVTex::VTex( int argc, char **argv )
|
||||||
{
|
{
|
||||||
CommandLine()->CreateCmdLine( argc, argv );
|
// CommandLine()->CreateCmdLine( argc, argv );
|
||||||
|
|
||||||
if ( g_bUsedAsLaunchableDLL )
|
if ( g_bUsedAsLaunchableDLL )
|
||||||
{
|
{
|
||||||
@ -2679,8 +2698,7 @@ int CVTex::VTex( int argc, char **argv )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_UseGameDir = true; // make sure this is initialized to true.
|
g_UseGameDir = false; // make sure this is initialized to true.
|
||||||
const char *p4ChangelistLabel = "VTex Auto Checkout";
|
|
||||||
bool bCreatedFilesystem = false;
|
bool bCreatedFilesystem = false;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@ -2691,67 +2709,22 @@ int CVTex::VTex( int argc, char **argv )
|
|||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
g_Quiet = true;
|
g_Quiet = true;
|
||||||
g_NoPause = true; // no point in pausing if we aren't going to print anything out.
|
|
||||||
}
|
}
|
||||||
else if( stricmp( argv[i], "-nopause" ) == 0 )
|
else if ( stricmp( argv[i], "-warningsaserrors" ) == 0 )
|
||||||
{
|
|
||||||
i++;
|
|
||||||
g_NoPause = true;
|
|
||||||
}
|
|
||||||
else if ( stricmp( argv[i], "-WarningsAsErrors" ) == 0 )
|
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
g_bWarningsAsErrors = true;
|
g_bWarningsAsErrors = true;
|
||||||
}
|
}
|
||||||
else if ( stricmp( argv[i], "-UseStandardError" ) == 0 )
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
g_bUseStandardError = true;
|
|
||||||
}
|
|
||||||
else if ( stricmp( argv[i], "-nopsd" ) == 0 )
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
g_bNoPsd = true;
|
|
||||||
}
|
|
||||||
else if ( stricmp( argv[i], "-notga" ) == 0 )
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
g_bNoTga = true;
|
|
||||||
}
|
|
||||||
else if ( stricmp( argv[i], "-nomkdir" ) == 0 )
|
else if ( stricmp( argv[i], "-nomkdir" ) == 0 )
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
g_CreateDir = false;
|
g_CreateDir = false;
|
||||||
}
|
}
|
||||||
else if ( stricmp( argv[i], "-mkdir" ) == 0 )
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
g_CreateDir = true;
|
|
||||||
}
|
|
||||||
else if ( stricmp( argv[i], "-game" ) == 0 )
|
|
||||||
{
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
else if ( stricmp( argv[i], "-outdir" ) == 0 )
|
else if ( stricmp( argv[i], "-outdir" ) == 0 )
|
||||||
{
|
{
|
||||||
V_strcpy_safe( g_ForcedOutputDir, argv[i+1] );
|
V_strcpy_safe( g_ForcedOutputDir, argv[i+1] );
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
else if ( stricmp( argv[i], "-p4changelistlabel" ) == 0 )
|
|
||||||
{
|
|
||||||
p4ChangelistLabel = argv[i+1];
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
else if ( stricmp( argv[i], "-p4skipchangelistlabel" ) == 0 )
|
|
||||||
{
|
|
||||||
p4ChangelistLabel = NULL;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
else if ( stricmp( argv[i], "-dontusegamedir" ) == 0)
|
|
||||||
{
|
|
||||||
++i;
|
|
||||||
g_UseGameDir = false;
|
|
||||||
}
|
|
||||||
else if( stricmp( argv[i], "-shader" ) == 0 )
|
else if( stricmp( argv[i], "-shader" ) == 0 )
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
@ -2761,14 +2734,12 @@ int CVTex::VTex( int argc, char **argv )
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( stricmp( argv[i], "-vproject" ) == 0 )
|
else if( stricmp(argv[i], "-crcvalidate") == 0 )
|
||||||
{
|
{
|
||||||
// skip this one. . we dont' use it internally.
|
i++;
|
||||||
i += 2;
|
|
||||||
}
|
}
|
||||||
else if( stricmp( argv[i], "-allowdebug" ) == 0 )
|
else if( stricmp(argv[i], "-crcforce") == 0 )
|
||||||
{
|
{
|
||||||
// skip this one. . we dont' use it internally.
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else if( stricmp( argv[i], "-vmtparam" ) == 0 )
|
else if( stricmp( argv[i], "-vmtparam" ) == 0 )
|
||||||
@ -2806,36 +2777,6 @@ int CVTex::VTex( int argc, char **argv )
|
|||||||
fprintf( stderr, "Exceeded max number of vmt parameters, extra ignored ( max %d )\n", MAX_VMT_PARAMS );
|
fprintf( stderr, "Exceeded max number of vmt parameters, extra ignored ( max %d )\n", MAX_VMT_PARAMS );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( stricmp( argv[i], "-nop4" ) == 0 )
|
|
||||||
{
|
|
||||||
// Just here to signify that -nop4 is a valid flag
|
|
||||||
++ i;
|
|
||||||
}
|
|
||||||
else if( stricmp( argv[i], "-deducepath" ) == 0 )
|
|
||||||
{
|
|
||||||
// Just here to signify that -deducepath is a valid flag
|
|
||||||
++ i;
|
|
||||||
}
|
|
||||||
else if( stricmp( argv[i], "-quickconvert" ) == 0 )
|
|
||||||
{
|
|
||||||
// Just here to signify that -quickconvert is a valid flag
|
|
||||||
++ i;
|
|
||||||
}
|
|
||||||
else if( stricmp( argv[i], "-crcvalidate" ) == 0 )
|
|
||||||
{
|
|
||||||
// Just here to signify that -crcvalidate is a valid flag
|
|
||||||
++ i;
|
|
||||||
}
|
|
||||||
else if( stricmp( argv[i], "-crcforce" ) == 0 )
|
|
||||||
{
|
|
||||||
// Just here to signify that -crcforce is a valid flag
|
|
||||||
++ i;
|
|
||||||
}
|
|
||||||
else if( stricmp( argv[i], "-p4skip" ) == 0 )
|
|
||||||
{
|
|
||||||
// Just here to signify that -p4skip is a valid flag
|
|
||||||
++ i;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -2848,6 +2789,7 @@ int CVTex::VTex( int argc, char **argv )
|
|||||||
SetSuggestGameInfoDirFn( CSuggestGameDirHelper::SuggestFn );
|
SetSuggestGameInfoDirFn( CSuggestGameDirHelper::SuggestFn );
|
||||||
|
|
||||||
// g_pFileSystem may have been inherited with -inherit_filesystem.
|
// g_pFileSystem may have been inherited with -inherit_filesystem.
|
||||||
|
|
||||||
if (g_UseGameDir && !g_pFileSystem)
|
if (g_UseGameDir && !g_pFileSystem)
|
||||||
{
|
{
|
||||||
FileSystem_Init( argv[i] );
|
FileSystem_Init( argv[i] );
|
||||||
@ -2856,56 +2798,6 @@ int CVTex::VTex( int argc, char **argv )
|
|||||||
Q_FixSlashes( gamedir, '/' );
|
Q_FixSlashes( gamedir, '/' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !CommandLine()->FindParm( "-p4skip" ) )
|
|
||||||
{
|
|
||||||
// Initialize P4
|
|
||||||
bool bP4DLLExists = false;
|
|
||||||
if ( g_pFullFileSystem )
|
|
||||||
{
|
|
||||||
bP4DLLExists = g_pFullFileSystem->FileExists( "p4lib.dll", "EXECUTABLE_PATH" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( g_bUsedAsLaunchableDLL && !CommandLine()->FindParm( "-nop4" ) && bP4DLLExists )
|
|
||||||
{
|
|
||||||
const char *pModuleName = "p4lib.dll";
|
|
||||||
CSysModule *pModule = Sys_LoadModule( pModuleName );
|
|
||||||
if ( !pModule )
|
|
||||||
{
|
|
||||||
printf( "Can't load %s.\n", pModuleName );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
CreateInterfaceFn fn = Sys_GetFactory( pModule );
|
|
||||||
if ( !fn )
|
|
||||||
{
|
|
||||||
printf( "Can't get factory from %s.\n", pModuleName );
|
|
||||||
Sys_UnloadModule( pModule );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
p4 = (IP4 *)fn( P4_INTERFACE_VERSION, NULL );
|
|
||||||
if ( !p4 )
|
|
||||||
{
|
|
||||||
printf( "Can't get IP4 interface from %s, proceeding with -nop4.\n", pModuleName );
|
|
||||||
g_p4factory->SetDummyMode( true );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p4->Connect( FileSystem_GetFactory() );
|
|
||||||
p4->Init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_p4factory->SetDummyMode( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup p4 factory
|
|
||||||
if ( p4ChangelistLabel && p4ChangelistLabel[0] != '\000' )
|
|
||||||
{
|
|
||||||
// Set the named changelist
|
|
||||||
g_p4factory->SetOpenFileChangeList( p4ChangelistLabel );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse args
|
// Parse args
|
||||||
for( ; i < argc; i++ )
|
for( ; i < argc; i++ )
|
||||||
{
|
{
|
||||||
@ -2921,59 +2813,6 @@ int CVTex::VTex( int argc, char **argv )
|
|||||||
Process_File( pInputBaseName, sizeof(pInputBaseName) );
|
Process_File( pInputBaseName, sizeof(pInputBaseName) );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
char search[ 128 ];
|
|
||||||
char basedir[MAX_PATH];
|
|
||||||
char ext[_MAX_EXT];
|
|
||||||
char filename[_MAX_FNAME];
|
|
||||||
|
|
||||||
_splitpath( pInputBaseName, NULL, NULL, NULL, ext ); //find extension wanted
|
|
||||||
|
|
||||||
if ( !Q_ExtractFilePath ( pInputBaseName, basedir, sizeof( basedir ) ) )
|
|
||||||
strcpy( basedir, ".\\" );
|
|
||||||
|
|
||||||
sprintf( search, "%s\\*.*", basedir );
|
|
||||||
|
|
||||||
WIN32_FIND_DATA wfd;
|
|
||||||
HANDLE hResult;
|
|
||||||
memset(&wfd, 0, sizeof(WIN32_FIND_DATA));
|
|
||||||
|
|
||||||
hResult = FindFirstFile( search, &wfd );
|
|
||||||
|
|
||||||
if ( hResult != INVALID_HANDLE_VALUE )
|
|
||||||
{
|
|
||||||
sprintf( filename, "%s%s", basedir, wfd.cFileName );
|
|
||||||
|
|
||||||
if ( wfd.cFileName[0] != '.' )
|
|
||||||
Process_File( filename, sizeof( filename ) );
|
|
||||||
|
|
||||||
int iFFType = Find_Files( wfd, hResult, basedir, ext );
|
|
||||||
|
|
||||||
while ( iFFType )
|
|
||||||
{
|
|
||||||
sprintf( filename, "%s%s", basedir, wfd.cFileName );
|
|
||||||
|
|
||||||
if ( wfd.cFileName[0] != '.' && iFFType != FF_DONTPROCESS )
|
|
||||||
Process_File( filename, sizeof( filename ) );
|
|
||||||
|
|
||||||
iFFType = Find_Files( wfd, hResult, basedir, ext );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( iFFType == 0 )
|
|
||||||
{
|
|
||||||
FindClose( hResult );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shutdown P4
|
|
||||||
if ( g_bUsedAsLaunchableDLL && p4 && !CommandLine()->FindParm( "-p4skip" ) )
|
|
||||||
{
|
|
||||||
p4->Shutdown();
|
|
||||||
p4->Disconnect();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bCreatedFilesystem )
|
if ( bCreatedFilesystem )
|
||||||
@ -2987,7 +2826,6 @@ int CVTex::VTex( int argc, char **argv )
|
|||||||
SpewOutputFunc( NULL );
|
SpewOutputFunc( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
Pause();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
58
utils/vtex/wscript
Executable file
58
utils/vtex/wscript
Executable file
@ -0,0 +1,58 @@
|
|||||||
|
#! /usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
from waflib import Utils
|
||||||
|
import os
|
||||||
|
|
||||||
|
top = '.'
|
||||||
|
PROJECT_NAME = 'vtex_dll'
|
||||||
|
|
||||||
|
def options(opt):
|
||||||
|
# stub
|
||||||
|
return
|
||||||
|
|
||||||
|
def configure(conf):
|
||||||
|
conf.define('VTEX_DLL', 1)
|
||||||
|
conf.define('UTILS', 1)
|
||||||
|
conf.define('VTEX_DLL_EXPORTS', 1)
|
||||||
|
conf.define('PROTECTED_THINGS_DISABLE', 1)
|
||||||
|
|
||||||
|
|
||||||
|
def build(bld):
|
||||||
|
source = [
|
||||||
|
'../common/cmdlib.cpp',
|
||||||
|
'../../public/filesystem_helpers.cpp',
|
||||||
|
'../../public/filesystem_init.cpp',
|
||||||
|
'../common/filesystem_tools.cpp',
|
||||||
|
'vtex.cpp',
|
||||||
|
'../../common/imageutils.cpp'
|
||||||
|
]
|
||||||
|
|
||||||
|
includes = [
|
||||||
|
'.',
|
||||||
|
'../../public',
|
||||||
|
'../../public/tier0',
|
||||||
|
'../../public/tier1',
|
||||||
|
'../common',
|
||||||
|
'../../common'
|
||||||
|
]
|
||||||
|
|
||||||
|
defines = []
|
||||||
|
|
||||||
|
libs = ['tier0', 'tier1', 'bitmap', 'tier2', 'vstdlib', 'mathlib', 'vtf', 'JPEG', 'PNG']
|
||||||
|
|
||||||
|
install_path = bld.env.LIBDIR
|
||||||
|
|
||||||
|
bld.shlib(
|
||||||
|
source = source,
|
||||||
|
target = PROJECT_NAME,
|
||||||
|
name = PROJECT_NAME,
|
||||||
|
features = 'c cxx',
|
||||||
|
includes = includes,
|
||||||
|
defines = defines,
|
||||||
|
use = libs,
|
||||||
|
install_path = install_path,
|
||||||
|
subsystem = bld.env.MSVC_SUBSYSTEM,
|
||||||
|
idx = bld.get_taskgen_count()
|
||||||
|
)
|
||||||
|
|
46
utils/vtexconv/vtex_launcher.cpp
Normal file
46
utils/vtexconv/vtex_launcher.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||||
|
//
|
||||||
|
// Purpose:
|
||||||
|
//
|
||||||
|
// $NoKeywords: $
|
||||||
|
//=============================================================================//
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "tier1/interface.h"
|
||||||
|
#include "ilaunchabledll.h"
|
||||||
|
|
||||||
|
|
||||||
|
int main( int argc, char **argv )
|
||||||
|
{
|
||||||
|
const char *pModuleName = "vtex_dll" DLL_EXT_STRING;
|
||||||
|
|
||||||
|
CSysModule *pModule = Sys_LoadModule( pModuleName );
|
||||||
|
if ( !pModule )
|
||||||
|
{
|
||||||
|
printf( "Can't load %s.", pModuleName );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateInterfaceFn fn = Sys_GetFactory( pModule );
|
||||||
|
if ( !fn )
|
||||||
|
{
|
||||||
|
printf( "Can't get factory from %s.", pModuleName );
|
||||||
|
Sys_UnloadModule( pModule );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ILaunchableDLL *pInterface = (ILaunchableDLL*)fn( LAUNCHABLE_DLL_INTERFACE_VERSION, NULL );
|
||||||
|
if ( !pInterface )
|
||||||
|
{
|
||||||
|
printf( "Can't get '%s' interface from %s.", LAUNCHABLE_DLL_INTERFACE_VERSION, pModuleName );
|
||||||
|
Sys_UnloadModule( pModule );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iRet = pInterface->main( argc, argv );
|
||||||
|
Sys_UnloadModule( pModule );
|
||||||
|
return iRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
48
utils/vtexconv/wscript
Executable file
48
utils/vtexconv/wscript
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#! /usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
from waflib import Utils
|
||||||
|
import os
|
||||||
|
|
||||||
|
top = '.'
|
||||||
|
PROJECT_NAME = 'vtexconv'
|
||||||
|
|
||||||
|
def options(opt):
|
||||||
|
# stub
|
||||||
|
return
|
||||||
|
|
||||||
|
def configure(conf):
|
||||||
|
conf.define('PROTECTED_THINGS_DISABLE', 1)
|
||||||
|
|
||||||
|
def build(bld):
|
||||||
|
source = [
|
||||||
|
'vtex_launcher.cpp'
|
||||||
|
]
|
||||||
|
|
||||||
|
includes = [
|
||||||
|
'.',
|
||||||
|
'../../public',
|
||||||
|
'../../public/tier0',
|
||||||
|
'../../public/tier1',
|
||||||
|
'../../common'
|
||||||
|
]
|
||||||
|
|
||||||
|
defines = []
|
||||||
|
|
||||||
|
libs = ['tier0', 'appframework','tier1','tier2','tier3','vstdlib']
|
||||||
|
|
||||||
|
install_path = bld.env.BINDIR
|
||||||
|
|
||||||
|
bld(
|
||||||
|
source = source,
|
||||||
|
target = PROJECT_NAME,
|
||||||
|
name = PROJECT_NAME,
|
||||||
|
features = 'c cxx cxxprogram',
|
||||||
|
includes = includes,
|
||||||
|
defines = defines,
|
||||||
|
use = libs,
|
||||||
|
install_path = install_path,
|
||||||
|
subsystem = bld.env.MSVC_SUBSYSTEM,
|
||||||
|
idx = bld.get_taskgen_count()
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user