|
@@ -168,47 +168,55 @@ PlatformWindow *PlatformWindowManagerSDL::createWindow(GFXDevice *device, const
|
|
|
|
|
|
//Now, fetch our window icon, if any
|
|
//Now, fetch our window icon, if any
|
|
Torque::Path iconPath = Torque::Path(Con::getVariable( "$Core::windowIcon" ));
|
|
Torque::Path iconPath = Torque::Path(Con::getVariable( "$Core::windowIcon" ));
|
|
- Resource<GBitmap> bmp = GBitmap::load(iconPath);
|
|
|
|
- if (bmp != NULL)
|
|
|
|
- {
|
|
|
|
- U32 pitch;
|
|
|
|
- U32 width = bmp->getWidth();
|
|
|
|
- bool hasAlpha = bmp->getHasTransparency();
|
|
|
|
- U32 depth;
|
|
|
|
|
|
|
|
- if (hasAlpha)
|
|
|
|
- {
|
|
|
|
- pitch = 4 * width;
|
|
|
|
- depth = 32;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ if (iconPath.getExtension() == String("bmp"))
|
|
|
|
+ {
|
|
|
|
+ Con::errorf("Unable to use bmp format images for the window icon. Please use a different format.");
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ Resource<GBitmap> img = GBitmap::load(iconPath);
|
|
|
|
+ if (img != NULL)
|
|
{
|
|
{
|
|
- pitch = 3 * width;
|
|
|
|
- depth = 24;
|
|
|
|
- }
|
|
|
|
|
|
+ U32 pitch;
|
|
|
|
+ U32 width = img->getWidth();
|
|
|
|
+ bool hasAlpha = img->getHasTransparency();
|
|
|
|
+ U32 depth;
|
|
|
|
|
|
- Uint32 rmask, gmask, bmask, amask;
|
|
|
|
- if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
|
|
|
- {
|
|
|
|
- S32 shift = hasAlpha ? 8 : 0;
|
|
|
|
- rmask = 0xff000000 >> shift;
|
|
|
|
- gmask = 0x00ff0000 >> shift;
|
|
|
|
- bmask = 0x0000ff00 >> shift;
|
|
|
|
- amask = 0x000000ff >> shift;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- rmask = 0x000000ff;
|
|
|
|
- gmask = 0x0000ff00;
|
|
|
|
- bmask = 0x00ff0000;
|
|
|
|
- amask = hasAlpha ? 0xff000000 : 0;
|
|
|
|
- }
|
|
|
|
|
|
+ if (hasAlpha)
|
|
|
|
+ {
|
|
|
|
+ pitch = 4 * width;
|
|
|
|
+ depth = 32;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ pitch = 3 * width;
|
|
|
|
+ depth = 24;
|
|
|
|
+ }
|
|
|
|
|
|
- SDL_Surface* iconSurface = SDL_CreateRGBSurfaceFrom(bmp->getAddress(0, 0), bmp->getWidth(), bmp->getHeight(), depth, pitch, rmask, gmask, bmask, amask);
|
|
|
|
|
|
+ Uint32 rmask, gmask, bmask, amask;
|
|
|
|
+ if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
|
|
|
+ {
|
|
|
|
+ S32 shift = hasAlpha ? 8 : 0;
|
|
|
|
+ rmask = 0xff000000 >> shift;
|
|
|
|
+ gmask = 0x00ff0000 >> shift;
|
|
|
|
+ bmask = 0x0000ff00 >> shift;
|
|
|
|
+ amask = 0x000000ff >> shift;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ rmask = 0x000000ff;
|
|
|
|
+ gmask = 0x0000ff00;
|
|
|
|
+ bmask = 0x00ff0000;
|
|
|
|
+ amask = hasAlpha ? 0xff000000 : 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SDL_Surface* iconSurface = SDL_CreateRGBSurfaceFrom(img->getAddress(0, 0), img->getWidth(), img->getHeight(), depth, pitch, rmask, gmask, bmask, amask);
|
|
|
|
|
|
- SDL_SetWindowIcon(window->mWindowHandle, iconSurface);
|
|
|
|
|
|
+ SDL_SetWindowIcon(window->mWindowHandle, iconSurface);
|
|
|
|
|
|
- SDL_FreeSurface(iconSurface);
|
|
|
|
|
|
+ SDL_FreeSurface(iconSurface);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if(device)
|
|
if(device)
|