text: //
  //  TextFile.cpp
  //  NYUCodebase
  //
  //  Created by Marcus Williams on 5/10/15.
  //  Copyright (c) 2015 Ivan Safrin. All rights reserved.
  //
  
  #include <SDL.h>
  #include <SDL_image.h>
  #include <SDL_opengl.h>
  #include <vector>
  #include <string>
  #include "TextFile.h"
  
  void Text::Draw(std::string text, float x, float y) {
      glBindTexture(GL_TEXTURE_2D, font);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glEnable(GL_TEXTURE_2D);
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      float texture_size = 1.0 / 16.0f;
      std::vector<float> vertexData;
      std::vector<float> texCoordData;
      std::vector<float> colorData;
      for (int i = 0; i < text.size(); i++) {
          float texture_x = (float)(((int)text[i]) % 16) / 16.0f;
          float texture_y = (float)(((int)text[i]) / 16) / 16.0f;
          
          colorData.insert(colorData.end(), { r, g, b, a, r, g, b, a, r, g, b, a, r, g, b, a });
          vertexData.insert(vertexData.end(), { ((size + spacing) * i) + (-0.5f * size), 0.5f * size, ((size + spacing) * i) +
              (-0.5f * size), -0.5f * size, ((size + spacing) * i) + (0.5f * size), -0.5f * size, ((size + spacing) * i) + (0.5f * size), 0.5f
              * size });
          
          texCoordData.insert(texCoordData.end(), { texture_x, texture_y, texture_x, texture_y + texture_size, texture_x +
              texture_size, texture_y + texture_size, texture_x + texture_size, texture_y });
      }
      glPushMatrix();
      glTranslatef(x, y, 0.0);
      
      glColorPointer(4, GL_FLOAT, 0, colorData.data());
      glEnableClientState(GL_COLOR_ARRAY);
      glVertexPointer(2, GL_FLOAT, 0, vertexData.data());
      glEnableClientState(GL_VERTEX_ARRAY);
      glTexCoordPointer(2, GL_FLOAT, 0, texCoordData.data());
      glEnableClientState(GL_TEXTURE_COORD_ARRAY);
      glDrawArrays(GL_QUADS, 0, text.size() * 4.0);
      glPopMatrix();
      
      glDisableClientState(GL_COLOR_ARRAY);
      glDisableClientState(GL_VERTEX_ARRAY);
      glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  }