GUI Event Never Created When GUI Is Added to Irr Tech Demo

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
nighthawk
Posts: 16
Joined: Tue May 30, 2006 5:43 am

GUI Event Never Created When GUI Is Added to Irr Tech Demo

Post by nighthawk »

Hi all,

I was trying to add GUI to Irrlicht's tech demo. What I did was to merge Example 9, Mesh Viewer with the demo. Menus and buttons were all shown up and rendered correctly. But I run on the problem that a GUI event was never created when I clicked on these menus and buttons. I set up a conditional break point in
CIrrDeviceStub::postEventFromUser(SEvent event)
method to make the program stop when event.EventType == EET_GUI_EVENT was true. The breakpoint was never reached.

Here is what I did:

I created a method in CDemo.cpp:

void CDemo::createMenuAndToolbar(gui::IGUIEnvironment* env){
video::IVideoDriver* driver = device->getVideoDriver();

gui::IGUISkin* skin = env->getSkin();
gui::IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp");
if(font)
skin->setFont(font);

//Create menu
gui::IGUIContextMenu* menu = env->addMenu();
menu->addItem(L"File", -1, true, true);
menu->addItem(L"View", -1, true, true);
menu->addItem(L"Help", -1, true, true);

gui::IGUIContextMenu* submenu;
submenu = menu->getSubMenu(0);
submenu->addItem(L"Open Model File ...", 100);
submenu->addSeparator();
submenu->addItem(L"Quit", 200);

submenu = menu->getSubMenu(1);
submenu->addItem(L"toggle sky box visibility", 300);
submenu->addItem(L"toggle model debug information", 400);
submenu->addItem(L"model material", -1, true, true);

submenu = submenu->getSubMenu(2);
submenu->addItem(L"Solid", 610);
submenu->addItem(L"Transparent", 620);
submenu->addItem(L"Reflection", 630);

submenu = menu->getSubMenu(2);
submenu->addItem(L"About", 500);

// Create toolbar
gui::IGUIToolBar* bar = env->addToolBar();
bar->addButton(1102, 0, driver->getTexture("../../media/open.bmp"));
bar->addButton(1103, 0, driver->getTexture("../../media/help.bmp"));
bar->addButton(1104, 0, driver->getTexture("../../media/tools.bmp"));

// Create a combo box
gui::IGUIComboBox* box = env->addComboBox(core::rect<s32>(100,5,200,25), bar);
box->addItem(L"Bilinear");
box->addItem(L"Trilinear");
box->addItem(L"Anisotropic");
box->addItem(L"Isotropic");
box->addItem(L"Psychedelic");
box->addItem(L"No filtering");
}


Then in run(), I called the above method

void CDemo::run()
{
eventDispatcher = CEventDispatcher;
device = createDevice(driverType,
core::dimension2d<s32>(640, 480), 32, fullscreen, shadows, vsync, eventDispatcher);;
eventDispatcher->addEventReceiver(this);

device->getFileSystem()->addZipFileArchive("irrlicht.dat");
device->getFileSystem()->addZipFileArchive("../../media/irrlicht.dat");
device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");

video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* guienv = device->getGUIEnvironment();

createMenuAndToolbar(guienv);

device->setWindowCaption(L"Irrlicht Engine Demo");

wchar_t tmp[255];

while(device->run() && driver)
{
if (device->isWindowActive())
{
// load next scene if necessary
u32 now = device->getTimer()->getTime();
if (now - sceneStartTime > timeForThisScene && timeForThisScene!=-1)
switchToNextScene();

createParticleImpacts();

// draw everything

driver->beginScene(true, true, backColor);

smgr->drawAll();
guienv->drawAll();

driver->endScene();

// write statistics

swprintf(tmp, 255, L"%s fps:%d", driver->getName(), driver->getFPS());

statusText->setText(tmp);
}
}

device->drop();
}


CEventDispatcher is used to store multiple event receivers and dispatch events to them.

I found GUI event was never created inside the engine when GUI components were clicked.

Any suggestions?
nighthawk
Posts: 16
Joined: Tue May 30, 2006 5:43 am

Post by nighthawk »

Sorry, I forgot the let you guys know I have changed the camera from a FPS one to a third person one.

Thanks
nighthawk
Posts: 16
Joined: Tue May 30, 2006 5:43 am

Post by nighthawk »

Can anybody shed some light on this problem?

Thanks
CuteAlien
Admin
Posts: 10027
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

