/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
#ifndef SHADERS_H
#define SHADERS_H

#include <glew/glew.h>
#include <glm/glm.hpp>

#include <string>
#include <vector>
#include <map>

class ShaderProgram
{
public:
    // Setting integers
    void setUniform(unsigned int uProgId, const char* name, int* iValues);
    void setUniform(unsigned int uProgId, const char* name, const int iValue);
    // Setting floats
    void setUniform(unsigned int uProgId, const char* name, float* fValues);
    void setUniform(unsigned int uProgId, const char* name, const float fValue);
    // Setting vectors
    void setUniform(unsigned int uProgId, const char* name, glm::vec2* vVectors);
    void setUniform(unsigned int uProgId, const char* name, const glm::vec2 vVector);
    void setUniform(unsigned int uProgId, const char* name, glm::vec3* vVectors);
    void setUniform(unsigned int uProgId, const char* name, const glm::vec3 vVector);
    void setUniform(unsigned int uProgId, const char* name, glm::vec4* vVectors);
    void setUniform(unsigned int uProgId, const char* name, const glm::vec4 vVector);
    // Setting 3x3 matrices
    void setUniform(unsigned int uProgId, const char* name, glm::mat3* mMatrices);
    void setUniform(unsigned int uProgId, const char* name, const glm::mat3 mMatrix);
    // Setting 4x4 matrices
    void setUniform(unsigned int uProgId, const char* name, glm::mat4* mMatrices);
    void setUniform(unsigned int uProgId, const char* name, const glm::mat4 mMatrix);

	unsigned int createProgram(const std::string& vName, const std::string& fName);
    unsigned int createProgram(const char* pvShader, const char* pfShader);

	void deleteProgram(unsigned int programId);

	void useProgram(unsigned int programId);

    bool loadShader(unsigned int programId, const std::string& shaderName, int type);
    bool loadShader(unsigned int programId, const char* pShader, int type);
private:

	bool compileShader(const char* pShader, unsigned int shaderId);

	bool linkProgram(unsigned int programId, unsigned int shaderId);

	void deleteShader(unsigned int shaderId);

	bool readShaderFile(const std::string& fileName, std::string& value);
};

#endif
