]> git.tdb.fi Git - libs/gl.git/blob - source/program.h
Rework Bind and enable it to restore the old binding
[libs/gl.git] / source / program.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_PROGRAM_H_
9 #define MSP_GL_PROGRAM_H_
10
11 #include <list>
12 #include <string>
13 #include <msp/datafile/objectloader.h>
14 #include "bindable.h"
15 #include "gl.h"
16
17 namespace Msp {
18 namespace GL {
19
20 class Shader;
21
22 class Program: public Bindable<Program>
23 {
24 private:
25         unsigned id;
26         std::list<Shader *> shaders;
27         bool del_shaders;
28         bool linked;
29
30 public:
31         class Loader: public DataFile::ObjectLoader<Program>
32         {
33         public:
34                 Loader(Program &);
35
36         private:
37                 void vertex_shader(const std::string &);
38                 void fragment_shader(const std::string &);
39                 void attribute(unsigned, const std::string &);
40                 virtual void finish();
41         };
42
43         Program();
44         Program(const std::string &, const std::string &);
45 private:
46         void init();
47 public:
48         virtual ~Program();
49
50         void attach_shader(Shader &shader);
51         void detach_shader(Shader &shader);
52         const std::list<Shader *> &get_shaders() const { return shaders; }
53         void set_del_shaders(bool);
54         void bind_attribute(unsigned, const std::string &);
55         void link();
56         int get_param(GLenum param) const;
57         bool get_linked() const { return linked; }
58         std::string get_info_log() const;
59         void bind() const;
60         int get_uniform_location(const std::string &) const;
61
62         static void unbind();
63 };
64
65 } // namespace GL
66 } // namespace Msp
67
68 #endif