/** ----------------------------------------------------------------------
*
*  main.c
*
*  ANTz - realtime 3D data visualization tools for the real-world, based on NPE.
*
*  Hosted at http://openantz.com and NPE at http://neuralphysics.org
*
*  Written in 2010-2016 by Shane Saxon - saxon@openantz.com
*
*  Additional code contributors are listed chronologically: Lucas Erickson,
*  Mark Buchanan and Johannes Johannsen
*
*  Special thanks to Dave Warner, project synergist and conceptual architect.
*  Additional gratitude to Jeff Sale for creating great data visualizations.
*
*  To the extent possible under law, the author(s) have dedicated all copyright
*  and related and neighboring rights to this software to the public domain
*  worldwide. This software is distributed without any warranty.
*
*  Released under the CC0 license, which is GPL compatible.
*
*  You should have received a copy of the CC0 Public Domain Dedication along
*  with this software (license file named LICENSE.txt). If not, see
*  http://creativecommons.org/publicdomain/zero/1.0/
*
* --------------------------------------------------------------------------- */

#include "npdata.h"					///< scene graph and other data structures
#include "npio.h"					///< file IO, MySQL, OSC-UDP, OpenGL
#include "npctrl.h"					///< command logic with physics

//! Using doxygen with graphviz for inline code docs.
/*!
 @param argc is the command line argument count.
 @param argv is a list of the tokenized arguments that can be used to load
		files and set initial parameters. From the system console, run 
		'antz ?' to see full list of command line arguments.
 @return 0 if exited normally, otherwise returns an error number which is 
		generated by the OS application framework.
*/
int main (int argc, char **argv)
{
/*! --------------------------------------------------------------------------
*  MVC architecture variant where View becomes a subset of the IO group.
*  Model named Data (map) is a global Scene Graph.
*  View named IO, includes keyboard, mice, haptic devices, audio, video...
*  Control named Ctrl, a pseudo state-machine based on physics, excludes IO.
*
*  Ctrl modifies the scene state and the Neural Physics Engine updates it.
*  Platform specific functions are separately placed in the 'os' subfolders.
*
*  Currently only a single (global) dataRef instance is used, but expect that
*  multiple instances will be created to support several users and GL contexts.
*
*  CPU load is currently 15% NPE, 5% qsort, 80% GL commands.
*  Greatest performance gain would be to make the GL code run in parallel.
*  main() can be compiled as either C or C++
* --------------------------------------------------------------------------- */

	int err = 0;
	void* data = NULL;	

	data = npInitData (argc, argv);			///< Model named - map
	npInitIO (data);						///< View called - io
	npInitCtrl (data);						///< Control is  - ctrl

	err = npAppLoop (data);					///< enter main app loop

	npCloseCtrl (data);						///< halt all activity
	npCloseIO (data);						///< close connections
	npCloseData (data);						///< data map destructor

	return err;
}

