#ifndef OGL_WIDGET_SHARED_DATA_H
#define OGL_WIDGET_SHARED_DATA_H

#include "./../../../lib/glee/glee.h"
#include <iostream>

#include <qmutex.h>
#include "./cgSupport/CgShaderManager.h"
#include "./configurator/CALreader.h"
#include "./renderer/Render2D.h"
#include "./apps/AbstractAPP.h"
#include "./console/Environment.h"
#include "./exception/Exception.h"
#include "./renderer/softProjRender.h"
#include "./geometry/OBJsupport.h"
#include "./geometry/OBJmodel.h"
#include "./exception/Exception.h"
#include "./console/StrException.h"
#include "./math/Matrix.h"
#include "./math/SupportFunctions.h"
#include "./illumination/LightPrinter.h"
#include <cassert>
#include "./softProj/Render/SpaceStructures.h"

#include "./softProj/Render/SpaceMap.h"
#include "./softProj/Render/SpaceSky.h"

#include "./ModelViewer/ModelViewer.h"
#include "./heightMap/heightMap.h"
#include "./softProj/Render/SpaceMapGameInterface.h"
#include "./softProj/Render/SpacePlanetGameInterface.h"
#include "./softProj/Render/ItemViewer.h"
#include "./softProj/clientServer/sharedStructures.h"
#include "./effects/animationEffect.h"
#include "./softProj/selectionWidget/selectionWidget.h"
#include "./softProj/selectionWidget/otherviewWidget.h"
#include "softProj\graphicMapper.h"

#include <map>
using namespace std;

using namespace ANALYTICAL_GEOMETRY;
using namespace GEOMETRY;

/// Auxiliary structure for important path directiories.
/**
*	Auxiliary structure for important path directiories.
*/
struct ExternalParamsGameData
{
	string CALpath;	 /**< relative path from working folder to CAL file directory*/
	string shadersPath;	/**< relative path from working folder to shaders directory*/
	string texturesPath;	/**< relative path from working folder to textures directory*/
	string modelsPath;	/**< relative path from working folder to models directory*/
	string terrainResourcesPath;	/**< relative path from working folder to terrains directory*/

	bool useShaders; /**< Flag if shaders should be used or not. */
	Projection projection; /**< data for projection matrix setting */
};

/// Contains important OpenGL data which can usefull to share with other applications.
/**
* Contains important OpenGL data which can usefull to share with other applications. All data loded from CAL file are stored into this structure, 
* so that every class with refence to this structure can use them.
*/
class OpenGlSharedData
{
private:
	bool initialized;

public:
	void init(void);	/**< Loads all OpenGL data defined in CAL file. This function must be called after OpenGL context is created!!!*/

	ShaderManager* shaderManager;	/**< shader manager manages all loaded GPU shaders*/
	VBOmanager vbo_manager;	/**< vertex buffer object manager manages all loaded GPU geometry data*/

	// vice stupnova struktura...pod jednim nazvem se skryva cely manager materialu (1 mtl soubor obvykle obsahuje vice materialu)*/
	std::map<string,PhongMaterialManager*> materialManager;	/**< multi-tier structure, under every name is stored whole material manager ( 1 mtl file contains usually many materials )*/
	std::map<string, Model* > modelManager;	/**< 3D model database, stores all loaded models. */

	calSpace::SkyboxContainer skyboxContainer;	/**< stores skyboxes data loaded from CAL file*/
	calSpace::TextureContainer textureContainer;	/**< stores textures data loaded from CAL file*/
	calSpace::MaterialContainer materialContainer;	/**< stores materials data loaded from CAL file*/
	calSpace::ModelContainer modelContainer;	/**< stores models data loaded from CAL file*/
	calSpace::TerrainContainer terrainContainer;	/**< stores terrain data loaded from CAL file*/
	ExternalParamsGameData externalParams;		/**< stores important relative pathes*/

	OpenGlSharedData( const string &appPath, const string& resourcePath, Environment &env );  /**< Load external data from envFile and stores them. CAL file specified in envFile is also parsed. */
	~OpenGlSharedData(); /**< Release all alocated resources. */
};


#endif