void DirectX9::LoadTexture( Gwen::Texture* pTexture ) { IDirect3DTexture9* ptr = NULL; D3DXIMAGE_INFO ImageInfo; HRESULT hr = D3DXCreateTextureFromFileExW( m_pDevice, pTexture->name.GetUnicode().c_str(), 0, 0, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, &ImageInfo, NULL, &ptr ); if ( hr != S_OK ) { return; } pTexture->data = ptr; pTexture->width = ImageInfo.Width; pTexture->height = ImageInfo.Height; }
bool KINRenderManager::LoadTextureInFile(Texture& pTexture, const std::wstring& pPath) { D3DXIMAGE_INFO info; D3DXGetImageInfoFromFileW(pPath.c_str(), &info); if(FAILED(D3DXCreateTextureFromFileExW(mpD3D_Device, pPath.c_str(), info.Width, info.Height, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &pTexture.mpTexture))) { return false; } pTexture.mSize.mWidth = info.Width; pTexture.mSize.mHeight = info.Height; return true; }
bool CTexture::CreateTexture(const wchar_t *textureName) { //if (FAILED(D3DXCreateTextureFromFile(direct3DDevice, textureName, &m_texture))) if (FAILED(D3DXCreateTextureFromFileExW(direct3DDevice, textureName, 0, 0, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_FILTER_NONE, 0, nullptr, nullptr, &m_texture))) { MessageBox(nullptr, L"D3DXCreateTextureFromFile fail", L"Error", MB_OK | MB_ICONERROR); return false; } m_texture->GetLevelDesc(0, &m_desc); // D3DFMT_A8R8G8B8 // D3DX_FILTER_NONE // D3DX_DEFAULT return true; }
D3DTextureObject9::D3DTextureObject9(IDirect3DDevice9 *pDevice, const TextureDescription &textureDesc) { HRESULT result = S_FALSE; switch(textureDesc.type) { case TEXTURE_FROM_FILE: result = D3DXCreateTextureFromFileExW(pDevice, textureDesc.filePath.c_str(), textureDesc.width, textureDesc.height, textureDesc.mipLevels, textureDesc.usage, textureDesc.format, textureDesc.pool, textureDesc.filter, textureDesc.mipFilter, textureDesc.colorKey, nullptr, nullptr, &m_d3dTexture9); break; case TEXTURE_FROM_RESOURCE: result = D3DXCreateTextureFromResourceExW(pDevice, textureDesc.resourceModule, MAKEINTRESOURCE(textureDesc.resourceId), textureDesc.width, textureDesc.height, textureDesc.mipLevels, textureDesc.usage, textureDesc.format, textureDesc.pool, textureDesc.filter, textureDesc.mipFilter, textureDesc.colorKey, nullptr, nullptr, &m_d3dTexture9); break; } Utils::ThrowIfFailed(result); }