Getting filesystem without device

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
hiker
Posts: 58
Joined: Thu May 31, 2007 5:12 am

Getting filesystem without device

Post by hiker »

Hi all,

I am evaluating irrlicht as an engine for a program I am working on, and I am stuck with a silly(?) problem:
I want to read an XML configuration file, which contains the resolution the program should start with. Now, to get an XML reader, I need a IFileSystem, which I get from the device, but I can't create the device without having the resolution(?). There are a few obivous ideas:
  • 1) read the resolution (and fullscreen option) from a plain text file (with standard C++ functions), and create the device, and then read the full config file? Seems to be a bit ugly having two config files.

    2) add another XML parser - but I want to avoid more dependencies.

    3) Create a device with a default resolution, read the config file, delete the device and create a new one? Wouldn't that create a somewhat disturbing flicker?

    4) Manually create a new CFileSystem (after including CFileSystem.h and specifying an additional -I directive)?? Obviously a bad idea :( (but it appears to be working, at least I get a valid working directory)
Now, I would think that I am not the first one with the problem (I didn't find an answer here on the forum except for using TinyXML, and it appears a bit strange having to do this), and that there must be a good solution :)

Any help/recommendations highly appreciated!

Cheers,
Joerg

Edited: removed FAQ question about changing the resolution of a device :oops:
Last edited by hiker on Thu May 31, 2007 6:42 am, edited 1 time in total.
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

Create a device with EDT_NULL for the renderer and then get the config, destroy this device, and create a new one.
hiker
Posts: 58
Joined: Thu May 31, 2007 5:12 am

Post by hiker »

Hi,

thanks a lot - I knew I was missing something.

Cheers,
Joerg
LLDD
Posts: 43
Joined: Fri May 11, 2007 9:50 am

Post by LLDD »

You can use irrXML without creating a device.

This is the code I'm using. If I remember properly I had to add irrXML.cpp to my project.

Code: Select all


	// Open config.xml
	IrrXMLReader* xml = createIrrXMLReader("Config.xml");

	// Check if it was opened correctly
	if(xml!=0){
		// Start reading
		while(xml->read()){
			if(xml->getNodeType()==EXN_ELEMENT){
				// Screen drivertype x y bpp fullscreen
				if(!strcmp("Screen", xml->getNodeName())){
					
					// drivertype
					drivertype=xml->getAttributeValueAsInt("drivertype");

					// x
					x=xml->getAttributeValueAsInt("x");

					// y
					y=xml->getAttributeValueAsInt("y");

					ScreenX=x; ScreenY=y;

					// bpp
					bpp=xml->getAttributeValueAsInt("bpp");

					// fullscreen
					fullscreen=xml->getAttributeValueAsInt("fullscreen");	
				}
			}
		}

		delete xml;
	}
	

	// create device and exit if creation failed
	device = createDevice((E_DRIVER_TYPE)drivertype, dimension2d<s32>(x, y), bpp, fullscreen, 1);
________
BRITISH COOKING
Last edited by LLDD on Sun Feb 20, 2011 2:13 am, edited 1 time in total.
elvman
Posts: 253
Joined: Sun Sep 17, 2006 9:37 am
Location: Riga, Latvia
Contact:

Post by elvman »

Why do Irrlicht developer's add IrrXML.cpp to Irrlicht engine, if we still need to add it to our projects too? My suggestion is to define IrrXML functions like this:

Code: Select all

IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename);
and #include "IrrCompileConfig.h" in the IrrXML.h, so that we don't need to add IrrXML.cpp to our projects.
P.S. I defined IrrXML functions like this and it worked!
Post Reply