summaryrefslogtreecommitdiff
path: root/video
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-08-13 08:18:11 +0000
committerDarkvater <darkvater@openttd.org>2006-08-13 08:18:11 +0000
commitb1b0b26fc8a1fc499b1cbe4d3c51f71079bd34fe (patch)
tree32937c8ff5c499288446de72e7b581207fd3bf34 /video
parent00aaf8b8f19a59c9c4b80f9f7e6f98ea489448f6 (diff)
downloadopenttd-b1b0b26fc8a1fc499b1cbe4d3c51f71079bd34fe.tar.xz
(svn r5872) - Feature: Add an icon to the SDL openttd executable.
Diffstat (limited to 'video')
-rw-r--r--video/sdl_v.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/video/sdl_v.c b/video/sdl_v.c
index 373009bc8..275db9dba 100644
--- a/video/sdl_v.c
+++ b/video/sdl_v.c
@@ -161,15 +161,36 @@ static int GetAvailableVideoMode(int *w, int *h)
extern const char _openttd_revision[];
+#ifndef ICON_DIR
+#define ICON_DIR "media"
+#endif
+
+#ifdef WIN32
+/* Let's redefine the LoadBMP macro with because we are dynamically
+ * loading SDL and need to 'SDL_CALL' all functions */
+#undef SDL_LoadBMP
+#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_CALL SDL_RWFromFile(file, "rb"), 1)
+#endif
+
static bool CreateMainSurface(int w, int h)
{
- SDL_Surface *newscreen;
+ SDL_Surface *newscreen, *icon;
char caption[50];
GetAvailableVideoMode(&w, &h);
DEBUG(driver, 1) ("sdl: using mode %dx%d", w, h);
+ /* Give the application an icon */
+ icon = SDL_CALL SDL_LoadBMP(ICON_DIR PATHSEP "openttd.32.bmp");
+ if (icon != NULL) {
+ /* Get the colourkey, which will be magenta */
+ uint32 rgbmap = SDL_CALL SDL_MapRGB(icon->format, 255, 0, 255);
+ SDL_CALL SDL_SetColorKey(icon, SDL_SRCCOLORKEY, rgbmap);
+ SDL_CALL SDL_WM_SetIcon(icon, NULL);
+ SDL_CALL SDL_FreeSurface(icon);
+ }
+
// DO NOT CHANGE TO HWSURFACE, IT DOES NOT WORK
newscreen = SDL_CALL SDL_SetVideoMode(w, h, 8, SDL_SWSURFACE | SDL_HWPALETTE | (_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE));
if (newscreen == NULL)