Skip to content


Windows: Set window icon (#5486)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrido authored and nerzhul committed Mar 30, 2017
1 parent ea549bb commit cc1ff26
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/client/clientlauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)

porting::setXorgClassHint(video_driver->getExposedVideoData(), PROJECT_NAME_C);


This changes the minimum allowed number of vertices in a VBO.
Expand Down
34 changes: 32 additions & 2 deletions src/porting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,9 @@ void setXorgClassHint(const video::SExposedVideoData &video_data,

bool setXorgWindowIcon(IrrlichtDevice *device)
bool setWindowIcon(IrrlichtDevice *device)
#ifdef XORG_USED
#if defined(XORG_USED)
return setXorgWindowIconFromPath(device,
path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png");
Expand All @@ -627,6 +627,36 @@ bool setXorgWindowIcon(IrrlichtDevice *device)
path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png");
# endif
#elif defined(_WIN32)
const video::SExposedVideoData exposedData = device->getVideoDriver()->getExposedVideoData();
HWND hWnd; // Window handle

switch (device->getVideoDriver()->getDriverType()) {
case video::EDT_DIRECT3D8:
hWnd = reinterpret_cast<HWND>(exposedData.D3D8.HWnd);
case video::EDT_DIRECT3D9:
hWnd = reinterpret_cast<HWND>(exposedData.D3D9.HWnd);
case video::EDT_OPENGL:
hWnd = reinterpret_cast<HWND>(exposedData.OpenGLWin32.HWnd);
return false;

// Load the ICON from resource file
const HICON hicon = LoadIcon(
MAKEINTRESOURCE(130) // The ID of the ICON defined in winresource.rc

if (hicon) {
SendMessage(hWnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(hicon));
SendMessage(hWnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(hicon));
return true;
return false;
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/porting.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ inline const char *getPlatformName()
void setXorgClassHint(const video::SExposedVideoData &video_data,
const std::string &name);

bool setXorgWindowIcon(IrrlichtDevice *device);
bool setWindowIcon(IrrlichtDevice *device);

bool setXorgWindowIconFromPath(IrrlichtDevice *device,
const std::string &icon_file);
Expand Down

0 comments on commit cc1ff26

Please sign in to comment.