]> git.tdb.fi Git - libs/gl.git/blob - source/core/module.h
78afcfc9823997161644c1d51e4eb5830a1c008f
[libs/gl.git] / source / core / module.h
1 #ifndef MSP_GL_MODULE_H_
2 #define MSP_GL_MODULE_H_
3
4 #include <string>
5 #include <msp/io/base.h>
6 #include "glsl/compiler.h"
7 #include "glsl/sourcemap.h"
8
9 namespace Msp {
10 namespace GL {
11
12 class Resources;
13
14 class Module
15 {
16 public:
17         enum Format
18         {
19                 GLSL,
20         };
21
22 protected:
23         Module() { }
24 public:
25         virtual ~Module() { }
26
27         virtual Format get_format() const = 0;
28
29         void set_source(const std::string &);
30         void load_source(IO::Base &, Resources *, const std::string &);
31         void load_source(IO::Base &, const std::string &);
32 private:
33         virtual void compile(SL::Compiler &) = 0;
34 };
35
36 class GlslModule: public Module
37 {
38 private:
39         std::string prepared_source;
40         SL::SourceMap source_map;
41
42 public:
43         virtual Format get_format() const { return GLSL; }
44
45 private:
46         virtual void compile(SL::Compiler &);
47
48 public:
49         const std::string &get_prepared_source() const { return prepared_source; }
50         const SL::SourceMap &get_source_map() const { return source_map; }
51 };
52
53 } // namespace GL
54 } // namespace Msp
55
56 #endif