]> git.tdb.fi Git - libs/gl.git/blob - source/program.h
Get rid of the typedefs for fundamental types
[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 "gl.h"
15
16 namespace Msp {
17 namespace GL {
18
19 class Shader;
20
21 class Program
22 {
23 private:
24         unsigned id;
25         std::list<Shader *> shaders;
26         bool del_shaders;
27         bool linked;
28
29         static const Program *cur_prog;
30
31 public:
32         class Loader: public DataFile::ObjectLoader<Program>
33         {
34         public:
35                 Loader(Program &);
36
37         private:
38                 void vertex_shader(const std::string &);
39                 void fragment_shader(const std::string &);
40                 void attribute(unsigned, const std::string &);
41                 virtual void finish();
42         };
43
44         Program();
45         Program(const std::string &, const std::string &);
46 private:
47         void init();
48 public:
49         virtual ~Program();
50
51         void attach_shader(Shader &shader);
52         void detach_shader(Shader &shader);
53         const std::list<Shader *> &get_shaders() const { return shaders; }
54         void set_del_shaders(bool);
55         void bind_attribute(unsigned, const std::string &);
56         void link();
57         int get_param(GLenum param) const;
58         bool get_linked() const { return linked; }
59         std::string get_info_log() const;
60         void bind() const;
61         int get_uniform_location(const std::string &) const;
62
63         static void unbind();
64
65 private:
66         void maybe_bind();
67 };
68
69 } // namespace GL
70 } // namespace Msp
71
72 #endif