#pragma once

#include "MGL.h"
#include "Vector.h"

namespace Aftr
{

   class MGLGrid : public MGL
   {
   public:
      static MGLGrid* New(WO* parentWO, const std::vector<std::vector<VectorD> >& grid, const VectorD& scale, 
         const std::vector< std::vector< aftrColor4ub > >& colors = std::vector< std::vector< aftrColor4ub > >());

      virtual ~MGLGrid();  
      virtual void render( const Camera& cam );
      virtual void renderSelection( const Camera& cam, GLubyte red, GLubyte green, GLubyte blue );
      size_t getRows(){return row-1;}
      GLfloat* getNormalList(){return normalList;}
      GLfloat* getVertexList(){return vertexList;}
      virtual void defineIndices();
      virtual void defineVertices();
      virtual void defineTextureCoords();
      virtual void defineNormals();
      virtual void defineColors( const aftrColor4ub* c = NULL );
      virtual void makeVBO(int splits = 0);
      virtual size_t getFaceCount();
   protected:
      MGLGrid(WO* parentWO);
      MGLGrid(WO* parentWO, const std::vector<std::vector<VectorD> >& grid, const VectorD& scale, 
                            const std::vector< std::vector< aftrColor4ub > >& colors = std::vector< std::vector< aftrColor4ub > >());
      virtual void onCreate();

      //indexList is defined as GLvoid* from the MGL.h
      GLfloat* vertexList = nullptr;//list of descriptions of those vertices 
      GLubyte* colorList = nullptr;
      GLfloat* normalList = nullptr;
      GLfloat* textureList = nullptr;
      size_t row = 0;//strictly positive
      size_t column = 0;
      std::vector<std::vector<VectorD> > grid;
      std::vector< std::vector< aftrColor4ub > > colors;
      VectorD scale;

      GLuint vertexData = 0;
      GLuint indexData = 0;
   };

}  //namespace Aftr

