BlockGame/gl/Shader.h

46 lines
1.1 KiB
C
Raw Normal View History

2022-02-05 20:44:31 +00:00
//
// 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);
/**
* 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;
std::string readFile(std::string path);
void Bind() const;
unsigned getHandle() const;
unsigned getUniformHandle(std::string name);
};
#endif //OPENGLTEST_SHADER_H