]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/compiler.h
Redesign the way shader programs are loaded
[libs/gl.git] / source / glsl / compiler.h
1 #ifndef MSP_GL_SL_COMPILER_H_
2 #define MSP_GL_SL_COMPILER_H_
3
4 #include <vector>
5 #include "parser.h"
6 #include "syntax.h"
7
8 namespace Msp {
9 namespace GL {
10 namespace SL {
11
12 class Compiler
13 {
14 public:
15         enum Mode
16         {
17                 MODULE,
18                 PROGRAM
19         };
20
21 private:
22         Module *module;
23         std::vector<std::string> imported_names;
24
25 public:
26         Compiler();
27         ~Compiler();
28
29 private:
30         void clear();
31 public:
32         void set_source(const std::string &, const std::string & = "<string>");
33         void load_source(IO::Base &, DataFile::Collection * = 0, const std::string & = "<file>");
34         void load_source(IO::Base &, const std::string &);
35         void compile(Mode);
36
37         std::string get_combined_glsl() const;
38         std::vector<Stage::Type> get_stages() const;
39         std::string get_stage_glsl(Stage::Type) const;
40         const std::map<std::string, unsigned> &get_vertex_attributes() const;
41         const std::map<std::string, unsigned> &get_fragment_outputs() const;
42         const SourceMap &get_source_map() const;
43 private:
44
45         void append_module(Module &, DataFile::Collection *);
46         void append_stage(Stage &);
47         void import(DataFile::Collection *, const std::string &);
48         void generate(Stage &, Mode);
49         bool optimize(Stage &);
50         void finalize(Stage &, Mode);
51         static void inject_block(Block &, const Block &);
52 };
53
54 } // namespace SL
55 } // namespace GL
56 } // namespace Msp
57
58 #endif