CIrrDeviceSutb::postEventFromUser is rarely called for GUI-Events, so you won't get them by setting a breakpoint there.

You set an eventreceiver here:

Code: Select all

eventDispatcher = CEventDispatcher;
device = createDevice(driverType,
core::dimension2d<s32>(640, 480), 32, fullscreen, shadows, vsync, eventDispatcher);;
But i can't help you, because i don't know what CEventDispatcher looks like (it sounds rather like a class name than a variable name to me, maybe you wanted "eventDispatcher = new CEventDispatcher"). I can only tell you what it should look like. It should be a variable to an object from a class which is derived from IEventReceiver. And in that class you should have an OnEvent member (it probably is that way already, otherewise it wouldn't compile). And this member is the place to check for gui-events. If you have that and it doesn't work it might help to post the OnEvent function of that class and maybe the point where you declare CEventDispatcher (maybe it is just 0?).
nighthawk
Posts: 16
Joined: Tue May 30, 2006 5:43 am

Post by nighthawk »

Hi CuteAlien,

Thank you for your replay. But the problem is not in eventDispatcher. I finally found that device->getSceneManager()->getActiveCamera() is keeping GUI events from being fired up.

Please see the following for the OnEvent method in CDemo.cpp:

bool CDemo::OnEvent(SEvent event)
{
if (!device)
return false;

if(event.EventType == EET_GUI_EVENT)
{
// GUI Event
#ifdef _DEBUG
char tmp[255];
sprintf(tmp, "GUI Eventevent.GUIEvent.EventType = %d\n", event.GUIEvent.EventType);
OutputDebugString(tmp);
#endif
s32 id = event.GUIEvent.Caller->getID();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
bool obsorbed = false;
switch(event.GUIEvent.EventType)
{
case gui::EGET_MENU_ITEM_SELECTED:
{
//a menu item was clicked
gui::IGUIContextMenu* menu = (gui::IGUIContextMenu*) event.GUIEvent.Caller;
s32 menuId = menu->getItemCommandId(menu->getSelectedItem());
switch(menuId)
{
case 100: // File->Open Model
env->addFileOpenDialog(L"Please select a model file to open");
obsorbed = true;
break;
case 200: // File->Quit
device->closeDevice();
obsorbed = true;
break;
case 300: // View->Skybox
skyboxNode->setVisible(!skyboxNode->isVisible());
obsorbed = true;
break;
case 400: // View->Debugging Information
obsorbed = true;
break;
case 500:
obsorbed = true;
break;
case 610:
obsorbed = true;
break;
case 620:
obsorbed = true;
break;
case 630:
obsorbed = true;
break;
}
}
case gui::EGET_FILE_SELECTED:
{
// load the model file, selected in the file open dialog
gui::IGUIFileOpenDialog* dialog = (gui::IGUIFileOpenDialog*) event.GUIEvent.Caller;
// loadModel(core::stringc(dialog->getFilename()).c_str());
obsorbed = true;
break;
}
case gui::EGET_BUTTON_CLICKED:
{
switch(id)
{
case 1101:
{
gui::IGUIElement* root = env->getRootGUIElement();
core::vector3df scale;
core::stringc s;
s = root->getElementFromId(901, true)->getText();
scale.X = (f32)atof(s.c_str());
s = root->getElementFromId(902, true)->getText();
scale.Y = (f32)atof(s.c_str());
s = root->getElementFromId(903, true)->getText();
scale.Z = (f32)atof(s.c_str());
}
obsorbed = true;
break;
case 1102:
env->addFileOpenDialog(L"Please select a model file to upload");
obsorbed = true;
break;
case 1103:
obsorbed = true;
break;
case 1104:
obsorbed = true;
break;
}
}
}
if(obsorbed)
return true;
}else if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_ESCAPE &&
event.KeyInput.PressedDown == false)
{
device->closeDevice();
}
/*
else
if (device->getSceneManager()->getActiveCamera())
{
device->getSceneManager()->getActiveCamera()->OnEvent(event);
return true;
}
*/

return false;
}


Please be noted lines that I commented out at the bottom. If these lines were uncommented, GUI events were never fired up.

I think this is a bug inside the engine.
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I think it should be

Code: Select all

return  device->getSceneManager()->getActiveCamera()->OnEvent(event);
such that non-handled events are correctly passed on. But this is not a bug in the engine, but a bug in the demo :wink:
nighthawk
Posts: 16
Joined: Tue May 30, 2006 5:43 am

