-
Notifications
You must be signed in to change notification settings - Fork 0
/
shaders.hpp
60 lines (51 loc) · 1.36 KB
/
shaders.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef SHADERS_HPP
#define SHADERS_HPP
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
// GLM
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <string>
#include "logger/logger.hpp"
#include <memory>
namespace shaders {
class Shader
{
public:
using pointer = std::shared_ptr< Shader >;
using raw_poiner = Shader*;
Shader();
void load_vertex_shader( const std::string& body );
void load_fragment_shader( const std::string& body );
std::string read_shader_body( const std::string& filename );
bool create_shader_program();
void use_shaders();
GLuint get_program() const;
operator GLuint()
{
return shader_program;
}
/*
* Load from the shader an uniform
* or raise an error
*/
GLint load_location( const std::string& loc_name );
void enable_light_calculations();
void disable_light_calculations();
void enable_texture_calculations();
void disable_texture_calculations();
private:
GLuint vertex_shader,
fragment_shader,
shader_program;
GLuint light_calc_uniform;
GLuint tex_calc_uniform;
GLchar log_buffer[512];
void load_shader_generic( GLuint& shader_target,
const std::string& body,
GLenum shader_type );
};
}
#endif