aboutsummaryrefslogtreecommitdiff
path: root/shader.h
blob: feb595271ce454df0934266f57178186ec3a1c5a (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
#ifndef SHADER_H
#define SHADER_H

#include <glad/gl.h>

class Shader
{
public:
    Shader(const char *vertexSrc, const char *fragmentSrc, const char *geometrySrc = nullptr);
    ~Shader();

    GLuint program() const { return m_program; }

    GLint uniformLocation(const char *name) const;

    void setUniform(GLint location, GLint value) const;
    void setUniform(GLint location, GLfloat value) const;
    void setUniform(GLint location, GLfloat mat[4][4]) const;
    void setUniform1dArray(GLint location, const GLfloat *values, int count) const;
    void setUniform2dArray(GLint location, const GLfloat *values, int count) const;
    void setUniform3dArray(GLint location, const GLfloat *values, int count) const;

    void setUniform(const char *name, GLint value) const;
    void setUniform(const char *name, GLfloat value) const;
    void setUniform(const char *name, GLfloat mat[4][4]) const;
    void setUniform1dArray(const char *name, const GLfloat *values, int count) const;
    void setUniform2dArray(const char *name, const GLfloat *values, int count) const;
    void setUniform3dArray(const char *name, const GLfloat *values, int count) const;

    void use() const;
    void release() const;

private:
    GLuint m_program;
};

#endif // SHADER_H