Hooks the splash window code up to the same image loading code as the icon code, and also adds a check if it tries to load a BMP for either(this is a bad format and really shouldn't be used for pretty much anything).

Also includes a icon for the templates.
This commit is contained in:
Areloch 2017-01-16 00:09:55 -06:00
parent 713c93d328
commit f02d0d6c4e
4 changed files with 92 additions and 39 deletions

View file

@ -22,7 +22,7 @@
#include "platform/platform.h" #include "platform/platform.h"
#include "console/console.h" #include "console/console.h"
#include "gfx/bitmap/gBitmap.h"
#include "SDL.h" #include "SDL.h"
#include "windowManager/sdl/sdlWindow.h" #include "windowManager/sdl/sdlWindow.h"
@ -36,7 +36,52 @@ bool Platform::displaySplashWindow( String path )
if(path.isEmpty()) if(path.isEmpty())
return false; return false;
gSplashImage = SDL_LoadBMP(path); Torque::Path iconPath = Torque::Path(path);
if (iconPath.getExtension() == String("bmp"))
{
Con::errorf("Unable to use bmp format images for the splash screen. Please use a different format.");
return false;
}
Resource<GBitmap> img = GBitmap::load(iconPath);
if (img != NULL)
{
U32 pitch;
U32 width = img->getWidth();
bool hasAlpha = img->getHasTransparency();
U32 depth;
if (hasAlpha)
{
pitch = 4 * width;
depth = 32;
}
else
{
pitch = 3 * width;
depth = 24;
}
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;
}
gSplashImage = SDL_CreateRGBSurfaceFrom(img->getAddress(0, 0), img->getWidth(), img->getHeight(), depth, pitch, rmask, gmask, bmask, amask);
}
//now the pop-up window //now the pop-up window
if (gSplashImage) if (gSplashImage)

View file

@ -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) if (iconPath.getExtension() == String("bmp"))
{ {
U32 pitch; Con::errorf("Unable to use bmp format images for the window icon. Please use a different format.");
U32 width = bmp->getWidth(); }
bool hasAlpha = bmp->getHasTransparency(); else
U32 depth; {
Resource<GBitmap> img = GBitmap::load(iconPath);
if (hasAlpha) if (img != NULL)
{ {
pitch = 4 * width; U32 pitch;
depth = 32; U32 width = img->getWidth();
} bool hasAlpha = img->getHasTransparency();
else U32 depth;
{
pitch = 3 * width;
depth = 24;
}
Uint32 rmask, gmask, bmask, amask; if (hasAlpha)
if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
{ pitch = 4 * width;
S32 shift = hasAlpha ? 8 : 0; depth = 32;
rmask = 0xff000000 >> shift; }
gmask = 0x00ff0000 >> shift; else
bmask = 0x0000ff00 >> shift; {
amask = 0x000000ff >> shift; pitch = 3 * width;
depth = 24;
}
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_FreeSurface(iconSurface);
} }
else
{
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = hasAlpha ? 0xff000000 : 0;
}
SDL_Surface* iconSurface = SDL_CreateRGBSurfaceFrom(bmp->getAddress(0, 0), bmp->getWidth(), bmp->getHeight(), depth, pitch, rmask, gmask, bmask, amask);
SDL_SetWindowIcon(window->mWindowHandle, iconSurface);
SDL_FreeSurface(iconSurface);
} }
if(device) if(device)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB