BlockGame/gl/Shader.h

54 lines
1.2 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>
2022-02-10 17:24:56 +00:00
#include <stdexcept>
#include <glm/ext/matrix_float4x4.hpp>
#include <iostream>
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
2022-02-05 20:44:31 +00:00
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);
2022-02-06 21:53:29 +00:00
2022-02-05 20:44:31 +00:00
std::string readFile(std::string path);
void Bind() const;
unsigned getHandle() const;
unsigned getUniformHandle(std::string name);
2022-02-06 21:53:29 +00:00
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;
2022-02-05 20:44:31 +00:00
};
#endif //OPENGLTEST_SHADER_H