]> git.tdb.fi Git - libs/gl.git/blobdiff - source/program.h
Rework Bind and enable it to restore the old binding
[libs/gl.git] / source / program.h
index fde4d85439a2cfe9e7cb82a62aebd965f111d082..63d43e0f800f65b9ac58b7df6017c6bf7b51588f 100644 (file)
@@ -10,38 +10,33 @@ Distributed under the LGPL
 
 #include <list>
 #include <string>
-#include <msp/datafile/loader.h>
+#include <msp/datafile/objectloader.h>
+#include "bindable.h"
 #include "gl.h"
-#include "types.h"
 
 namespace Msp {
 namespace GL {
 
 class Shader;
 
-class Program
+class Program: public Bindable<Program>
 {
 private:
-       uint id;
+       unsigned id;
        std::list<Shader *> shaders;
        bool del_shaders;
        bool linked;
 
-       static Program *cur_prog;
-
 public:
-       class Loader: public DataFile::Loader
+       class Loader: public DataFile::ObjectLoader<Program>
        {
-       private:
-               Program &prog;
-
        public:
                Loader(Program &);
 
        private:
                void vertex_shader(const std::string &);
                void fragment_shader(const std::string &);
-               void attribute(uint, const std::string &);
+               void attribute(unsigned, const std::string &);
                virtual void finish();
        };
 
@@ -56,18 +51,15 @@ public:
        void detach_shader(Shader &shader);
        const std::list<Shader *> &get_shaders() const { return shaders; }
        void set_del_shaders(bool);
-       void bind_attribute(uint, const std::string &);
+       void bind_attribute(unsigned, const std::string &);
        void link();
        int get_param(GLenum param) const;
        bool get_linked() const { return linked; }
        std::string get_info_log() const;
-       void bind();
+       void bind() const;
        int get_uniform_location(const std::string &) const;
 
        static void unbind();
-
-private:
-       void maybe_bind();
 };
 
 } // namespace GL