aboutsummaryrefslogtreecommitdiff
path: root/apps/openmb/renderer/Shader.hpp
blob: 260e67e15145ffa14cadc2396f65274097c84cea (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
#pragma once

#include <glm/glm.hpp>
#include <string>

namespace renderer {
class Shader {
  public:
    Shader();
    ~Shader();

    bool fromSource( const std::string& vertexSrc, const std::string& fragmentSrc );
    bool fromFiles( const std::string& vertexPath, const std::string& fragmentPath );

    void use() const;

    unsigned int id() const;

    void setInt( const std::string& name, int value ) const;
    void setFloat( const std::string& name, float value ) const;
    void setVec3( const std::string& name, const glm::vec3& v ) const;
    void setVec2( const std::string& name, const glm::vec2& v ) const;
    void setMat4( const std::string& name, const glm::mat4& m ) const;

  private:
    unsigned int mID;
    bool         compileShader( const char* vSrc, const char* fSrc );
    std::string  readFile( const std::string& path ) const;
};

}   // namespace renderer