summaryrefslogtreecommitdiff
path: root/shader.h
blob: 85a7d587ac50a50ab071244d17236d2ac7bc54ca (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
#ifndef SHADER_INCLUDED_H
#define SHADER_INCLUDED_H

#include <GL/glew.h>
#include <array>
#include <string>

class Camera;
class Transform;

class Shader {
public:
	explicit Shader(const std::string & fileName);
	virtual ~Shader();
	void operator=(const Shader &) = delete;
	Shader(const Shader &) = delete;

	void Bind() const;
	void Update(const Transform & transform, const Camera & camera) const;

private:
	static constexpr unsigned int NUM_SHADERS = 2;
	static constexpr unsigned int NUM_UNIFORMS = 3;

	static void CheckShaderError(GLuint shader, GLuint flag, bool isProgram, const std::string & errorMessage);
	static GLuint CreateShader(const GLchar * text, GLint len, unsigned int type);

	GLuint m_program;
	std::array<GLuint, NUM_SHADERS> m_shaders;
	std::array<GLint, NUM_UNIFORMS> m_uniforms;
};

#endif