terrain-gen/src/shader.h

44 lines
1.0 KiB
C++

#ifndef SHADER_H
#define SHADER_H
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <QOpenGLFunctions_4_5_Core>
#include <QRegularExpression>
#include "config.h"
class Shader: protected QOpenGLFunctions_4_5_Core
{
private:
std::map<std::string, GLint> m_uniformLocationMap;
std::map<std::string, GLint> m_attributeLocationMap;
GLuint m_programId;
std::set<GLuint> m_shaders;
void loadShader(std::string path, GLenum shaderType);
bool checkCompilationStatus(GLuint shader);
void logCompilationError(GLuint shader);
void linkProgram();
bool checkLinkStatus();
void logLinkError();
std::string loadSource(std::string path);
public:
Shader(std::string name, bool useGeom);
~Shader();
void bind();
void release();
GLint uniformLocation(std::string location);
GLint attributeLocation(std::string location);
void setTexture(std::string location, GLuint slot, GLuint textureId, GLenum target = GL_TEXTURE_2D);
};
#endif // SHADER_H