本文整理汇总了C++中torque::Path::getRootAndPath方法的典型用法代码示例。如果您正苦于以下问题:C++ Path::getRootAndPath方法的具体用法?C++ Path::getRootAndPath怎么用?C++ Path::getRootAndPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torque::Path
的用法示例。
在下文中一共展示了Path::getRootAndPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: String
HRESULT _gfxD3DXInclude::Open(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName,
LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes,
LPSTR pFullPath, DWORD cbFullPath)
{
// First try making the path relative to the parent.
Torque::Path path = Torque::Path::Join( mLastPath.last(), '/', pFileName );
path = Torque::Path::CompressPath( path );
if ( !Torque::FS::ReadFile( path, (void *&)*ppData, *pBytes, true ) )
{
// Ok... now try using the path as is.
path = String( pFileName );
path = Torque::Path::CompressPath( path );
if ( !Torque::FS::ReadFile( path, (void *&)*ppData, *pBytes, true ) )
{
AssertISV(false, avar( "Failed to open include '%s'.", pFileName));
return E_FAIL;
}
}
// If the data was of zero size then we cannot recurse
// into this file and DX won't call Close() below.
//
// So in this case don't push on the path.
if ( *pBytes > 0 )
mLastPath.push_back( path.getRootAndPath() );
return S_OK;
}
示例2: sHLSLStr
bool GFXD3D9Shader::_compileShader( const Torque::Path &filePath,
const String& target,
const D3DXMACRO *defines,
GenericConstBufferLayout* bufferLayoutF,
GenericConstBufferLayout* bufferLayoutI,
Vector<GFXShaderConstDesc> &samplerDescriptions )
{
PROFILE_SCOPE( GFXD3D9Shader_CompileShader );
HRESULT res = D3DERR_INVALIDCALL;
LPD3DXBUFFER code = NULL;
LPD3DXBUFFER errorBuff = NULL;
#ifdef TORQUE_DEBUG
U32 flags = D3DXSHADER_DEBUG;
#else
U32 flags = 0;
#endif
#ifdef TORQUE_OS_XENON
flags |= D3DXSHADER_PREFER_FLOW_CONTROL;
#endif
#ifdef D3DXSHADER_USE_LEGACY_D3DX9_31_DLL
if( D3DX_SDK_VERSION >= 32 )
{
// will need to use old compiler for 1_1 shaders - check for pixel
// or vertex shader with appropriate version.
if ((target.compare("vs1", 3) == 0) || (target.compare("vs_1", 4) == 0))
flags |= D3DXSHADER_USE_LEGACY_D3DX9_31_DLL;
if ((target.compare("ps1", 3) == 0) || (target.compare("ps_1", 4) == 0))
flags |= D3DXSHADER_USE_LEGACY_D3DX9_31_DLL;
}
#endif
#if !defined(TORQUE_OS_XENON) && (D3DX_SDK_VERSION <= 40)
#error This version of the DirectX SDK is too old. Please install a newer version of the DirectX SDK: http://msdn.microsoft.com/en-us/directx/default.aspx
#endif
ID3DXConstantTable* table = NULL;
static String sHLSLStr( "hlsl" );
static String sOBJStr( "obj" );
// Is it an HLSL shader?
if ( filePath.getExtension().equal(sHLSLStr, String::NoCase) )
{
FrameAllocatorMarker fam;
char *buffer = NULL;
// Set this so that the D3DXInclude::Open will have this
// information for relative paths.
smD3DXInclude->setPath( filePath.getRootAndPath() );
FileStream s;
if ( !s.open( filePath, Torque::FS::File::Read ) )
{
AssertISV(false, avar("GFXD3D9Shader::initShader - failed to open shader '%s'.", filePath.getFullPath().c_str()));
if ( smLogErrors )
Con::errorf( "GFXD3D9Shader::_compileShader - Failed to open shader file '%s'.",
filePath.getFullPath().c_str() );
return false;
}
// Convert the path which might have virtualized
// mount paths to a real file system path.
Torque::Path realPath;
if ( !FS::GetFSPath( filePath, realPath ) )
realPath = filePath;
// Add a #line pragma so that error and warning messages
// returned by the HLSL compiler report the right file.
String linePragma = String::ToString( "#line 1 \"%s\"\r\n", realPath.getFullPath().c_str() );
U32 linePragmaLen = linePragma.length();
U32 bufSize = s.getStreamSize();
buffer = (char *)fam.alloc( bufSize + linePragmaLen + 1 );
dStrncpy( buffer, linePragma.c_str(), linePragmaLen );
s.read( bufSize, buffer + linePragmaLen );
buffer[bufSize+linePragmaLen] = 0;
res = GFXD3DX.D3DXCompileShader( buffer, bufSize + linePragmaLen, defines, smD3DXInclude, "main",
target, flags, &code, &errorBuff, &table );
}
// Is it a precompiled obj shader?
else if ( filePath.getExtension().equal( sOBJStr, String::NoCase ) )
{
FileStream s;
if(!s.open(filePath, Torque::FS::File::Read))
{
AssertISV(false, avar("GFXD3D9Shader::initShader - failed to open shader '%s'.", filePath.getFullPath().c_str()));
if ( smLogErrors )
Con::errorf( "GFXD3D9Shader::_compileShader - Failed to open shader file '%s'.",
filePath.getFullPath().c_str() );
//.........这里部分代码省略.........