BlockGame/gl/Shader.h
2022-02-06 22:53:29 +01:00

49 lines
1.1 KiB
C++

//
// Created by lukas on 03.02.22.
//
#ifndef OPENGLTEST_SHADER_H
#define OPENGLTEST_SHADER_H
#include <unordered_map>
#include <string>
class Shader {
private:
unsigned mProgHandle;
std::unordered_map<std::string, unsigned> uniformhandles;
public:
/**
* load the compiled shader pipeline
* @param vertex_file_path path to vertex source file
* @param fragment_file_path path to fragment source file
* @return program id
*/
unsigned int loadShaderFromFile(const std::string vertex_file_path, const std::string geometry_file_path, const std::string fragment_file_path);
unsigned int loadShader(const std::string vertex_src, const std::string geometry_src, const std::string fragment_src);
std::string readFile(std::string path);
void Bind() const;
unsigned getHandle() const;
unsigned getUniformHandle(std::string name);
private:
/**
* comile a specific shader source
* @param source source string
* @param type shader tpye
* @return id of copiled shader
*/
unsigned int compileShader(const char *source, unsigned int type) const;
};
#endif //OPENGLTEST_SHADER_H