コード例 #1
0
ファイル: CTexture.cpp プロジェクト: urluf/BorneInfo
OpenUtility::CTexture* OpenUtility::CTexture::LoadTextureFile(const char *file,unsigned long w,unsigned long h,bool nonPowerOf2)
{
	CTextureLoader *texLoader;

	if ((texLoader=GetLoader(file))!=NULL)
	{
		unsigned char *data;
		EPicMode channel;

		if ((data=texLoader->Load(file,w,h,channel))!=NULL)
		{
			CTexture *texObj=LoadTextureMemory(data,w,h,channel,nonPowerOf2);
			texLoader->DestroyData(data);
			return(texObj);
		}
	}
	return(NULL);
}
コード例 #2
0
HRESULT TextureEntityDirectX::CreateTextureFromFile_Serial(IDirect3DDevice9* pDev, const char* sFileName, IDirect3DTexture9** ppTexture, D3DFORMAT dwTextureFormat, UINT nMipLevels, Color dwColorKey )
{
	// Load Texture sequentially
	asset_ptr<TextureEntity> my_asset(this);
	CTextureLoader loader_( my_asset, sFileName );
	CTextureLoader* pLoader = &loader_;
	CTextureProcessor processor_( my_asset );
	CTextureProcessor* pProcessor = &processor_;

	pLoader->m_dwTextureFormat = dwTextureFormat;
	pLoader->m_nMipLevels = nMipLevels;
	pLoader->m_ppTexture = (void**)ppTexture;
	pLoader->m_dwColorKey = dwColorKey;

	pProcessor->m_dwTextureFormat = dwTextureFormat;
	pProcessor->m_nMipLevels = nMipLevels;
	pProcessor->m_pDevice = pDev;
	pProcessor->m_ppTexture = (void**)ppTexture;
	pProcessor->m_dwColorKey = dwColorKey;

	void* pLocalData;
	int Bytes;
	if( SUCCEEDED(pLoader->Load()) && 
		SUCCEEDED(pLoader->Decompress( &pLocalData, &Bytes )) && 
		SUCCEEDED(pProcessor->Process( pLocalData, Bytes )) && 
		SUCCEEDED(pProcessor->LockDeviceObject()) && 
		SUCCEEDED(pProcessor->CopyToResource()) && 
		SUCCEEDED(pProcessor->UnLockDeviceObject()) )
	{
	}
	else
	{
		pProcessor->SetResourceError();
	}
	pProcessor->Destroy();
	pLoader->Destroy();
	return S_OK;
}