Hello,
I was figured out how to compile all bitmaps used for toolbars buttons (for example), because i want to compile Example 9 (Meshviewer) with no external dependencies except for irrlicht.dll.
I use Code::Blocks with VC++ Toolkit 2003 compiler, don't know is this way usable for other tools though...
File 09.Meshviewer.rc
Code: Select all
#include "resource.h"
IDI_ICON1 ICON "icon.ico"
IDI_OPEN1 BITMAP "open.bmp"
IDI_HELP1 BITMAP "help.bmp"
IDI_TOOLS1 BITMAP "tools.bmp"
Code: Select all
#define IDI_ICON1 1
#define IDI_OPEN1 2
#define IDI_HELP1 3
#define IDI_TOOLS1 4
in file main.cpp add following code:
Code: Select all
....
#include <windows.h>
#include "resource.h"
....
// set icon for window (in left top corner)
HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
HICON hSmallIcon = (HICON) LoadImage ( hInstance, MAKEINTRESOURCE(IDI_ICON1), 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 );
// end set icon
// set "open" button texture
// this is standard windows routine for loading resources
HBITMAP hOpenIcon = (HBITMAP) LoadImage ( hInstance, MAKEINTRESOURCE(IDI_OPEN1), IMAGE_BITMAP, 16, 16, LR_CREATEDIBSECTION);
// this is used for determening size of the resource
BITMAP bitmap;
GetObject(hOpenIcon,sizeof(BITMAP),&bitmap);
int sizestrip = bitmap.bmHeight*bitmap.bmWidth*bitmap.bmBitsPixel/8;
// this is assigning byte array for the bitmap
BYTE *strip = new BYTE[ sizestrip ];
// fill this array
GetBitmapBits((HBITMAP)hOpenIcon, sizestrip, strip );
// irrlicht native stuff for loading engine images from data (from byte array)
video::IImage* image = driver->createImageFromData(video::ECF_R8G8B8, core::dimension2d<s32>(16,16), strip, false);
// irrlicht native stuff for converting engine image to texture
video::ITexture* iconOpen = driver->addTexture("open", image);
// end set "open" button texture
// set "help" button texture
hOpenIcon = (HBITMAP) LoadImage ( hInstance, MAKEINTRESOURCE(IDI_HELP1), IMAGE_BITMAP, 16, 16, LR_CREATEDIBSECTION);
GetObject(hOpenIcon,sizeof(BITMAP),&bitmap);
sizestrip = bitmap.bmHeight*bitmap.bmWidth*bitmap.bmBitsPixel/8;
strip = new BYTE[ sizestrip ];
GetBitmapBits((HBITMAP)hOpenIcon, sizestrip, strip );
image = driver->createImageFromData(video::ECF_R8G8B8, core::dimension2d<s32>(16,16), strip, false);
video::ITexture* iconHelp = driver->addTexture("help", image);
// end set "help" button texture
// set "tools" button texture
hOpenIcon = (HBITMAP) LoadImage ( hInstance, MAKEINTRESOURCE(IDI_TOOLS1), IMAGE_BITMAP, 16, 16, LR_CREATEDIBSECTION);
GetObject(hOpenIcon,sizeof(BITMAP),&bitmap);
sizestrip = bitmap.bmHeight*bitmap.bmWidth*bitmap.bmBitsPixel/8;
strip = new BYTE[ sizestrip ];
GetBitmapBits((HBITMAP)hOpenIcon, sizestrip, strip );
image = driver->createImageFromData(video::ECF_R8G8B8, core::dimension2d<s32>(16,16), strip, false);
video::ITexture* iconTools = driver->addTexture("tools", image);
// end set "tools" button texture
....
//bar->addButton(1102, 0, driver->getTexture("../../media/open.bmp"));
bar->addButton(1102, 0, iconOpen);
//bar->addButton(1102, 0, driver->getTexture("../../media/help.bmp"));
bar->addButton(1103, 0, iconHelp);
//bar->addButton(1102, 0, driver->getTexture("../../media/tools.bmp"));
bar->addButton(1104, 0, iconTools);
User32.Lib
Gdi32.Lib
in compiler options of course add MicrosoftSDK/include folder
That's all i hope. Compile and notice that colors for the icons are somehow changed...
That's because of flipping Red and Blue bytes (probably in Irrlicht). So in order to have same images loaded from resources you should use external image editor to swap thouse colors...