| 260 | #ifdef OS_WIN |
| 261 | const VfsPath iconPath("art/textures/icons/0ad_64.png"); // or load from config |
| 262 | #else |
| 263 | // TODO: set path |
| 264 | #endif |
| 265 | |
| 266 | // Setup the titlebar icon |
| 267 | std::shared_ptr<u8> iconFile; |
| 268 | size_t iconFileSize; |
| 269 | if (g_VFS->LoadFile(iconPath, iconFile, iconFileSize) != INFO::OK) |
| 270 | return false; |
| 271 | Tex iconTexture; |
| 272 | if (iconTexture.decode(iconFile, iconFileSize) != INFO::OK) |
| 273 | return false; |
| 274 | |
| 275 | // Convert to required BGRA format. |
| 276 | const size_t iconFlags = (iconTexture.m_Flags | TEX_BGR) & ~TEX_DXT; |
| 277 | if (iconTexture.transform_to(iconFlags) != INFO::OK) |
| 278 | return false; |
| 279 | |
| 280 | void* bgra_img = iconTexture.get_data(); |
| 281 | if (!bgra_img) |
| 282 | return false; |
| 283 | |
| 284 | SDL_Surface *iconSurface = SDL_CreateRGBSurfaceFrom(bgra_img, iconTexture.m_Width, iconTexture.m_Height, 32, iconTexture.m_Width * 4, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); |
| 285 | if (!iconSurface) |
| 286 | return false; |
| 287 | SDL_SetWindowIcon(m_Window, iconSurface); |
| 288 | SDL_FreeSurface(iconSurface); |
| 289 | |