diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-03-17 17:09:06 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-03-17 17:09:06 (GMT) |
| commit | 9913e499fd40635afdf26a089bd3fb1e6e654d81 (patch) | |
| tree | cb8b884dd946f4684f2a91e129787df849fb083c /src | |
| parent | 887a43c097883d1212510e06b75b1b92ba138312 (diff) | |
| download | powder-9913e499fd40635afdf26a089bd3fb1e6e654d81.zip powder-9913e499fd40635afdf26a089bd3fb1e6e654d81.tar.gz | |
Add icon again for Windows and Linux
Diffstat (limited to 'src')
| -rw-r--r-- | src/graphics.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/graphics.c b/src/graphics.c index bacc234..6e0651a 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1,6 +1,9 @@ #include <math.h> #include <SDL/SDL.h> #include <bzlib.h> +#ifdef WIN32 +#include <SDL/SDL_syswm.h> +#endif #if defined(OGLR) #ifdef MACOSX @@ -29,6 +32,11 @@ #include <misc.h> #include "hmap.h" + +#ifdef WIN32 +IMAGE_DOS_HEADER __ImageBase; +#endif + //unsigned cmode = CM_FIRE; unsigned int *render_modes; unsigned int render_mode; @@ -3745,12 +3753,37 @@ void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry) int sdl_opened = 0; int sdl_open(void) { +#ifdef WIN32 + SDL_SysWMinfo SysInfo; + HWND WindowHandle; + HICON hIconSmall; + HICON hIconBig; + SDL_Surface *icon; +#endif int status; if (SDL_Init(SDL_INIT_VIDEO)<0) { fprintf(stderr, "Initializing SDL: %s\n", SDL_GetError()); return 0; } + +#ifdef WIN32 + SDL_VERSION(&SysInfo.version); + if(SDL_GetWMInfo(&SysInfo) <= 0) { + printf("%s : %d\n", SDL_GetError(), SysInfo.window); + exit(-1); + } + WindowHandle = SysInfo.window; + hIconSmall = (HICON)LoadImage(&__ImageBase, MAKEINTRESOURCE(101), IMAGE_ICON, 16, 16, LR_SHARED); + hIconBig = (HICON)LoadImage(&__ImageBase, MAKEINTRESOURCE(101), IMAGE_ICON, 32, 32, LR_SHARED); + SendMessage(WindowHandle, WM_SETICON, ICON_SMALL, (LPARAM)hIconSmall); + SendMessage(WindowHandle, WM_SETICON, ICON_BIG, (LPARAM)hIconBig); +#elif defined(LIN32) || defined(LIN32) + icon = SDL_CreateRGBSurfaceFrom(app_icon, 16, 16, 32, 64, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + SDL_WM_SetIcon(icon, NULL); +#endif + SDL_WM_SetCaption("The Powder Toy", "Powder Toy"); + atexit(SDL_Quit); #if defined(OGLR) sdl_scrn=SDL_SetVideoMode(XRES*sdl_scale + BARSIZE*sdl_scale,YRES*sdl_scale + MENUSIZE*sdl_scale,32,SDL_OPENGL); @@ -3949,8 +3982,6 @@ int sdl_open(void) fprintf(stderr, "Creating window: %s\n", SDL_GetError()); return 0; } - SDL_WM_SetCaption("The Powder Toy", "Powder Toy"); - sdl_seticon(); SDL_EnableUNICODE(1); //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); #if (defined(LIN32) || defined(LIN64)) && defined(SDL_VIDEO_DRIVER_X11) |
