#pragma once

#include <fstream>

/*
   Class: Shader

     Implements a GLSL shader handler.
*/
class Shader {
  public:
    /*
       Constructor: Shader

         Initializes the object by creating the OpenGL shaders and program.

       Parameters:

         sVertexSource - Source of the vertex shader as string.
         sFragmentSource - Source of the fragment shader as string.
    */
    Shader(const char* sVertexSource, const char* sFragmentSource);

    /*
       Destructor: ~Shader

         Releases all allocated resources. Also releases all OpenGL resources.
    */
    ~Shader();


    /*
       Function: Bind

         Binds the shader as the active OpenGL program.
    */
    void Bind() const;

    /*
       Function:

         Binds NULL as active OpenGL program.
    */
    void Unbind() const;

    /*
       Function: GetAttribLocation

         Returns the shader attribute location of the given attribute.

       Parameters:

         sName - Name of the attribute to be searched.

       Returns:

         The shader attribute location of the given attribute.
    */
    unsigned int GetAttribLocation(const char* sName) const;

    /*
       Function: GetUniformLocation

         Returns the shader uniform location of the given uniform.

       Parameters:

         sName - Name of the uniform to be searched.

       Returns:

         The shader uniform location of the given uniform.
    */
    unsigned int GetUniformLocation(const char* sName) const;

    /*
       Function: GetVertexLocation

         Returns the shader location for the vertex array.

       Returns:

         The shader location for the vertex array.
    */
    unsigned int GetVertexLocation();

    /*
       Function: GetColorLocation

         Returns the shader location for the color array.

       Returns:

         The shader location for the color array.
    */
    unsigned int GetColorLocation();

  private:
    unsigned int uVertexShader;
    unsigned int uFragmentShader;
    unsigned int uProgram;
    unsigned int uVertexLocation;
    unsigned int uColorLocation;
};