// Author: Juan Carlos De Abreu (jcabreur@gmail.com)

#include "Shader.h"
#include "../base/LogManagement.h"

BEGIN_TEG_NAMESPACE();

Shader::Shader() {}

Shader::~Shader() {}

std::tstring Shader::LoadShaderProgram(const std::tstring path) {
  // Try to open the file, and if cann't report a error.
  FILE *file = fopen(path.c_str(), "r");
  if (file == NULL) {
	  PRINT_LOG(TYPE_WARNING, "Cann't open the shader program file : '%s'", path.c_str());
    return "";
  }

  // Buffer to store temporaly each line in the lecture and the program string.
  char buffer[1000];
  std::tstring program;

  // Read each line of the program and store it.
  while (fgets(buffer, sizeof(buffer), file))
    program += buffer;

  // Close the file and return the program string.
  fclose(file);
  return program;
}

END_TEG_NAMESPACE();
