/* shader.hpp: Handles compiling shaders.
*
* Copyright (C) 2014: Dalton Nell, Slop Contributors (https://github.com/naelstrof/slop/graphs/contributors).
*
* This file is part of Slop.
*
* Slop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Slop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Slop. If not, see .
*/
#ifndef N_SHADER_H_
#define N_SHADER_H_
#include
#include
#include
#include
#include "gl_core_3_3.h"
#include
#include
#include
#include
#include "resource.hpp"
class Shader {
public:
Shader( std::string vert, std::string frag, bool file = true );
~Shader();
unsigned int getProgram();
void bind();
void unbind();
void setParameter( std::string name, int foo );
void setParameter( std::string name, float foo );
void setParameter( std::string name, glm::mat4& foo );
void setParameter( std::string name, glm::vec4 foo );
void setParameter( std::string name, glm::vec2 foo );
void setAttribute( std::string name, unsigned int buffer, unsigned int stepsize );
private:
void loadFromFile( std::string vert, std::string frag );
void loadFromMemory( std::string vert, std::string frag );
std::vector activeAttributes;
unsigned int getUniformLocation( std::string );
int compile( unsigned int shader, std::string& error );
int link( unsigned int vert, unsigned int frag, std::string& error );
unsigned int program;
};
#endif // N_SHADER_H_