/** ---------------------------------------------------------------------------
*
*  main.c
*
*  ANTz - hyper dimensional visualization tools to synergize the group mind.
*
*  http://openantz.com is based on the Neural Physics Engine (NPE).
*
*  Written in 2010-2019 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.
*
*  Released under the CC0 license, so everyone everywhere can use it freely!
*
*  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.
*
*  CC0 Public Domain Dedication 'LICENSE.txt' is in the 'doc' folder, or see:
*  http://creativecommons.org/publicdomain/zero/1.0/
*
*  3rd party library licenses are in the 'sdk/libs/' folders.
* -------------------------------------------------------------------------- */

//! Using Doxygen with graphviz DOT for inline code docs.
#include "npdata.h"					/// Our data map is a scene graph.
#include "npio.h"					/// IO for all user devices, file, DB, net.
#include "npctrl.h"					/// Control logic with physics.

/*!
 @param argc command line argument count
 @param argv tokenized arguments: load files, set parameters. 
		Get help, run 'antz ?' to see a 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, an event driven pseudo state-machine based on physics.
*
*  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;

	npInitApp();							/// Init 3rd party App Framework

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

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

	npCloseCtrl (data);						/// halt ctrl events
	npCloseIO (data);						/// save globals, release io
	npCloseData (data);						/// destroy map

	return err;
}

