blob: 75a24c6d7141c9a5a5d744d26de8f726a631727d (
plain)
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
|
/** ---------------------------------------------------------------------------
* -*- c++ -*-
* @file: shader.h
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
#pragma once
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <string>
namespace yage
{
class Shader
{
public:
Shader(std::string const &vertex_path, std::string const &fragment_path);
Shader(const Shader &) = delete;
Shader(Shader &&) = delete;
~Shader();
Shader &operator=(const Shader &) = delete;
Shader &operator=(Shader &&) = delete;
/// compiles vertex and fragment shader
void use() const;
/// set uniforms of different type
void setUniform(std::string const &name, int value) const;
void setUniform(std::string const &name, float value) const;
void setUniform(std::string const &name, const glm::mat4 &matrix) const;
private:
/// compiled shader program id
GLuint program_id_ = 0;
GLint getUniformLocation(std::string const &uniform_name) const;
void errorCheck(GLuint shader, std::string const &shader_type) const;
};
} // namespace yage
|