//Header du moteur

#include "Define.h"


class CMoteur
{
	private:
		class CSprite
		{
			private:
				GLint IDTexture;

			public:
				CSprite();
				~CSprite();

				void Affiche(GLint x, GLint y, GLint w, GLint h, unsigned char red = 255, unsigned char green = 255, unsigned char blue = 255, bool balpha = false, unsigned char alpha = 255, bool inversX = false, bool inversY = false);
				GLint LoadTexture(const char * filename);
		};

		class CTexte
		{

			private :
		        	GLuint surface[42];
		        	int giveLettre(char lettre);
					GLint ChargerFichier(const char *NomPolice, const char *NomFichier);

			public :
		       		CTexte();
		        	~CTexte();

		        	void LoadFont(const char * NomDeLaPolice);
		        	void DessineTexte(const char * texte, int taille, int PosX, int PosY, unsigned char red = 255, unsigned char green = 255, unsigned char blue = 255, bool balpha = false, unsigned char alpha = 255);


		};

		bool IsFullScreen, Fondu;
		Uint32 nbFPS, LastFPS, FPS, DebFondu, FinFondu;
		SDL_Surface *Screen;
		unsigned char DebFonduBlue, DebFonduGreen, DebFonduRed, DebFonduAlpha, FinFonduBlue, FinFonduGreen, FinFonduRed, FinFonduAlpha;

		vector<CSprite> Sprites;
		vector<CTexte> Fontes;


	public:
		CMoteur(); //Constructeur
		~CMoteur(); //Destructeur ...

		int Init(bool FullScreen, const char *TitreFenetre);
		
		void DebutDessin();
		void FinDessin();

		void AfficheTexture(Uint32 nbTex, GLint x, GLint y, GLint w, GLint h, unsigned char red = 255, unsigned char green = 255, unsigned char blue = 255, unsigned char alpha = 255);
		void DessineTexte(int NbFonte, const char *Texte, int Taille, int x, int y, unsigned char red = 255, unsigned char green = 255, unsigned char blue = 255, unsigned char alpha = 255);
		void DessineFPS();

		int NouvelleFonte(const char *NomFonte);
		int NouvelleTexture(const char *CheminImg);

		void ResizeWindow(int larg, int haut);

		void RajoutFondu(Uint32 pDebFondu, Uint32 pFinFondu, unsigned char pDebFonduRed, unsigned char pDebFonduGreen, unsigned char pDebFonduBlue, unsigned char pDebFonduAlpha, unsigned char pFinFonduRed, unsigned char pFinFonduGreen, unsigned char pFinFonduBlue, unsigned char pFinFonduAlpha);


};

extern CMoteur Moteur;