Post by nighthawk »

Hi Hybrid,

Thank you for your post. But changing to

Code: Select all

return  device->getSceneManager()->getActiveCamera()->OnEvent(event);
does not fix the problem. To isolate the problem, I changed the mesh viewer example and I reproduced the same problem there. The following is the code. The footprint of this test case is really small. You may get a handle of this problem if you can copy and paste this code into your debugger. Uncommenting

/*
else
if (Device->getSceneManager()->getActiveCamera())
{
return Device->getSceneManager()->getActiveCamera()->OnEvent(event);
}
*/



results in no GUI event is fired up when GUI elements are clicked.

Thanks.


Code: Select all

/*
 This tutorial show how to create a more complex application with the engine. We construct
 a simple mesh viewer using the user interface API and the scenemanagement of Irrlicht.
 The tutorial show how to create and use Buttons, Windows, Toolbars, Menus, ComboBoxes,
 Tabcontrols, Editboxes, Images, MessageBoxes, SkyBoxes, and how to parse XML files
 with the integrated XML reader of the engine.

 We start like in most other tutorials: Include all nesessary header files, add a
 comment to let the engine be linked with the right .lib file in Visual Studio,
 and deklare some global variables. We also add two 'using namespece' statements, so
 we do not need to write the whole names of all classes. In this tutorial, we use a
 lot stuff from the gui namespace.
*/
#include <irrlicht.h>
#include <iostream>
#include <windows.h>


using namespace irr;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")


IrrlichtDevice *Device = 0;
scene::ISceneManager* smgr = 0;
core::stringc StartUpModelFile;
core::stringw MessageText;
core::stringw Caption;
scene::IAnimatedMeshSceneNode* Model = 0;
scene::ISceneNode* SkyBox = 0;
video::SColor backColor;

/*
	The three following functions do several stuff used by the mesh viewer. 
	The first function showAboutText() simply displays a messagebox with a caption
	and a message text. The texts will be stored in the MessageText and 
	Caption variables at startup.
*/
void showAboutText()
{
	// create modal message box with the text
	// loaded from the xml file.
	Device->getGUIEnvironment()->addMessageBox(
		Caption.c_str(), MessageText.c_str());
}


/*
	The second function loadModel() loads a model and displays it using an
	addAnimatedMeshSceneNode and the scene manager. Nothing difficult. It also
	displays a short message box, if the model could not be loaded.
*/
void loadModel(const c8* fn)
{
	// load quake level

	Device->getFileSystem()->addZipFileArchive("irrlicht.dat");
	Device->getFileSystem()->addZipFileArchive("../../media/irrlicht.dat");
	Device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
	Device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");

	video::IVideoDriver* driver = Device->getVideoDriver();
	scene::ISceneManager* sm = Device->getSceneManager();

	scene::IAnimatedMesh* quakeLevelMesh = sm->getMesh("20kdm2.bsp");
	
	if (quakeLevelMesh)
	{
		scene::ISceneNode* quakeLevelNode = sm->addOctTreeSceneNode(quakeLevelMesh->getMesh(0));
		if (quakeLevelNode)
		{
			quakeLevelNode->setPosition(core::vector3df(-10,-10,-10));
			quakeLevelNode->setScale(core::vector3df(1,1,1));
			quakeLevelNode->setVisible(true);
			
		}
	}

	// set background color

	backColor.set(0,0,0,0);

//	scene::ICameraSceneNode* camera = 0;

//	camera = sm->addCameraSceneNodeMaya(0, 10.0f, 10.0f, 10.0f, 1234);
//	camera->setPosition(core::vector3df(0,0,0));
}


