
#include "precomp.h"
#include "application.h"
#include "world.h"

Application app;

int Application::main(int argc, char** argv)
{
	CL_ConsoleWindow console("Debug console window", 80, 25);
	console.redirect_stdio();

	try
	{
		std::cout << "ClanLib Pacman game, written by Magnus Norddahl" << std::endl;
		
		CL_SetupCore::init();
		CL_SetupDisplay::init();
		CL_SetupGL::init();
		CL_SetupSound::init();
		CL_SetupMikMod::init();

		CL_SoundOutput sound_output(44100);
//#ifdef _DEBUG
		CL_DisplayWindow window("The ClanLib Pacman game!", 640, 480, false);
//#else
//		CL_DisplayWindow window("The ClanLib Pacman game!", 640, 480, true);
//#endif

		CL_ResourceManager resources("pacman.xml");

		World world(&resources);
		world.run(window);
	}
	catch (CL_Error err)
	{
		std::cout << "Exeception caught: " << err.message.c_str() << std::endl;
		console.wait_for_key();
	}

	CL_SetupMikMod::deinit();
	CL_SetupSound::deinit();
	CL_SetupGL::deinit();
	CL_SetupDisplay::deinit();
	CL_SetupCore::deinit();
	
	return 0;
}
