summaryrefslogtreecommitdiffstats
path: root/game/client/program.hh
blob: 4e796fa13f4f9d3efbdb4711c0dc681ab00b33e3 (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
#ifndef CLIENT_PROGRAM_HH
#define CLIENT_PROGRAM_HH 1
#pragma once

struct GL_VariedMacro final {
    std::string name;
    unsigned long line;
    unsigned int value;
};

struct GL_Uniform final {
    std::string name;
    GLint location;
};

class GL_Program final {
public:
    bool setup(std::string_view vpath, std::string_view fpath);
    void destroy(void);
    bool update(void);

    std::size_t add_uniform(std::string_view name);
    void set_variant_vert(unsigned int variant, unsigned int value);
    void set_variant_frag(unsigned int variant, unsigned int value);

public:
    std::string vert_path;
    std::string frag_path;
    std::vector<std::string> vert_source;
    std::vector<std::string> frag_source;
    std::vector<GL_VariedMacro> vert_variants;
    std::vector<GL_VariedMacro> frag_variants;
    std::vector<GL_Uniform> uniforms;
    bool needs_update;
    GLuint handle;
};

#endif // CLIENT_PROGRAM_HH