#ifndef BLUECORE_SHADER_MANAGER_H
#define BLUECORE_SHADER_MANAGER_H

#include <map>
#include <string>

#include "GL/glew.h"

#include "Utilities/Referenced.h"

#include "TextureManager.h"
#include "RenderWindow.h"

namespace BlueCore {

typedef GLhandleARB ShaderProgram;
typedef GLhandleARB VertexShader;
typedef GLhandleARB FragmentShader;

class ShaderManager : public Referenced, public sigslot::has_slots<>
{
    typedef std::map<std::string, VertexShader> VertexShaderMap;
    typedef std::map<std::string, FragmentShader> FragmentShaderMap;
    typedef std::map<std::string, ShaderProgram> ShaderProgramMap;

    VertexShaderMap vertex_shader;
    FragmentShaderMap fragment_shader;
    ShaderProgramMap shader_programs;

    VertexShader loadVertexShader(const std::string &name);

    FragmentShader loadFragmentShader(const std::string &name);

    bool _usingShaders;

    ref_ptr<RenderWindow> _RenderWindow;
 
    void shutdown();
    
    void WindowCloseSlot();
    
  public:

    ShaderManager (RenderWindow* renderwindow);

    virtual ~ShaderManager();

    bool usingShaders();

    ShaderProgram loadShaderProgram(const std::string &name);

    void useShaderProgram(ShaderProgram shader_program);

    void useTexture(ShaderProgram shader_program, unsigned int texture,
        const std::string &name);
/*
    void useTangentBuffer(ShaderProgram shader_program,
        TangentBuffer *tangent_buffer, const std::string &name);

    void disableTangentBuffer(ShaderProgram shader_program,
        const std::string &name);*/
};

} // namespace BlueCore

#endif
