

#include "renderPass.h"

#include "../event.h"

#include "../vector2.h"

#include "../shader.h"

#include "int.h"

#include "../fontRenderer.h"

#include "../program.h"

#include "../mesh.h"

class tesselation extends renderPass{


	struct program * program;

	struct mesh * mesh;

	fontRenderer * font = new fontRenderer();

	sampler2D * samplerArray;

	char * textFromNumber( int i) {

		char * fileName = malloc( sizeof( char ) * 100 );

		sprintf( fileName, "%d", i );

		return fileName;

	}

	prepare() {

		shader * vertexShader = new shader( GL_VERTEX_SHADER );

		vertexShader->loadFromFile( "assets/shaders/quadScale.vertex" );


		shader * fragmentShader = new shader( GL_FRAGMENT_SHADER );

		fragmentShader->loadFromFile( "assets/shaders/color.fragment" );


		shader * geometryShader = new shader( GL_GEOMETRY_SHADER );

		geometryShader->loadFromFile( "assets/shaders/tesselation.geometry.shader" );


		shader * tesselationControlShader = new shader( GL_TESS_CONTROL_SHADER );

		tesselationControlShader->loadFromFile( "assets/shaders/tesselation.triangle.tsc.shader" );


		shader * tesselationEvaluationShader = new shader( GL_TESS_EVALUATION_SHADER );

		tesselationEvaluationShader->loadFromFile( "assets/shaders/tesselation.triangle.shader" );



		this->program 	= new program();

		this->program->addShader( vertexShader );

		this->program->addShader( fragmentShader );/*

		this->program->addShader( geometryShader );

		this->program->addShader( tesselationControlShader );

		this->program->addShader( tesselationEvaluationShader );*/



		this->program->create();




		this->mesh = new mesh();

		this->mesh->setProgram( this->program );

		this->mesh->createBuffers();


		glUseProgram( this->program->glProgram );


	}

	render() {

		glUseProgram( this->program->glProgram );

		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

		int numItems	= 12;

		//this->program->setUniform( "samplerArray", this->samplerArray );

		glBindVertexArray( this->mesh->vertexArrayObject );




		glDrawElements( GL_LINE_STRIP, numItems, GL_UNSIGNED_INT, ( void * ) 0 ); 

	}

}