]> git.tdb.fi Git - libs/gl.git/blobdiff - source/program.h
Make the compiler shut up about a signed/unsigned mismatch
[libs/gl.git] / source / program.h
index af506fe8c57b1128a5354e1515c20059bcccdb1e..1e41e84423f8680ba787a83d8ecea5c45d1bc7c7 100644 (file)
@@ -11,6 +11,7 @@ Distributed under the LGPL
 #include <list>
 #include <string>
 #include <msp/datafile/objectloader.h>
+#include "bindable.h"
 #include "gl.h"
 
 namespace Msp {
@@ -18,16 +19,8 @@ namespace GL {
 
 class Shader;
 
-class Program
+class Program: public Bindable<Program>
 {
-private:
-       unsigned id;
-       std::list<Shader *> shaders;
-       bool del_shaders;
-       bool linked;
-
-       static const Program *cur_prog;
-
 public:
        class Loader: public DataFile::ObjectLoader<Program>
        {
@@ -35,13 +28,43 @@ public:
                Loader(Program &);
 
        private:
-               void vertex_shader(const std::string &);
-               void fragment_shader(const std::string &);
-               void attribute(unsigned, const std::string &);
                virtual void finish();
+
+               void attribute(unsigned, const std::string &);
+               void fragment_shader(const std::string &);
+               void standard();
+               void vertex_shader(const std::string &);
        };
 
+       struct StandardFeatures
+       {
+               class Loader: public DataFile::ObjectLoader<StandardFeatures>
+               {
+               public:
+                       Loader(StandardFeatures &);
+               };
+
+               bool texture;
+               bool material;
+               bool lighting;
+               bool specular;
+               bool normalmap;
+               bool shadow;
+
+               StandardFeatures();
+
+               std::string create_flags() const;
+       };
+
+private:
+       unsigned id;
+       std::list<Shader *> shaders;
+       bool del_shaders;
+       bool linked;
+
+public:
        Program();
+       Program(const StandardFeatures &);
        Program(const std::string &, const std::string &);
 private:
        void init();
@@ -50,6 +73,10 @@ public:
 
        void attach_shader(Shader &shader);
        void detach_shader(Shader &shader);
+       void add_standard_shaders(const StandardFeatures &);
+private:
+       static std::string process_standard_source(const char **, const std::string &);
+public:
        const std::list<Shader *> &get_shaders() const { return shaders; }
        void set_del_shaders(bool);
        void bind_attribute(unsigned, const std::string &);
@@ -61,9 +88,6 @@ public:
        int get_uniform_location(const std::string &) const;
 
        static void unbind();
-
-private:
-       void maybe_bind();
 };
 
 } // namespace GL