HRESULT Texture::loadFromFile(LPD3DXSPRITE spriteHandle, LPWSTR filePath, D3DXCOLOR color) { HRESULT result; result = D3DXGetImageInfoFromFile(filePath, &this->_imageInfo); if (result != D3D_OK) { return result; } LPDIRECT3DDEVICE9 _device = DeviceManager::getInstance()->getDevice(); spriteHandle->GetDevice(&_device); result = D3DXCreateTextureFromFileEx( _device, filePath, this->_imageInfo.Width, this->_imageInfo.Height, 1, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, color, &this->_imageInfo, nullptr, &this->_texture); _color = color; return result; }
Sprite::Sprite(LPD3DXSPRITE SpriteHandler, char* Path, int Width, int Height, int Count, int SpritePerRow) { D3DXIMAGE_INFO info; HRESULT result; this->_Image = NULL; this->_SpriteHandler = SpriteHandler; this->_Width = Width; this->_Height = Height; this->_Count = Count; this->_SpritePerRow = SpritePerRow; this->_Index = 0; this->_CurrentSpriteLocation.x = 0.0f; this->_CurrentSpriteLocation.y = 0.0f; this->_CurrentSpriteLocation.z = 0.0f; result = D3DXGetImageInfoFromFile(Path, &info); if (result != D3D_OK) { int i = 10; } LPDIRECT3DDEVICE9 d3ddv; SpriteHandler->GetDevice(&d3ddv); result = D3DXCreateTextureFromFileEx( d3ddv, Path, info.Width, info.Height, 1, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_XRGB(88, 1, 0), &info, NULL, &_Image); if (result != D3D_OK) { int i = 10; } }
CSprite::CSprite(LPD3DXSPRITE SpriteHandler, LPWSTR FilePath, int Width, int Height, int Count, int SpritePerRow) { D3DXIMAGE_INFO info; HRESULT result; _Image = NULL; _SpriteHandler = SpriteHandler; _Width = Width; _Height = Height; _Count = Count; _SpritePerRow = SpritePerRow; _Index = 0; result = D3DXGetImageInfoFromFile(FilePath, &info); if (result != D3D_OK) { //trace(L"[ERROR] Failed to get information from image file '%s'", FilePath); return; } LPDIRECT3DDEVICE9 d3ddv; SpriteHandler->GetDevice(&d3ddv); result = D3DXCreateTextureFromFileEx( d3ddv, FilePath, info.Width, info.Height, 1, D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_XRGB(255, 0, 255), // 176, 224, 248 &info, NULL, &_Image); if (result != D3D_OK) { //trace(L"[ERROR] Failed to create texture from file '%s'", FilePath); return; } }
Sprite::Sprite(LPD3DXSPRITE SpriteHandler, LPWSTR Path, double Width, double Height, int Count, int SpritePerRow, D3DCOLOR TransparentColor) { D3DXIMAGE_INFO info; HRESULT result; _Image = NULL; _SpriteHandler = SpriteHandler; _Width = Width; _Height = Height; _Count = Count; _SpritePerRow = SpritePerRow; result = D3DXGetImageInfoFromFile(Path, &info); if (result != D3D_OK) { return; } LPDIRECT3DDEVICE9 d3ddv; SpriteHandler->GetDevice(&d3ddv); result = D3DXCreateTextureFromFileEx( d3ddv, Path, info.Width, info.Height, 1, //Mipmap levels D3DUSAGE_DYNAMIC, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, TransparentColor, // Transparent color &info, // Image information NULL, &_Image); // Result if (result != D3D_OK) { return; } }