青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當(dāng)自強(qiáng)而不息

DXUT源碼分析 ---- 媒體文件查找函數(shù)

DXUT中涉及到媒體文件查找的函數(shù)有3個(gè):DXUTFindMediaSearchTypicalDirs()、DXUTFindMediaSearchParentDirs()、DXUTFindDXSDKMediaFileCch(),都位于DXUTmisc.cpp文件中。

 

DXUTFindMediaSearchTypicalDirs()分析:

DXUTFindMediaSearchTypicalDirs()這個(gè)函數(shù)用于在特定的搜索路徑中查找媒體文件,主要供DXUTFindDXSDKMediaFileCch()調(diào)用以查找媒體文件。

參數(shù)分析:

strSearchPath: 函數(shù)調(diào)用完后將媒體文件的路徑返回給該字符串(可能是當(dāng)前工作目錄路徑,也可能是全路徑)
cchSearch: strSearchPath的長度
strLeaf:指定要查找的媒體文件名
strExePath:當(dāng)前進(jìn)程執(zhí)行文件所在的目錄(全路徑名)
strExeName:當(dāng)前進(jìn)程執(zhí)行文件名(不包含擴(kuò)展名)

//--------------------------------------------------------------------------------------
// Search a set of typical directories
//--------------------------------------------------------------------------------------
bool DXUTFindMediaSearchTypicalDirs( WCHAR* strSearchPath, int cchSearch, LPCWSTR strLeaf,
WCHAR* strExePath, WCHAR* strExeName )
{
// Typical directories:
// .\
// ..\
// ..\..\
// %EXE_DIR%\
// %EXE_DIR%\..\
// %EXE_DIR%\..\..\
// %EXE_DIR%\..\%EXE_NAME%
// %EXE_DIR%\..\..\%EXE_NAME%
// DXSDK media path
    // Search in .\  
StringCchCopy( strSearchPath, cchSearch, strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
    // Search in ..\  
StringCchPrintf( strSearchPath, cchSearch, L"..\\%s", strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
    // Search in ..\..\ 
StringCchPrintf( strSearchPath, cchSearch, L"..\\..\\%s", strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
    // Search in the %EXE_DIR%\ 
StringCchPrintf( strSearchPath, cchSearch, L"%s\\%s", strExePath, strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
    // Search in the %EXE_DIR%\..\ 
StringCchPrintf( strSearchPath, cchSearch, L"%s\\..\\%s", strExePath, strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
    // Search in the %EXE_DIR%\..\..\ 
StringCchPrintf( strSearchPath, cchSearch, L"%s\\..\\..\\%s", strExePath, strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
    // Search in "%EXE_DIR%\..\%EXE_NAME%\".  This matches the DirectX SDK layout
StringCchPrintf( strSearchPath, cchSearch, L"%s\\..\\%s\\%s", strExePath, strExeName, strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
    // Search in "%EXE_DIR%\..\..\%EXE_NAME%\".  This matches the DirectX SDK layout
StringCchPrintf( strSearchPath, cchSearch, L"%s\\..\\..\\%s\\%s", strExePath, strExeName, strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
    // Search in media search dir 
    WCHAR* s_strSearchPath = DXUTMediaSearchPath();
    if( s_strSearchPath[0] != 0 )
{
StringCchPrintf( strSearchPath, cchSearch, L"%s%s", s_strSearchPath, strLeaf );
        if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
}
    return false;
}

函數(shù)首先在當(dāng)前工作目錄(.\)查找,它首先調(diào)用

StringCchCopy( strSearchPath, cchSearch, strLeaf );

將要查找的媒體文件名復(fù)制到字符串strSearchPath中,該函數(shù)聲明如下:

StringCchCopy is a replacement for strcpy. The size, in characters, of the destination buffer is provided to the function to ensure that StringCchCopy does not write past the end of this buffer.

Syntax

HRESULT StringCchCopy(      

    LPTSTR pszDest,
    size_t cchDest,
    LPCTSTR pszSrc
);

Parameters

pszDest
[out] Pointer to a buffer which receives the copied string.
cchDest
[in] Size of the destination buffer, in characters. This value must equal the length of pszSrc plus 1 to account for the copied source string and the terminating null character. The maximum number of characters allowed is STRSAFE_MAX_CCH.
pszSrc
[in] Pointer to a buffer containing the source string. This source string must be null-terminated.

Return Value

Note that this function returns an HRESULT as opposed to strcpy, which returns a pointer. It is strongly recommended that you use the SUCCEEDED and FAILED macros to test the return value of this function.

S_OK Source data was present, fully copied without truncation, and the resultant destination buffer is null-terminated.
STRSAFE_E_INVALID_PARAMETER The value in cchDest is either 0 or larger than STRSAFE_MAX_CCH.
STRSAFE_E_INSUFFICIENT_BUFFER The copy operation failed due to insufficient buffer space. The destination buffer contains a truncated, null-terminated version of the intended result. In situations where truncation is acceptable, this may not necessarily be seen as a failure condition.

Remarks

StringCchCopy provides additional processing for proper buffer handling in your code. Poor buffer handling is implicated in many security issues that involve buffer overruns. StringCchCopy always null-terminates a non-zero-length destination buffer.

StringCchCopy can be used in its generic form, or specifically as StringCchCopyA (for ANSI strings) or StringCchCopyW (for Unicode strings). The form to use is determined by your data.

String Data Type String Literal Function
char "string" StringCchCopyA
TCHAR TEXT("string") StringCchCopy
WCHAR L"string" StringCchCopyW
 

接著調(diào)用

if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
        return true;

判斷要查找的媒體文件是否存在,該函數(shù)聲明如下:

The GetFileAttributes function retrieves a set of FAT file system attributes for a specified file or directory.

To get more attribute information, use the GetFileAttributesEx function.

DWORD GetFileAttributes(
LPCTSTR lpFileName
);

Parameters

lpFileName
[in] A pointer to a null-terminated string that specifies the name of a file or directory.

In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.

Windows Me/98/95:  This string must not exceed MAX_PATH characters.

Return Values

If the function succeeds, the return value contains the attributes of the specified file or directory.

If the function fails, the return value is INVALID_FILE_ATTRIBUTES. To get extended error information, call GetLastError.

The attributes can be one or more of the following values.

Attribute Meaning
FILE_ATTRIBUTE_ARCHIVE A file or directory that is an archive file or directory.

Applications use this attribute to mark files for backup or removal.

FILE_ATTRIBUTE_COMPRESSED A file or directory that is compressed.

For a file, all of the data in the file is compressed.

For a directory, compression is the default for newly created files and subdirectories.

FILE_ATTRIBUTE_DEVICE Reserved; do not use.
FILE_ATTRIBUTE_DIRECTORY The handle that identifies a directory.
FILE_ATTRIBUTE_ENCRYPTED A file or directory that is encrypted.

For a file, all data streams in the file are encrypted.

For a directory, encryption is the default for newly created files and subdirectories.

FILE_ATTRIBUTE_HIDDEN The file or directory is hidden. It is not included in an ordinary directory listing.
FILE_ATTRIBUTE_NORMAL A file or directory that does not have other attributes set.

This attribute is valid only when used alone.

FILE_ATTRIBUTE_NOT_CONTENT_INDEXED The file is not be indexed by the content indexing service.
FILE_ATTRIBUTE_OFFLINE The data of a file is not available immediately.

This attribute indicates that the file data is physically moved to offline storage. This attribute is used by Remote Storage, which is the hierarchical storage management software. Applications should not arbitrarily change this attribute.

FILE_ATTRIBUTE_READONLY A file or directory that is read-only.

For a file, applications can read the file, but cannot write to it or delete it.

For a directory, applications cannot delete it.

FILE_ATTRIBUTE_REPARSE_POINT A file or directory that has an associated reparse point.
FILE_ATTRIBUTE_SPARSE_FILE A file that is a sparse file.
FILE_ATTRIBUTE_SYSTEM A file or directory that the operating system uses a part of, or uses exclusively.
FILE_ATTRIBUTE_TEMPORARY A file that is being used for temporary storage.

File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data is written after the handle is closed.

Remarks

When GetFileAttributes is called on a directory that contains a volume mount point, the file attributes returned are those of the directory where the volume mount point is set, not those of the root directory in a target mounted volume. To obtain the file attributes of a mounted volume, call GetVolumeNameForVolumeMountPoint to obtain the name of the target volume. Then use the resulting name in a call to GetFileAttributes. The results are the attributes of the root directory on the target volume.

接著按以下路徑搜索媒體文件:

    //      ..\
    //      ..\..\
    //      %EXE_DIR%\
    //      %EXE_DIR%\..\
    //      %EXE_DIR%\..\..\
    //      %EXE_DIR%\..\%EXE_NAME%
    //      %EXE_DIR%\..\..\%EXE_NAME%

最后在DirectX SDK媒體文件目錄中搜索媒體文件,當(dāng)然該目錄必須首先在程序中設(shè)置才會(huì)被搜索:

    // Search in media search dir 
    WCHAR* s_strSearchPath = DXUTMediaSearchPath();
    if( s_strSearchPath[0] != 0 )
{
StringCchPrintf( strSearchPath, cchSearch, L"%s%s", s_strSearchPath, strLeaf );
        if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
}

函數(shù)DXUTMediaSearchPath()返回設(shè)置的媒體文件搜索路徑:

//--------------------------------------------------------------------------------------
// Returns pointer to static media search buffer
//--------------------------------------------------------------------------------------
WCHAR* DXUTMediaSearchPath()
{
static WCHAR s_strMediaSearchPath[MAX_PATH] = {0};
return s_strMediaSearchPath;
}

 

DXUTFindMediaSearchParentDirs()分析

DXUTFindMediaSearchParentDirs()用于在指定搜索路徑的父目錄中查找媒體文件,主要供DXUTFindDXSDKMediaFileCch()調(diào)用。

參數(shù)分析:

strSearchPath:當(dāng)找到媒體文件時(shí),將媒體文件的全路徑名返回給這個(gè)字符串。
cchSearch:strSearchPath的長度
strStartAt:指定開始搜索的路徑
strLeafName:媒體文件名(包含擴(kuò)展名)

//--------------------------------------------------------------------------------------
// Search parent directories starting at strStartAt, and appending strLeafName
// at each parent directory. It stops at the root directory.
//--------------------------------------------------------------------------------------
bool DXUTFindMediaSearchParentDirs( WCHAR* strSearchPath, int cchSearch, WCHAR* strStartAt, WCHAR* strLeafName )
{
WCHAR strFullPath[MAX_PATH] = {0};
WCHAR strFullFileName[MAX_PATH] = {0};
WCHAR strSearch[MAX_PATH] = {0};
WCHAR* strFilePart = NULL;
    GetFullPathName( strStartAt, MAX_PATH, strFullPath, &strFilePart );
if( strFilePart == NULL )
return false;
    while( strFilePart != NULL && *strFilePart != '\0' )
{
StringCchPrintf( strFullFileName, MAX_PATH, L"%s\\%s", strFullPath, strLeafName );

if( GetFileAttributes( strFullFileName ) != 0xFFFFFFFF )
{
StringCchCopy( strSearchPath, cchSearch, strFullFileName );
return true;
}
        StringCchPrintf( strSearch, MAX_PATH, L"%s\\..", strFullPath ); 
GetFullPathName( strSearch, MAX_PATH, strFullPath, &strFilePart );
}
    return false;
}

函數(shù)首先調(diào)用

    GetFullPathName( strStartAt, MAX_PATH, strFullPath, &strFilePart );
    if( strFilePart == NULL )
        return false;

獲取開始搜索的路徑全名和文件名,注意如果strStartAt指定的是一個(gè)目錄,則strFillPart返回的是最后一個(gè)目錄的名稱,而不是文件名。

該函數(shù)聲明如下:

The GetFullPathName function retrieves the full path and file name of a specified file.
DWORD GetFullPathName(
LPCTSTR lpFileName,
DWORD nBufferLength,
LPTSTR lpBuffer,
LPTSTR* lpFilePart
);

Parameters

lpFileName
[in] A pointer to a null-terminated string that specifies a valid file name.

This string can use short (the 8.3 form) or long file names.

nBufferLength
[in] The size of the buffer to receive the null-terminated string for the drive and path, in TCHARs.
lpBuffer
[out] A pointer to a buffer that receives the null-terminated string for the drive and path.
lpFilePart
[out] A pointer to a buffer that receives the address (in lpBuffer) of the final file name component in the path.

If lpBuffer points to a directory and not a file, lpFilePart receives 0 (zero).

Return Values

If the function succeeds, the return value is the length of the string copied to lpBuffer, not including the terminating null character, in TCHARs.

If the lpBuffer buffer is too small to contain the path, the return value is the size of the buffer that is required to hold the path and the terminating null character, in TCHARs. Therefore, if the return value is greater than nBufferLength, call the function again with a buffer that is large enough to hold the path.

If the function fails for any other reason, the return value is 0 (zero). To get extended error information, call GetLastError.

Remarks

GetFullPathName merges the name of the current drive and directory with a specified file name to determine the full path and file name of the specified file. It also calculates the address of the file name portion of the full path and file name. This function does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume.

GetFullPathName does not convert the specified file name, lpFileName. If the specified file name exists, you can use GetLongPathName and GetShortPathName to convert to long and short path names, respectively.

函數(shù)接著不斷的上溯目錄層查找直到到達(dá)分區(qū)的根目錄為止,如果找到就將strSearchPath置為媒體文件所在的路徑全名,并返回true,否則返回false。

    while( strFilePart != NULL && *strFilePart != '\0' )
{
StringCchPrintf( strFullFileName, MAX_PATH, L"%s\\%s", strFullPath, strLeafName );

if( GetFileAttributes( strFullFileName ) != 0xFFFFFFFF )
{
StringCchCopy( strSearchPath, cchSearch, strFullFileName );
return true;
}
        StringCchPrintf( strSearch, MAX_PATH, L"%s\\..", strFullPath ); 
GetFullPathName( strSearch, MAX_PATH, strFullPath, &strFilePart );
}

 

DXUTFindDXSDKMediaFileCch()分析

該函數(shù)主要用于查找媒體文件。

參數(shù)分析:

strDestPath:函數(shù)調(diào)用成功后將返回媒體文件的全路徑名(若在當(dāng)前工作目錄找到該文件則僅返回媒體文件名),若調(diào)用失敗則返回媒體文件名。

cchDest:strDestPath的長度。

strFilename:要查找的媒體文件名。

//--------------------------------------------------------------------------------------
// Tries to find the location of a SDK media file.
//
// cchDest is the size in WCHARs of strDestPath.
// Be careful not to pass in sizeof(strDest) on UNICODE builds.
//--------------------------------------------------------------------------------------
HRESULT DXUTFindDXSDKMediaFileCch( WCHAR* strDestPath, int cchDest, LPCWSTR strFilename )
{
bool bFound;
WCHAR strSearchFor[MAX_PATH];
    if( NULL==strFilename || strFilename[0] == 0 || NULL==strDestPath || cchDest < 10 )
return E_INVALIDARG;
    // Get the exe name, and exe path
    WCHAR strExePath[MAX_PATH] = {0};
WCHAR strExeName[MAX_PATH] = {0};
WCHAR* strLastSlash = NULL;
    GetModuleFileName(NULL, strExePath, MAX_PATH);
strExePath[MAX_PATH-1] = 0;
    strLastSlash = wcsrchr( strExePath, TEXT('\\') );
    if( strLastSlash )
{
StringCchCopy( strExeName, MAX_PATH, &strLastSlash[1] );
        // Chop the exe name from the exe path
*strLastSlash = 0;
        // Chop the .exe from the exe name
strLastSlash = wcsrchr( strExeName, TEXT('.') );
if( strLastSlash )
*strLastSlash = 0;
}
    // Typical directories:
// .\
// ..\
// ..\..\
// %EXE_DIR%\
// %EXE_DIR%\..\
// %EXE_DIR%\..\..\
// %EXE_DIR%\..\%EXE_NAME%
// %EXE_DIR%\..\..\%EXE_NAME%
    // Typical directory search
bFound = DXUTFindMediaSearchTypicalDirs( strDestPath, cchDest, strFilename, strExePath, strExeName );
if( bFound )
return S_OK;
    // Typical directory search again, but also look in a subdir called "\media\" 
StringCchPrintf( strSearchFor, MAX_PATH, L"media\\%s", strFilename );
bFound = DXUTFindMediaSearchTypicalDirs( strDestPath, cchDest, strSearchFor, strExePath, strExeName );
if( bFound )
return S_OK;
    WCHAR strLeafName[MAX_PATH] = {0};
    // Search all parent directories starting at .\ and using strFilename as the leaf name
StringCchCopy( strLeafName, MAX_PATH, strFilename );
bFound = DXUTFindMediaSearchParentDirs( strDestPath, cchDest, L".", strLeafName );
if( bFound )
return S_OK;
    // Search all parent directories starting at the exe's dir and using strFilename as the leaf name
bFound = DXUTFindMediaSearchParentDirs( strDestPath, cchDest, strExePath, strLeafName );
if( bFound )
return S_OK;
    // Search all parent directories starting at .\ and using "media\strFilename" as the leaf name
StringCchPrintf( strLeafName, MAX_PATH, L"media\\%s", strFilename );
bFound = DXUTFindMediaSearchParentDirs( strDestPath, cchDest, L".", strLeafName );
if( bFound )
return S_OK;
    // Search all parent directories starting at the exe's dir and using "media\strFilename" as the leaf name
bFound = DXUTFindMediaSearchParentDirs( strDestPath, cchDest, strExePath, strLeafName );
if( bFound )
return S_OK;
    // On failure, return the file as the path but also return an error code
StringCchCopy( strDestPath, cchDest, strFilename );
    return DXUTERR_MEDIANOTFOUND;
}

函數(shù)首先對參數(shù)的合法性進(jìn)行檢查,接著調(diào)用GetModuleName()取得進(jìn)程的全路徑名:

    // Get the exe name, and exe path
WCHAR strExePath[MAX_PATH] = {0};
WCHAR strExeName[MAX_PATH] = {0};
WCHAR* strLastSlash = NULL;

GetModuleFileName(NULL, strExePath, MAX_PATH);
strExePath[MAX_PATH-1] = 0;

該函數(shù)聲明如下:

The GetModuleFileName function retrieves the fully-qualified path for the file that contains the specified module that the current process owns.

GetModuleFileName operates only on modules that the current process owns. To specify modules that belong to another process, use the GetModuleFileNameEx function.

DWORD GetModuleFileName(
HMODULE hModule,
LPTSTR lpFilename,
DWORD nSize
);

Parameters

hModule
[in] Handle to the module whose path is being requested. If this parameter is NULL, GetModuleFileName retrieves the path of the executable file of the current process.
lpFilename
[out] Pointer to a buffer that receives a null-terminated string that specifies the fully-qualified path of the module. If the length of the path exceeds the size that the nSize parameter specifies, the function succeeds, and the string is truncated to nSize characters and cannot be null terminated.

The string returned will use the same format that was specified when the module was loaded. Therefore, the path can be a long or short file name, and can use the prefix "\\?\". For more information, see Naming a File.

To separate the path from the file name and extension, use the PathRemoveFileSpec function. Note that this function does not support paths with the "\\?\" prefix.

nSize
[in] Size of the lpFilename buffer, in TCHARs.

Return Values

If the function succeeds, the return value is the length of the string that is copied to the buffer, in TCHARs. If the buffer is too small to hold the module name, the string is truncated to nSize, and the function returns nSize.

If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.

Remarks

If a DLL is loaded in two processes, its file name in one process may differ in case from its file name in the other process.

For the ANSI version of the function, the number of TCHARs is the number of bytes; for the Unicode version, it is the number of characters.

The global variable _pgmptr is automatically initialized to the full path of the executable file, and can be used to retrieve the full path name of an executable file.

Windows Me/98/95:  This function retrieves long file names when an application version number is greater than or equal to 4.00 and the long file name is available. Otherwise, it returns only 8.3 format file names.

接著將當(dāng)前進(jìn)程執(zhí)行文件的路徑存儲(chǔ)在strExePath,將進(jìn)程執(zhí)行文件名存儲(chǔ)在strExeName:

    strLastSlash = wcsrchr( strExePath, TEXT('\\') );
    if( strLastSlash )
{
StringCchCopy( strExeName, MAX_PATH, &strLastSlash[1] );
        // Chop the exe name from the exe path
*strLastSlash = 0;
        // Chop the .exe from the exe name
strLastSlash = wcsrchr( strExeName, TEXT('.') );
if( strLastSlash )
*strLastSlash = 0;
}

函數(shù)接著按下面的路徑查找順序查找媒體文件:

// Typical directories:
// .\
// ..\
// ..\..\
// %EXE_DIR%\
// %EXE_DIR%\..\
// %EXE_DIR%\..\..\
// %EXE_DIR%\..\%EXE_NAME%
// %EXE_DIR%\..\..\%EXE_NAME%

    // Typical directory search
bFound = DXUTFindMediaSearchTypicalDirs( strDestPath, cchDest, strFilename, strExePath, strExeName );
if( bFound )
return S_OK;

如果沒有找到,則在上面指定的路徑中增加一級(jí)目錄media查找,即:

// Typical directories:
// .\media
// ..\media
// ..\..\media
// %EXE_DIR%\media
// %EXE_DIR%\..\media
// %EXE_DIR%\..\..\media
// %EXE_DIR%\..\%EXE_NAME%\media
// %EXE_DIR%\..\..\%EXE_NAME%\media

    // Typical directory search again, but also look in a subdir called "\media\" 
StringCchPrintf( strSearchFor, MAX_PATH, L"media\\%s", strFilename );
bFound = DXUTFindMediaSearchTypicalDirs( strDestPath, cchDest, strSearchFor, strExePath, strExeName );
if( bFound )
return S_OK;

若還沒找到,則在當(dāng)前工作目錄的所有父目錄中查找:

    // Search all parent directories starting at .\ and using strFilename as the leaf name
StringCchCopy( strLeafName, MAX_PATH, strFilename );
bFound = DXUTFindMediaSearchParentDirs( strDestPath, cchDest, L".", strLeafName );
if( bFound )
return S_OK;

若還沒找到,則在可執(zhí)行文件的所有父目錄中查找:

    // Search all parent directories starting at the exe's dir and using strFilename as the leaf name
bFound = DXUTFindMediaSearchParentDirs( strDestPath, cchDest, strExePath, strLeafName );
if( bFound )
return S_OK;

若還沒找到,則在當(dāng)前工作目錄的所有父目錄中增加一層目錄media中(相當(dāng)于文件名變?yōu)閙edia\filename)查找:

    // Search all parent directories starting at .\ and using "media\strFilename" as the leaf name
StringCchPrintf( strLeafName, MAX_PATH, L"media\\%s", strFilename );
bFound = DXUTFindMediaSearchParentDirs( strDestPath, cchDest, L".", strLeafName );
if( bFound )
return S_OK;

若還沒找到,則在可執(zhí)行文件的所有父目錄中增加一層目錄media中(相當(dāng)于文件名變?yōu)閙edia\filename)查找:

    // Search all parent directories starting at the exe's dir and using "media\strFilename" as the leaf name
bFound = DXUTFindMediaSearchParentDirs( strDestPath, cchDest, strExePath, strLeafName );
if( bFound )
return S_OK;

若都沒找到,則返回文件名為參數(shù)strDestPath,并返回錯(cuò)誤值。

     // On failure, return the file as the path but also return an error code
StringCchCopy( strDestPath, cchDest, strFilename );
    return DXUTERR_MEDIANOTFOUND;

posted on 2008-05-28 16:33 lovedday 閱讀(2012) 評(píng)論(2)  編輯 收藏 引用 所屬分類: ■ DXUT Research

評(píng)論

# re: DXUT源碼分析 ---- 媒體文件查找函數(shù) 2008-05-29 09:19 安曉輝

你好,看你的博客,你正在分析DXUT。我目前也在做這方面的工作,主要是做一個(gè)GUI庫,以DXUTGUI為基礎(chǔ)。我的博客:http://blog.csdn.net/foruok

看你貼的D3D的文章,有一些與《精通DIRECTX 3D圖形與動(dòng)畫程序設(shè)計(jì)》一樣,你是該書的作者嗎?我買了本。

我剛開始接觸D3D,很多問題似是而非。

有個(gè)問題請教一下:

你知道,DXUTGUI內(nèi)嵌了一個(gè)512X512的紋理,按鈕等元素的紋理都放在了這個(gè)紋理中。我修改DXUTGUI時(shí)改變了按鈕、窗口、組合框等的繪制方式,使其可以支持紋理定制。以窗口為例,我添加了背景,把窗口背景分成9部分,當(dāng)窗口尺寸變化時(shí),我重復(fù)紋理貼圖,保證邊框不變形,中間部分用一個(gè)小紋理填充。這樣可以得到一個(gè)比較好的效果。現(xiàn)在的問題是:當(dāng)我想要用重疊紋理尋址模式時(shí),不能利用512X512紋理的部分區(qū)域,只能用一個(gè)新的小紋理。有沒有辦法可以打破這種局限?

目前我自己根據(jù)目標(biāo)矩形和用于填充的紋理的尺寸進(jìn)行計(jì)算,每次平移目標(biāo)矩形,然后重復(fù)調(diào)用ID3DXSprite的draw函數(shù),可以實(shí)現(xiàn),但是效率很低下。有沒有別的更好的方法呢?

希望可以得到你的回復(fù)。  回復(fù)  更多評(píng)論   

# re: DXUT源碼分析 ---- 媒體文件查找函數(shù) 2008-05-30 18:25 lovedday

首先我做幾點(diǎn)說明,我不是《精通DIRECTX 3D圖形與動(dòng)畫程序設(shè)計(jì)》的作者,和你一樣,我也只是D3D的初學(xué)者,那些文章可算是我的看書筆記,方便自己查閱。由于個(gè)人能力和時(shí)間所限,尚無法對DXUT的源碼進(jìn)行系統(tǒng)完整的分析,也沒研究過里面的UI設(shè)計(jì)源碼。

我不知道怎么打破你說的哪種情況,似乎用一個(gè)新的小紋理是一種比較好的解決方案。

PS:我看過你寫的"DXUTGUI控件的定制",很不錯(cuò),感謝 :)  回復(fù)  更多評(píng)論   

公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲人成网站影音先锋播放| 日韩一区二区精品| 欧美在线视频在线播放完整版免费观看 | 悠悠资源网亚洲青| 老色鬼久久亚洲一区二区| 久久精品视频99| 国产精品免费看| 亚洲国产天堂久久综合| 亚洲视频你懂的| 亚洲视屏在线播放| 久久人人精品| 亚洲黄色高清| 亚洲一区二区视频在线观看| 国产欧美精品久久| 欧美+日本+国产+在线a∨观看| 美女亚洲精品| 亚洲欧美一区二区原创| 久久久国产成人精品| 亚洲毛片在线| 欧美一区影院| 夜夜狂射影院欧美极品| 亚洲免费婷婷| 亚洲欧洲在线视频| 中文网丁香综合网| **网站欧美大片在线观看| 99国产精品久久久久久久久久| 国产日产欧产精品推荐色| 亚洲国产成人午夜在线一区| 欧美日韩在线一二三| 久久综合给合| 国产精品日韩欧美大师| 亚洲大片精品永久免费| 国产精品一区在线播放| 亚洲欧洲精品一区二区| 国产日韩av高清| 亚洲美女在线视频| 亚洲国产午夜| 欧美一级专区免费大片| 亚洲永久字幕| 亚洲国产日韩欧美| 欧美国产三级| 女同一区二区| 亚洲区一区二| 久久久久久久性| 欧美激情第9页| 99re8这里有精品热视频免费| 午夜精品久久| 欧美国产综合一区二区| 亚洲国内精品在线| 欧美午夜一区| 亚洲伦伦在线| 亚洲国产欧美一区二区三区同亚洲| 亚洲在线中文字幕| 亚洲午夜小视频| 香蕉乱码成人久久天堂爱免费| 欧美美女操人视频| 亚洲高清毛片| 亚洲精品乱码久久久久久蜜桃91| 久久久国产精品亚洲一区| 久久久噜久噜久久综合| 国产麻豆一精品一av一免费| 亚洲欧美精品| 欧美一区二区在线播放| 国产午夜精品久久久久久久| 亚洲欧美日韩国产综合精品二区| 亚洲欧美在线磁力| 国产精品亚洲第一区在线暖暖韩国| 一个色综合导航| 亚洲欧美精品suv| 国产精品美女主播在线观看纯欲| 亚洲午夜精品久久久久久浪潮| 宅男在线国产精品| 国产精品区免费视频| 亚洲综合大片69999| 久久成人精品无人区| 国产综合精品| 久久综合狠狠综合久久激情| 亚洲第一中文字幕| 99国产一区| 国产精品一区二区三区四区五区 | 欧美一区二区日韩| 一级日韩一区在线观看| 在线综合+亚洲+欧美中文字幕| 欧美日韩精品一区二区天天拍小说| 日韩亚洲视频| 欧美一区二区视频在线观看2020| 国产一区二区三区久久精品| 久久久久久69| 亚洲乱亚洲高清| 欧美在线日韩| 亚洲高清久久久| 欧美日韩午夜激情| 性欧美xxxx大乳国产app| 欧美**人妖| 亚洲午夜精品| 影音先锋欧美精品| 欧美视频在线看| 久久精品官网| 一区二区高清视频在线观看| 久久国产乱子精品免费女| 在线观看亚洲专区| 欧美色网一区二区| 久久久精品国产一区二区三区| 亚洲激情校园春色| 久久久免费精品| 亚洲视屏一区| 亚洲国产精品传媒在线观看| 欧美视频在线不卡| 久久在线免费观看视频| 亚洲国产精品精华液网站| 久久美女性网| 久久久综合视频| 一区二区日韩免费看| 黄色成人片子| 国产精品美女黄网| 欧美精品久久一区二区| 亚洲一区二区三区久久| 在线免费高清一区二区三区| 国产精品久久久久久久久久免费看| 理论片一区二区在线| 欧美一区二区三区日韩| 99精品国产在热久久下载| 欧美激情a∨在线视频播放| 久久精品视频免费播放| 亚洲夜间福利| 99这里只有精品| 亚洲精品小视频| 在线看片欧美| 在线观看国产成人av片| 国产亚洲一区精品| 国产精品美女午夜av| 欧美日韩色一区| 欧美激情在线观看| 欧美成人精品h版在线观看| 久久久久久尹人网香蕉| 久久国产精品久久久久久久久久| 亚洲综合精品自拍| 国产精品99久久久久久白浆小说| 女生裸体视频一区二区三区| 国产精品v欧美精品v日韩精品| 亚洲先锋成人| 日韩天堂在线观看| 999亚洲国产精| 99精品免费视频| 一本色道久久综合亚洲91| 99国产精品99久久久久久| 亚洲区国产区| 亚洲精品久久视频| 99综合精品| 亚洲一区二区在线观看视频| 亚洲主播在线观看| 午夜在线a亚洲v天堂网2018| 亚洲欧美区自拍先锋| 篠田优中文在线播放第一区| 欧美一区二区三区免费大片| 久久成人免费网| 蜜臀91精品一区二区三区| 欧美精品九九| 国产精品久久久久毛片大屁完整版| 国产精品高潮在线| 国产一区二区高清不卡| 怡红院av一区二区三区| 亚洲精品美女91| 亚洲午夜一区二区三区| 久久国产免费看| 亚洲大胆视频| 在线中文字幕日韩| 久久久久久久999| 欧美人与性动交cc0o| 国产精品视频免费| 尤物九九久久国产精品的特点| 亚洲日本电影| 性色av一区二区三区| 免费不卡亚洲欧美| 99精品福利视频| 久久久www成人免费精品| 欧美精品尤物在线| 国产欧美日韩高清| 日韩午夜免费视频| 久久久久久久一区二区| 亚洲欧洲一区二区三区| 午夜国产精品视频免费体验区| 久久久久久午夜| 国产精品久久一区二区三区| 亚洲高清一区二| 亚洲免费在线看| 亚洲高清视频在线观看| 亚洲综合欧美日韩| 欧美精品在线一区二区三区| 国内成+人亚洲+欧美+综合在线| 一本色道久久综合亚洲二区三区| 欧美在线在线| 亚洲精品一区在线观看香蕉| 久久久久久久久蜜桃| 国产精品久久久久毛片大屁完整版 | 亚洲大片一区二区三区| 性色av一区二区怡红| 欧美视频免费看| 亚洲美女视频网| 欧美大片免费观看|