From 9ab83da60acb7b357a7f7da1cb2a55679605083d Mon Sep 17 00:00:00 2001 From: "Way, No" Date: Thu, 24 Apr 2014 11:43:13 +1100 Subject: [PATCH] added icon to screenhelper --- Sources/Gui/StartupScreenHelper.cpp | 19 +++++++++++++++++++ Sources/Gui/StartupScreenHelper.h | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Sources/Gui/StartupScreenHelper.cpp b/Sources/Gui/StartupScreenHelper.cpp index cc663b79..365291b9 100644 --- a/Sources/Gui/StartupScreenHelper.cpp +++ b/Sources/Gui/StartupScreenHelper.cpp @@ -162,6 +162,25 @@ namespace spades { if(window != nullptr && context == nullptr) { SPLog("Failed to create OpenGL context: %s", SDL_GetError()); } + +#ifdef __APPLE__ +#elif __unix + SDL_Surface *icon = nullptr; + SDL_RWops *icon_rw = nullptr; + icon_rw = SDL_RWFromConstMem(LDVAR(openspades_png), LDLEN(openspades_png)); + if (icon_rw != nullptr) { + icon = IMG_LoadPNG_RW(icon_rw); + SDL_FreeRW(icon_rw); + } + if(icon == nullptr) { + std::string msg = SDL_GetError(); + SPLog("Failed to load icon: %s", msg.c_str()); + } else { + SDL_SetWindowIcon(window, icon); + SDL_FreeSurface(icon); + } +#endif + if(!context){ // OpenGL initialization failed! diff --git a/Sources/Gui/StartupScreenHelper.h b/Sources/Gui/StartupScreenHelper.h index 56e1dc9f..87eea746 100644 --- a/Sources/Gui/StartupScreenHelper.h +++ b/Sources/Gui/StartupScreenHelper.h @@ -28,6 +28,7 @@ #include #include #include +#include "Icon.inc" namespace spades { class Serveritem; @@ -76,4 +77,4 @@ namespace spades { void Start(); }; } -} \ No newline at end of file +}