/*
	Finally, the third function creates a toolbox window. In this simple mesh viewer,
	this toolbox only contains a tab control with three edit boxes for changing
	the scale of the displayed model.
*/
void createToolBox()
{
	// remove tool box if already there
	IGUIEnvironment* env = Device->getGUIEnvironment();
	IGUIElement* root = env->getRootGUIElement();
	IGUIElement* e = root->getElementFromId(5000, true);
	if (e) e->remove();

	// create the toolbox window
	IGUIWindow* wnd = env->addWindow(core::rect<s32>(450,25,640,480),
		false, L"Toolset", 0, 5000);

	// create tab control and tabs
	IGUITabControl* tab = env->addTabControl(
		core::rect<s32>(2,20,640-452,480-7), wnd, true, true);

	IGUITab* t1 = tab->addTab(L"Scale");
	IGUITab* t2 = tab->addTab(L"Empty Tab");

	// add some edit boxes and a button to tab one
	env->addEditBox(L"1.0", core::rect<s32>(40,50,130,70), true, t1, 901);
	env->addEditBox(L"1.0", core::rect<s32>(40,80,130,100), true, t1, 902);
	env->addEditBox(L"1.0", core::rect<s32>(40,110,130,130), true, t1, 903);

	env->addButton(core::rect<s32>(10,150,100,190), t1, 1101, L"set");

	// add senseless checkbox
	env->addCheckBox(true, core::rect<s32>(10,220,200,240), t1, -1, L"Senseless Checkbox");

	// add undocumentated transparent control
	env->addStaticText(L"Transparent Control:", core::rect<s32>(10,240,150,260), true, false, t1);
	IGUIScrollBar* scrollbar = env->addScrollBar(true, core::rect<s32>(10,260,150,275), t1, 104);
	scrollbar->setMax(255);

	// bring irrlicht engine logo to front, because it
	// now may be below the newly created toolbox
	root->bringToFront(root->getElementFromId(666, true));
}


/*
	To get all the events sent by the GUI Elements, we need to create an event
	receiver. This one is really simple. If an event occurs, it checks the id
	of the caller and the event type, and starts an action based on these values.
	For example, if a menu item with id 100 was selected, if opens a file-open-dialog.
*/
class MyEventReceiver : public IEventReceiver
{
public:
	virtual bool OnEvent(SEvent event)
	{
		if(!Device)
			printf("Device is null and event = %d\n" + event.EventType);
		if (!Device)
		return false;
	if(event.EventType == EET_GUI_EVENT)
	{
		// GUI Event
#ifdef _DEBUG
		char tmp[255];
		sprintf(tmp, "GUI Eventevent.GUIEvent.EventType = %d\n", event.GUIEvent.EventType);
		OutputDebugString(tmp);
#endif
		s32 id = event.GUIEvent.Caller->getID();
		gui::IGUIEnvironment* env = Device->getGUIEnvironment();
		bool obsorbed = false;
		switch(event.GUIEvent.EventType)
		{
		case gui::EGET_MENU_ITEM_SELECTED:
			{
				//a menu item was clicked
				gui::IGUIContextMenu* menu = (gui::IGUIContextMenu*) event.GUIEvent.Caller;
				s32 menuId = menu->getItemCommandId(menu->getSelectedItem());
				switch(menuId)
				{
				case 100: // File->Open Model
					env->addFileOpenDialog(L"Please select a model file to open");
					obsorbed = true;
					break;
				case 200: // File->Quit
					Device->closeDevice();
					obsorbed = true;
					break;
				case 300: // View->Skybox
					SkyBox->setVisible(!SkyBox->isVisible());
					obsorbed = true;
					break;
				case 400: // View->Debugging Information
					obsorbed = true;
					break;
				case 500:
					obsorbed = true;
					break;
				case 610:
					obsorbed = true;
					break;
				case 620:
					obsorbed = true;
					break;
				case 630:
					obsorbed = true;
					break;
				}
			}
		case gui::EGET_FILE_SELECTED:
			{
				// load the model file, selected in the file open dialog
				gui::IGUIFileOpenDialog* dialog = (gui::IGUIFileOpenDialog*) event.GUIEvent.Caller;
//				loadModel(core::stringc(dialog->getFilename()).c_str());
				obsorbed = true;
				break;
			}
		case gui::EGET_BUTTON_CLICKED:
			{
				switch(id)
				{
				case 1101:
					{
						gui::IGUIElement* root = env->getRootGUIElement();
						core::vector3df scale;
						core::stringc s;
						s = root->getElementFromId(901, true)->getText();
						scale.X = (f32)atof(s.c_str());
						s = root->getElementFromId(902, true)->getText();
						scale.Y = (f32)atof(s.c_str());
						s = root->getElementFromId(903, true)->getText();
						scale.Z = (f32)atof(s.c_str());
					}
					obsorbed = true;
					break;
				case 1102:
					env->addFileOpenDialog(L"Please select a model file to upload");
					obsorbed = true;
					break;
				case 1103:
					obsorbed = true;
					break;
				case 1104:
					obsorbed = true;
					break;
				}
			}
		}
		if(obsorbed)
			return true;
	}else if (event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_ESCAPE &&
		event.KeyInput.PressedDown == false)
	{
			Device->closeDevice();
	}
	/*
	else
	if (Device->getSceneManager()->getActiveCamera())
	{
		return Device->getSceneManager()->getActiveCamera()->OnEvent(event);
	}
	*/
	return false;
}
};


