Here's how to do it.
In IrrlichtDevice.h, following setWindowCaption(), I added:
Code: Select all
//! Sets the application class
virtual void setApplicationClass(const char* className) {}
Code: Select all
//! Sets the application class
virtual void setApplicationClass(const char* className) _IRR_OVERRIDE_;
Code: Select all
//! Sets the application class
void CIrrDeviceLinux::setApplicationClass(const char* className)
{
#ifdef _IRR_COMPILE_WITH_X11_
if (CreationParams.DriverType == video::EDT_NULL)
return;
XClassHint* hint = XAllocClassHint();
hint->res_name = const_cast<char*>(className);
hint->res_class = const_cast<char*>(className);
XSetClassHint(XDisplay, XWindow, hint);
XFree(hint);
#endif
}
I'm on Ubuntu, so you're experience may vary. In any case, you will need to know:
1.) The location of your application binaries (usually /usr/bin)
2.) The location of your application icons (there are various places)
3.) The location of your application launchers (usually /usr/share/applications)
You need to create:
1) A .desktop file.
2) An icon (even .png or .jpg will work since we're not on Windows, haha)
Creating a .desktop
A .desktop file is just a text file that looks something like this:
Code: Select all
[Desktop Entry]
Version=1.0
Name[en_US]=MyProgram
Comment=Description that shows up in my start menu
GenericName=MyProgram - Some text that shows up in other places
Exec=/usr/bin/MyProgram
Icon=MyProgram.png
MimeType=application/x-example
Terminal=false
Type=Application
StartupNotify=true
Categories=Utilities;3DGraphics;Education
StartupWMClass=MyProgramClass
When you create the .desktop file, you can do so by replacing the extension ".txt" with ".desktop", however, some file managers are stupid and decide to doubly append ".desktop" onto the name. Just rename the file without the ".desktop", and the file manager will append it's own. *sigh* Some things... Anyways...
Let's go over the important parts of the .desktop file:
Name - (followed by the language locale) This is for what your program is going to be named in your desktop startmenu, among other things.
Exec - The ABSOLUTE PATH of the executable. Relative paths are not accepted no matter where the .desktop file is located.
Icon - The name (NOT A PATH) of the icon for this application. The icon will be automatically searched for within system directories.
MimeType - This is the "type" value of the registered mimetype, and it allows your files to be associated with your application. More info can be found here: https://developer.gnome.org/integration ... me.html.en
It is recommended that you use "glob pattern" when created a mimetype because it's faster.
Terminal - If your application is itself a terminal OR your application execution is loaded with a terminal (such as: Exec=gnone-terminal myapp), then this will need to be set to true. Standalone Irrlicht apps don't need this.
Categories - This is where your application will be placed by default in your taskbar startmenu.
StartupWMClass THIS IS THE MOST IMPORTANT ONE FOR ADDING THE ICON. The name put here must be the same as the one you pass to IrrlichtDevice::setApplicationClass().
Installing
For this, you'll obviously need root privileges, so it's helpful to open your file manager with root access (if it gives you the convenient option of doing so, all the better!).
1.) Copy your .desktop file to your application launchers folder.
2.) Copy your binary to your application binaries folder.
3.) Copy your application icon into one of two places:
a) If you just have a single icon, try looking for the folder "pixmaps", which for me is under "/usr/share/pixmaps". This folder is for icons of basically any shape and size.
b) If you have various quality sizes, you will need to add the sizes you have to the appropriate folders under the icons folder, something like "/usr/share/icons". Such folders include:
/usr/share/icons/HighContrast/48x48/apps
/usr/share/icons/HighContrast/22x22/apps
/usr/share/icons/HighContrast/256x256/apps
/usr/share/icons/HighContrast/32x32/apps
/usr/share/icons/HighContrast/scalable/apps-extra
/usr/share/icons/HighContrast/24x24/apps
/usr/share/icons/HighContrast/16x16/apps
/usr/share/icons/hicolor/scalable/apps
/usr/share/icons/hicolor/128x128/apps
/usr/share/icons/hicolor/16x16/apps
But your system may vary.
I used pixmaps, so I can't guarantee the latter, but I do have applications with icons in a similar folder structure, so obviously, it worked for somebody.
I hope this helps somebody.
EDIT: Added memory freeing of the XClassHint.