summaryrefslogtreecommitdiff
path: root/utils/xbox/MakeGameData/MakeTextures.cpp
blob: f26736765af11194bfd6e62dac83c966a5a2dc9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: .360.VTF Creation
//
//=====================================================================================//

#include "MakeGameData.h"
#include "vtf/vtf.h"

//-----------------------------------------------------------------------------
// Purpose: Create the 360 VTF, use the library!
//-----------------------------------------------------------------------------
bool CreateTargetFile_VTF( const char *pSourceName, const char *pTargetName, bool bWriteToZip )
{
	CUtlBuffer	sourceBuffer;
	CUtlBuffer	targetBuffer;

	if ( !scriptlib->ReadFileToBuffer( pSourceName, sourceBuffer ) )
	{
		return false;
	}

	// using library conversion routine
	bool bSuccess = ConvertVTFTo360Format( pSourceName, sourceBuffer, targetBuffer, CompressCallback );
	if ( bSuccess )
	{
		bSuccess = WriteBufferToFile( pTargetName, targetBuffer, bWriteToZip, g_WriteModeForConversions );
	}

	return bSuccess;
}

//-----------------------------------------------------------------------------
// Get the preload data for a vtf file
//-----------------------------------------------------------------------------
bool GetPreloadData_VTF( const char *pFilename, CUtlBuffer &fileBufferIn, CUtlBuffer &preloadBufferOut )
{
	if ( !GetVTFPreload360Data( pFilename, fileBufferIn, preloadBufferOut ) )
	{
		Msg( "Can't preload: '%s', has bad version\n", pFilename );
		return false;
	}

	return true;
}