Suggestion: allow using custom icon for window

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
comicsteam
Posts: 51
Joined: Thu Sep 11, 2008 2:24 pm
Location: Hong Kong
Contact:

Suggestion: allow using custom icon for window

Post by comicsteam »

I am developing a game using Irrlicht.
I want to use my custom icon and display it on the window's top left corner.
It is possible to do so if i named my icon as "irrlicht.ico".
However, if I want to embed my icon inside the exe file, there's no way for me to use it in Irrlicht.
Could we modify the source code a little bit in this way:

for struct SIrrlichtCreationParameters, add const char* windowIcon (default is "irrlicht.ico")

for createDevice()

Code: Select all

IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType,
		const core::dimension2d<s32>& windowSize,
		u32 bits, bool fullscreen,
		bool stencilbuffer, bool vsync, IEventReceiver* res,
		const char* windowIcon) /***added***/
{
	SIrrlichtCreationParameters p;
	p.DriverType = driverType;
	p.WindowSize = windowSize;
	p.Bits = bits;
	p.Fullscreen = fullscreen;
	p.Stencilbuffer = stencilbuffer;
	p.Vsync = vsync;
	p.EventReceiver = res;
	p.windowIcon = windowIcon; /***added***/

	return createDeviceEx(p);
}
for CIrrDeviceWin32 constructor

Code: Select all

CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters& params)
: CIrrDeviceStub(params), HWnd(0), ChangedToFullScreen(false),
	IsNonNTWindows(false), Resized(false),
	ExternalWindow(false), Win32CursorControl(0)
{
	......
	......

	// if there is an icon, load it
	wcex.hIcon = (HICON)LoadImage(hInstance, CreationParams.windowIcon /***modified***/, IMAGE_ICON, 0,0, LR_LOADFROMFILE);
	......
	......
}
So that i can use the following code to create a window with my icon

Code: Select all

_device = createDevice(
		video::EDT_DIRECT3D9,
		core::dimension2d<s32>(800, 600),
		32,
		false,
		false,
		false,
		0,
		MAKEINTRESOURCEA(IDI_ICON1) //IDI_ICON1 is the icon embedded in the exe file
		);
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You can do this within MSVC08 for sure.... and previous versions i think... and DevC++ can do it as well so mostly i think it's an IDE problem rather than something for irrlicht.
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I'll move this to the bug forum (as it's a better place for feature requests of this kind as well). Maybe you can also submit a feature request to the Irrlicht tracker at our SourceForge page?
https://sourceforge.net/tracker2/?atid= ... unc=browse
drewbacca
Posts: 38
Joined: Tue Jan 30, 2007 6:49 pm

Post by drewbacca »

It would be nice to have a cleaner way to set the icon. In the meantime, someone posted some code on this forum that I know will work in at least VS8 to set the window icon.

Code: Select all

	HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
	HICON hSmallIcon = (HICON) LoadImage ( hInstance, MAKEINTRESOURCE(IDI_ICON2), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR );
	irr::video::SExposedVideoData exposedData = driver->getExposedVideoData();
	HWND hWnd = reinterpret_cast<HWND>(exposedData.D3D9.HWnd);
	SendMessage ( hWnd, WM_SETICON, ICON_SMALL, (long)hSmallIcon );
where IDI_ICON2 was the image in my resource file.
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

no , just use the tools you are using properly.
The problem with your idea is that that is windows only, so its useless on a cross platform engine.

I understand the code exists on every platform...but then again so do resource files. Building with an icon is pancakes (seeing as we work in project nots from the command line) it isnt really a matter.
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

I thought you just copy over the icon file with __your__ icon? you should be able to display a different image.
Image
Post Reply