本文整理汇总了C++中LPDIRECT3DTEXTURE9::GenerateMipSubLevels方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DTEXTURE9::GenerateMipSubLevels方法的具体用法?C++ LPDIRECT3DTEXTURE9::GenerateMipSubLevels怎么用?C++ LPDIRECT3DTEXTURE9::GenerateMipSubLevels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DTEXTURE9
的用法示例。
在下文中一共展示了LPDIRECT3DTEXTURE9::GenerateMipSubLevels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: szFilePath
/// \brief Loads a texture
/// \param file = the filename
bool CDX9TextureObject::LoadFromFile( const TCHAR * file )
{
StdString szFilePath(file);
szFilePath.MakeSafeFileName();
DeInit();
if (!m_Renderer)
return false;
LPDIRECT3DDEVICE9 pDevice = (LPDIRECT3DDEVICE9)m_Renderer->GetAPIDevice();
if( !pDevice )
return false;
D3DXIMAGE_INFO srcInfo;
LPDIRECT3DTEXTURE9 pTexture;
/*
if( _tcsstr( file, _T(".hdr" ) )!= NULL )
{
bool retval = LoadHDRFile( (TCHAR*)file );
return retval;
}
*/
LPVOID pFileData = NULL;
UINT iFileDataSize = 0;
if (!LoadFileIntoBuffer( szFilePath, pFileData, iFileDataSize, true ))
{
m_ToolBox->Log(LOGERROR, _T("Texture Object: %s failed to load\n"), szFilePath.c_str() );
return false;
}
D3DFORMAT requestedFormat = EEDX9RequestedInternalFormatFromFileInMemory( pFileData, iFileDataSize );
HRESULT hr = D3DXCreateTextureFromFileInMemoryEx( pDevice,
pFileData,
iFileDataSize,
D3DX_DEFAULT, //width
D3DX_DEFAULT, //height
D3DX_DEFAULT, //number of mips
0, //usage - 0 unless for render targets
requestedFormat,
D3DPOOL_MANAGED,
D3DX_DEFAULT, //regular filter
D3DX_DEFAULT, //mip filter
0, //color key, opaque black default
&srcInfo, //src info
NULL, //palette
&pTexture );
SAFE_DELETE_ARRAY( pFileData );
if( hr != D3D_OK )
{
m_ToolBox->Log(LOGERROR, _T("Texture Object: %s failed to load\n"), szFilePath.c_str() );
return false;
}
D3DSURFACE_DESC textureDesc;
pTexture->GetLevelDesc( 0, &textureDesc );
m_Width = textureDesc.Width;
m_Height = textureDesc.Height;
m_Texture = pTexture;
m_Filename = file;
m_bRenderTarget = false;
m_ColorDepth = EEDX9ColorBitsFromFormat( textureDesc.Format );
m_Compressed = EEDX9IsCompressedFormat( textureDesc.Format );
if( m_AutoGenMips )
{
pTexture->GenerateMipSubLevels();
}
return true;
}