Level H Engine
Shader.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <unordered_map>
5 #include "GL/glew.h"
6 
10 class Shader
11 {
12 public:
18  Shader(std::string vertexShaderFileName, std::string fragmentShaderFileName);
19 
23  ~Shader();
24 
29  GLuint getShaderProgram();
30 
35  void initaliseUniform(std::string uniformID);
36 
42  GLint getUniform(std::string uniformID);
43 
44 private:
46  GLuint shaderProgram;
48  std::unordered_map<std::string, GLint> uniforms;
49 
55  bool Shader::CheckShaderCompiled(GLint shader);
56 
62  void initaliseShader(std::string shaderFileName, char shaderType);
63 };
GLuint getShaderProgram()
Returns the shader program.
Definition: Shader.cpp:116
~Shader()
Destructs the Shader Object deleting the Shader Object from memory.
Definition: Shader.cpp:40
void initaliseShader(std::string shaderFileName, char shaderType)
Initialise a shader.
Definition: Shader.cpp:44
void initaliseUniform(std::string uniformID)
Initalise a uniform for the shader.
Definition: Shader.cpp:122
bool CheckShaderCompiled(GLint shader)
A function to test if the shader compiled successfully.
Definition: Shader.cpp:90
Creates a Shader from an text file, this can then be used with OpenGL.
Definition: Shader.h:10
std::unordered_map< std::string, GLint > uniforms
The Uniform locations for the shader program.
Definition: Shader.h:48
GLuint shaderProgram
The Shader program of the Shader Object.
Definition: Shader.h:46
GLint getUniform(std::string uniformID)
Returns the requested uniform location.
Definition: Shader.cpp:137
Shader(std::string vertexShaderFileName, std::string fragmentShaderFileName)
Creates a Shader Object using an shader file location and OpenGL.
Definition: Shader.cpp:6