/*
	Most of the hard work is done. We only need to create the Irrlicht Engine device
	and all the buttons, menus and toolbars. 
	We start up the engine as usual, using createDevice(). To make our application
	catch events, we set our eventreceiver as parameter. The #ifdef WIN32 preprocessor
	commands are not necesarry, but I included them to make the tutorial use DirectX on
	Windows and OpenGL on all other platforms like Linux. 
	As you can see, there is also a unusual call to IrrlichtDevice::setResizeAble(). 
	This makes the render window resizeable, which is quite useful for a mesh viewer.
*/
int main()
{
	// ask user for driver

	video::E_DRIVER_TYPE driverType = video::EDT_DIRECT3D8;

	printf("Please select the driver you want for this example:\n"\
		" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
		" (d) Software Renderer\n (e) Apfelbaum Software Renderer\n"\
		" (f) NullDevice\n (otherKey) exit\n\n");

	char key;
	std::cin >> key;

	switch(key)
	{
		case 'a': driverType = video::EDT_DIRECT3D9;break;
		case 'b': driverType = video::EDT_DIRECT3D8;break;
		case 'c': driverType = video::EDT_OPENGL;   break;
		case 'd': driverType = video::EDT_SOFTWARE; break;
		case 'e': driverType = video::EDT_SOFTWARE2;break;
		case 'f': driverType = video::EDT_NULL;     break;
		default: return 1;
	}	

	// create device and exit if creation failed

	MyEventReceiver receiver;
	Device = createDevice(driverType, core::dimension2d<s32>(640, 480),
		16, false, false, false, &receiver);

	if (Device == 0)
		return 1; // could not create selected driver.

	Device->setResizeAble(true);

	Device->setWindowCaption(L"Irrlicht Engine - Loading...");

	video::IVideoDriver* driver = Device->getVideoDriver();
	IGUIEnvironment* env = Device->getGUIEnvironment();
	smgr = Device->getSceneManager();

	driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

	/*
		The next step is to read the configuration file. It is stored in the xml 
		format and looks a little bit like this:

		<?xml version="1.0"?>
		<config>
			<startUpModel file="some filename" />
			<messageText caption="Irrlicht Engine Mesh Viewer">
				Hello!
			</messageText>
		</config>

		We need the data stored in there to be written into the global variables
		StartUpModelFile, MessageText and Caption. This is now done using the
		Irrlicht Engine integrated XML parser:
	*/

	// read configuration from xml file

	io::IXMLReader* xml = Device->getFileSystem()->createXMLReader(
		"../../media/config.xml");

	while(xml && xml->read())
	{
		switch(xml->getNodeType())
		{
		case io::EXN_TEXT:
			// in this xml file, the only text which occurs is the messageText
			MessageText = xml->getNodeData();
			break;
		case io::EXN_ELEMENT:
			{
				if (core::stringw("startUpModel") == xml->getNodeName())
					StartUpModelFile = xml->getAttributeValue(L"file");
				else
				if (core::stringw("messageText") == xml->getNodeName())
					Caption = xml->getAttributeValue(L"caption");
			}
			break;
		}
	}

	if (xml)
		xml->drop(); // don't forget to delete the xml reader 

	/*
		That wasn't difficult. Now we'll set a nicer font and create the
		Menu. It is possible to create submenus for every menu item. The call
		menu->addItem(L"File", -1, true, true); for example adds a new menu
		Item with the name "File" and the id -1. The following parameter says
		that the menu item should be enabled, and the last one says, that
		there should be a submenu. The submenu can now be accessed with
		menu->getSubMenu(0), because the "File" entry is the menu item with
		index 0.
	*/

	// set a nicer font

	IGUISkin* skin = env->getSkin();
	IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp");
	if (font)
		skin->setFont(font);

	// create menu

	gui::IGUIContextMenu* menu = env->addMenu();
	menu->addItem(L"File", -1, true, true);
	menu->addItem(L"View", -1, true, true);
	menu->addItem(L"Help", -1, true, true);

	gui::IGUIContextMenu* submenu;
	submenu = menu->getSubMenu(0);
	submenu->addItem(L"Open Model File...", 100);
	submenu->addSeparator();
	submenu->addItem(L"Quit", 200);

	submenu = menu->getSubMenu(1);
	submenu->addItem(L"toggle sky box visibility", 300);
	submenu->addItem(L"toggle model debug information", 400);
	submenu->addItem(L"model material", -1, true, true );

	submenu = submenu->getSubMenu(2);
	submenu->addItem(L"Solid", 610);
	submenu->addItem(L"Transparent", 620);
	submenu->addItem(L"Reflection", 630);

	submenu = menu->getSubMenu(2);
	submenu->addItem(L"About", 500);

	/*
		Below the toolbar, we want a toolbar, onto which we can place 
		colored buttons and important looking stuff like a senseless
		combobox.
	*/

	// create toolbar

	gui::IGUIToolBar* bar = env->addToolBar();

	video::ITexture* image = driver->getTexture("../../media/open.bmp");
	driver->makeColorKeyTexture(image, core::position2d<s32>(0,0));
	bar->addButton(1102, 0, image, 0, false, true);

	image = driver->getTexture("../../media/help.bmp");
	driver->makeColorKeyTexture(image, core::position2d<s32>(0,0));
	bar->addButton(1103, 0, image, 0, false, true);

	image = driver->getTexture("../../media/tools.bmp");
	driver->makeColorKeyTexture(image, core::position2d<s32>(0,0));
	bar->addButton(1104, 0, image, 0, false, true);

	// create a combobox with some senseless texts

	gui::IGUIComboBox* box = env->addComboBox(core::rect<s32>(100,5,200,25), bar);
	box->addItem(L"Bilinear");
	box->addItem(L"Trilinear");
	box->addItem(L"Anisotropic");
	box->addItem(L"Isotropic");
	box->addItem(L"Psychedelic");
	box->addItem(L"No filtering");

	/*
		To make the editor look a little bit better, we disable transparent
		gui elements, and add a Irrlicht Engine logo. In addition, a text,
		which will show the current frame per second value is created, and
		the window caption changed.
	*/

	// disable alpha

	for (s32 i=0; i<gui::EGDC_COUNT ; ++i)
	{
		video::SColor col = env->getSkin()->getColor((gui::EGUI_DEFAULT_COLOR)i);
		col.setAlpha(255);
		env->getSkin()->setColor((gui::EGUI_DEFAULT_COLOR)i, col);
	}

	// add a tabcontrol

	createToolBox();

	// create fps text 

	IGUIStaticText* fpstext = env->addStaticText(L"", core::rect<s32>(210,26,270,41), true);

	// set window caption

	Caption += " - [";
	Caption += driver->getName();
	Caption += "]";
	Device->setWindowCaption(Caption.c_str());

	/*
		That's nearly the whole application. We simply show the about 
		message box at start up, and load the first model. To make everything
		look better, a skybox is created and a user controled camera,
		to make the application a little bit more interactive. Finally,
		everything is drawed in a standard drawing loop.
	*/

	// show about message box and load default model
	showAboutText();
	loadModel(StartUpModelFile.c_str());

	// add skybox 

	SkyBox = smgr->addSkyBoxSceneNode(
		driver->getTexture("../../media/irrlicht2_up.jpg"),
		driver->getTexture("../../media/irrlicht2_dn.jpg"),
		driver->getTexture("../../media/irrlicht2_lf.jpg"),
		driver->getTexture("../../media/irrlicht2_rt.jpg"),
		driver->getTexture("../../media/irrlicht2_ft.jpg"),
		driver->getTexture("../../media/irrlicht2_bk.jpg"));

	// add a camera scene node 

	smgr->addCameraSceneNodeMaya();

	// load the irrlicht engine logo

	video::ITexture* irrLogo = 
		driver->getTexture("../../media/irrlichtlogoaligned.jpg");

	// draw everything

	while(Device->run() && driver)
		if (Device->isWindowActive())
		{
			driver->beginScene(true, true, video::SColor(150,50,50,50));

			smgr->drawAll();
			env->drawAll();

			// draw irrlicht engine logo
			driver->draw2DImage(irrLogo,
				core::position2d<s32>(10, driver->getScreenSize().Height - 50),
				core::rect<s32>(0,0,108-20,460-429));
		
			driver->endScene();

			core::stringw str = L"FPS: ";
			str += driver->getFPS();
			fpstext->setText(str.c_str());
		}

	Device->drop();
	return 0;
}
[/code]
Post Reply