diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index cd800b8ffe..4336f0607a 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -28,8 +28,6 @@ #include "SDL_video.h" // for SDL_Surface #include "SDL_utils.h" #include "Dxerr8.h" -#include "SDL_image.h" // for setting icon -#include "SDL_rotozoom.h" // for setting icon #include "arch/arch.h" @@ -358,21 +356,7 @@ bool RageDisplay::SetVideoMode( bool windowed, int width, int height, int bpp, i { /* Set SDL window title and icon -before- creating the window */ SDL_WM_SetCaption(sWindowTitle, ""); - - SDL_Surface *srf = IMG_Load(sIconFile); - SDL_SetColorKey( srf, SDL_SRCCOLORKEY, SDL_MapRGB(srf->format, 0xFF, 0, 0xFF)); - - /* Windows icons are 32x32 and SDL can't resize them for us, which - * causes mask corruption. (Actually, the above icon *is* 32x32; - * this is here just in case it changes.) */ - ConvertSDLSurface(srf, srf->w, srf->h, - 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); - zoomSurface(srf, 32, 32); - - SDL_SetAlpha( srf, SDL_SRCALPHA, SDL_ALPHA_OPAQUE ); - SDL_WM_SetIcon(srf, NULL /* derive from alpha */); - SDL_FreeSurface(srf); - + mySDL_WM_SetIcon( sIconFile ); // HACK: On Windows 98, we can't call SDL_SetVideoMode while D3D is full screen. diff --git a/stepmania/src/SDL_utils.cpp b/stepmania/src/SDL_utils.cpp index f972f285cd..d1c5dc60ac 100644 --- a/stepmania/src/SDL_utils.cpp +++ b/stepmania/src/SDL_utils.cpp @@ -510,3 +510,22 @@ bool SDL_GetEvent(SDL_Event &event, int mask) } +#include "SDL_image.h" // for setting icon +#include "SDL_rotozoom.h" // for setting icon + +void mySDL_WM_SetIcon( CString sIconFile ) +{ + SDL_Surface *srf = IMG_Load(sIconFile); + SDL_SetColorKey( srf, SDL_SRCCOLORKEY, SDL_MapRGB(srf->format, 0xFF, 0, 0xFF)); + + /* Windows icons are 32x32 and SDL can't resize them for us, which + * causes mask corruption. (Actually, the above icon *is* 32x32; + * this is here just in case it changes.) */ + ConvertSDLSurface(srf, srf->w, srf->h, + 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); + zoomSurface(srf, 32, 32); + + SDL_SetAlpha( srf, SDL_SRCALPHA, SDL_ALPHA_OPAQUE ); + SDL_WM_SetIcon(srf, NULL /* derive from alpha */); + SDL_FreeSurface(srf); +} diff --git a/stepmania/src/SDL_utils.h b/stepmania/src/SDL_utils.h index 3934778561..e3396b18de 100644 --- a/stepmania/src/SDL_utils.h +++ b/stepmania/src/SDL_utils.h @@ -46,5 +46,9 @@ bool SDL_GetEvent(SDL_Event &event, int mask); #define TRAIT_WHITE_ONLY 0x0004 /* 8alphaonly */ int FindSurfaceTraits(const SDL_Surface *img); + +void mySDL_WM_SetIcon( CString sIconFile ); + + #endif diff --git a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.cpp b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.cpp index 9caf38264e..601383878e 100644 --- a/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.cpp +++ b/stepmania/src/arch/LowLevelWindow/LowLevelWindow_SDL.cpp @@ -1,7 +1,6 @@ #include "global.h" #include "LowLevelWindow_SDL.h" -#include "SDL_image.h" // for setting icon -#include "SDL_rotozoom.h" // for setting icon +#include "SDL_utils.h" #include "RageLog.h" #include "RageDisplay.h" // for REFRESH_DEFAULT @@ -41,24 +40,9 @@ bool LowLevelWindow_SDL::SetVideoMode( bool windowed, int width, int height, int SDL_InitSubSystem(SDL_INIT_VIDEO); - /* Set SDL window title and icon -before- creating the window */ SDL_WM_SetCaption(sWindowTitle, ""); - - SDL_Surface *srf = IMG_Load(sIconFile); - SDL_SetColorKey( srf, SDL_SRCCOLORKEY, SDL_MapRGB(srf->format, 0xFF, 0, 0xFF)); - - /* Windows icons are 32x32 and SDL can't resize them for us, which - * causes mask corruption. (Actually, the above icon *is* 32x32; - * this is here just in case it changes.) */ - ConvertSDLSurface(srf, srf->w, srf->h, - 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); - zoomSurface(srf, 32, 32); - - SDL_SetAlpha( srf, SDL_SRCALPHA, SDL_ALPHA_OPAQUE ); - SDL_WM_SetIcon(srf, NULL /* derive from alpha */); - SDL_FreeSurface(srf); - + mySDL_WM_SetIcon( sIconFile ); Windowed = false;