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.
paooolino
Posts: 50 Joined: Wed Dec 21, 2005 12:17 pm
Location: Brescia, Italy
Contact:
Post
by paooolino » Sat Sep 13, 2008 7:47 pm
Hello guys. My question is simple.
I just wanna load an xml config file through IXMLReader and read few useful parameters like:
- video driver
- screen resolution
- ...others...
I know I need this line of code
Code: Select all
IXMLReader* xml = device->getFileSystem()->createXMLReader("...");
but I can put it only *AFTER* the device creation. But I need it *BEFORE*, as I have to read xml parameters for creating a device. How can I proceed?!
Acki
Posts: 3496 Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:
Post
by Acki » Sat Sep 13, 2008 7:53 pm
I don't use the IXMLReader/Writer (I'm using tinyXML), but you can create a device with the NULL driver (EDT_NULL) first to read the xml file, then drop the device and create a new one with the desired parameters...
paooolino
Posts: 50 Joined: Wed Dec 21, 2005 12:17 pm
Location: Brescia, Italy
Contact:
Post
by paooolino » Sat Sep 13, 2008 8:11 pm
mmh I will give it a try, thanks
ehenkes
Posts: 47 Joined: Sun Aug 03, 2008 2:52 pm
Location: Germany
Contact:
Post
by ehenkes » Sat Sep 13, 2008 8:45 pm
This works:
sourcecode:
Code: Select all
// ************ Setup irrlicht device ***************
s32 screenWidth, screenHeight;
SIrrlichtCreationParameters paramIrr;
MyEventReceiver receiver;
paramIrr.EventReceiver = &receiver;
IrrXMLReader* xml = createIrrXMLReader("settings.xml");
while(xml && xml->read())
{
switch(xml->getNodeType())
{
case EXN_ELEMENT:
{
if (!strcmp("settings", xml->getNodeName()))
{
screenWidth = xml->getAttributeValueAsInt("width");
screenHeight = xml->getAttributeValueAsInt("height");
paramIrr.Fullscreen = xml->getAttributeValueAsInt("fullscreen");
paramIrr.Vsync = xml->getAttributeValueAsInt("vsync");
//TODO: integrate more parameters in XML file
}
}
break;
}//switch
}//while
delete xml;
paramIrr.AntiAlias = false;
paramIrr.Bits = 32;
paramIrr.DriverType = EDT_DIRECT3D9;
paramIrr.Stencilbuffer = false;
paramIrr.WindowSize = dimension2d<s32>(screenWidth, screenHeight);
device = createDeviceEx(paramIrr);
// ************ Setup driver, smgr, guienv ***************
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
device->getCursorControl()->setVisible(true); // mouse cursor
XML file:
Code: Select all
<?xml version="1.0"?>
<config>
<!--This is a config file for the irrlicht engine.-->
<settings width = "1024" height = "768" antialias = "1" fullscreen = "0" vsync = "0">
</settings>
</config>
Last edited by
ehenkes on Sun Sep 14, 2008 1:03 am, edited 1 time in total.
hybrid
Admin
Posts: 14143 Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:
Post
by hybrid » Sat Sep 13, 2008 10:47 pm
Yes, Irrlicht 1.4 should have the create XML Reader method exposed even on Windows. So you can use the XML reader even without a device.
ehenkes
Posts: 47 Joined: Sun Aug 03, 2008 2:52 pm
Location: Germany
Contact:
Post
by ehenkes » Sun Sep 14, 2008 1:02 am
So you can use the XML reader even without a device.
Yes, it definitely works before creating a device.
vitek
Bug Slayer
Posts: 3919 Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR
Post
by vitek » Mon Sep 15, 2008 4:25 am
ehenkes
Posts: 47 Joined: Sun Aug 03, 2008 2:52 pm
Location: Germany
Contact:
Post
by ehenkes » Mon Sep 15, 2008 9:57 pm
Should be xml->drop();
Sorry, there is no member function "drop()".
rogerborg
Admin
Posts: 3590 Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:
Post
by rogerborg » Mon Sep 15, 2008 10:23 pm
ehenkes wrote: Should be xml->drop();
Sorry, there is no member function "drop()".
Hmm. It seems like IrrXMLReader should be using IReferenceCounted as a base class (when used within Irrlicht). The documentation seems to assume that it will be. I wonder if there's a reason why it isn't?
vitek
Bug Slayer
Posts: 3919 Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR
Post
by vitek » Mon Sep 15, 2008 10:25 pm
ehenkes wrote: Should be xml->drop();
Sorry, there is no member function "drop()". :roll:
Ah, yes. I forget that Irrlicht supports both the
IrrXMLReader and
IXMLReader types. Only the
IXMLReader inherits from
IReferenceCounted ...
Travis
rogerborg
Admin
Posts: 3590 Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:
Post
by rogerborg » Tue Sep 16, 2008 7:00 am
Which seems bass ackwards. Deliberate, or snafu?
ehenkes
Posts: 47 Joined: Sun Aug 03, 2008 2:52 pm
Location: Germany
Contact:
Post
by ehenkes » Fri Sep 19, 2008 5:50 pm
I forget that Irrlicht supports both the IrrXMLReader and IXMLReader types.
Nice feature.
bass ackwards = ass backwards
snafu = situation normal all beyond repair