How do I use XML in Irrlicht?

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
fatcat46
Posts: 23
Joined: Fri Apr 22, 2005 10:34 pm
Contact:

How do I use XML in Irrlicht?

Post by fatcat46 »

Hi,
I'm new to the engine and i know some thing but the XML worried me a lot.... How do i wrote them and use them in the engine?[/quote]
:: Double K ::
Web Site Under Construction
(http://k.domaindlx.com/fatcat46)
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

XML is not specific to irrlicht. if you dont know how to use XML go look it up. I recommend using tinyXML to deal with reading and writing XML, but first you have to understand what XML is, which is beyond the scope of this forum.
a screen cap is worth 0x100000 DWORDS
fatcat46
Posts: 23
Joined: Fri Apr 22, 2005 10:34 pm
Contact:

ok

Post by fatcat46 »

Thanks for that but now, how do I integrate tiny to Irrlicht?? :cry:
:: Double K ::
Web Site Under Construction
(http://k.domaindlx.com/fatcat46)
Guest

Post by Guest »

follow the tiny instructions to integrate it into any other project
fatcat46
Posts: 23
Joined: Fri Apr 22, 2005 10:34 pm
Contact:

Post by fatcat46 »

:shock: Tiny is sOOOooo powerfull!!!!
Thanks for the help!
:: Double K ::
Web Site Under Construction
(http://k.domaindlx.com/fatcat46)
one_eddie
Posts: 4
Joined: Wed Apr 20, 2005 10:30 am

Post by one_eddie »

Irrlicht has build in classes to handle XML:

I'm using this code to read configuration, this function is calles before createDevice

Code: Select all

void CMainApp::readConfiguration(CONFIGURATION& rConfig)
{
	// Create
	IReadFile* pFile = createReadFile( "App.xml" );
	if ( !pFile )
		throw new CAppException( TEXT_MISSING_CONFIG_FILE );

	// Create
	CTextReader* pTxtReader = new CTextReader( pFile );
	IXMLReader* pkXML = new CXMLReader( pTxtReader );

	// Drop
	pTxtReader->drop(); 
	pFile->drop();

	// Set std configuration
	rConfig.eDriverType = video::EDT_SOFTWARE;
	rConfig.iWidth = 640;
	rConfig.iHeight = 480;
	rConfig.bFullscreen = false;
	rConfig.iDepth = 16;

	// Check
	if ( !pkXML )
		throw new CAppException( TEXT_MISSING_CONFIG_FILE );

	// Read
	while( pkXML && pkXML->read() )
	{
		// Check
		switch( pkXML->getNodeType() )
		{
		case io::EXN_ELEMENT:
			{
				// Check
				if ( stringw( L"Driver" ) == pkXML->getNodeName() )
				{
					stringw strValue = pkXML->getAttributeValue( L"Type" );

					if (strValue == stringw( L"DirectX9" ) )
						rConfig.eDriverType = video::EDT_DIRECTX9;
					else
					if (strValue == stringw( L"DirectX8" ) )
						rConfig.eDriverType = video::EDT_DIRECTX8;
					else
					if (strValue == stringw( L"OpenGL" ) )
						rConfig.eDriverType = video::EDT_OPENGL;
					else
						rConfig.eDriverType = video::EDT_SOFTWARE;
				}
				else if ( stringw( L"Screen" ) == pkXML->getNodeName() )
				{
					// Copy values
					rConfig.iHeight = pkXML->getAttributeValueAsInt( L"Height" );
					rConfig.iWidth = pkXML->getAttributeValueAsInt( L"Width" );
					rConfig.iDepth = pkXML->getAttributeValueAsInt( L"Depth" );
					rConfig.bFullscreen = static_cast<bool>( pkXML->getAttributeValueAsInt( L"Full" ) );
				}
			}
			break;
		}
	}

	// Free XML reader
	if ( pkXML )
		pkXML->drop();
}
maybe this will help you
Post Reply