#include <GL/glut.h>
#include <string>
#include <strstream>
#include <vector>

#include "parametres.h"
#include "CPointChaud.h"
#include "globale.h"
#include "CWinStream.h"

void CalculTemp(void);

void run(void)
{
	static int Compteur = 0;

	CalculTemp();

	Compteur++;

	if (Compteur >= CALCULPARFRAME)
	{
		Compteur = 0;
		glutPostRedisplay();
	}
}

#include "Temps.h"
inline void FPS(void)
{
	static long Temps = GetTemps();
	static int Compteur = 0;
	static int AncienCompteur = 0;

	++Compteur;

	if (GetTemps() - Temps > 1000)
	{
		Temps = GetTemps();
		AncienCompteur = Compteur;
		Compteur = 0;
	}

	wout.Begin();
	wout.SetPos(10, 10);
	wout << AncienCompteur;
	wout.End();
}


void SetCoul(float);

void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT);

	for (int i = 0; i < DIV_X-1; i++)
		for (int j = 0; j < DIV_Y-1; j++)
		{
			glBegin(GL_QUADS);
				SetCoul(Temperatures[i][j]);
				glVertex2i(i,j);
				SetCoul(Temperatures[i+1][j]);
				glVertex2i(i+1,j);
				SetCoul(Temperatures[i+1][j+1]);
				glVertex2i(i+1,j+1);
				SetCoul(Temperatures[i][j+1]);
				glVertex2i(i,j+1);
			glEnd();
		}

	glColor3f(0,0,0);
	glPointSize(2);
	glBegin(GL_POINTS);
	for (int a = 0; a < (signed) LesPoints.size(); a++)
		glVertex2i(LesPoints[a].x, LesPoints[a].y);
	glEnd();


	FPS();
		
	glutSwapBuffers();
}
