]> git.tdb.fi Git - libs/gl.git/blobdiff - source/program.h
Drop Id tags and copyright notices from files
[libs/gl.git] / source / program.h
index af249edefa2066c29bcf23e7c6f643ddd7d6c95c..b875ec79f089f28e6ec629cb426ee354d9d674b5 100644 (file)
@@ -1,76 +1,94 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #ifndef MSP_GL_PROGRAM_H_
 #define MSP_GL_PROGRAM_H_
 
 #include <list>
 #include <string>
-#include <GL/gl.h>
-#include <msp/datafile/loader.h>
-#include "types.h"
+#include <msp/datafile/objectloader.h>
+#include "bindable.h"
+#include "gl.h"
 
 namespace Msp {
 namespace GL {
 
 class Shader;
 
-class Program
+class Program: public Bindable<Program>
 {
-private:
-       uint 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 &);
-               ~Loader();
 
        private:
-               void vertex_shader(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;
        };
 
+       struct UniformInfo
+       {
+               std::string name;
+               int location;
+               int size;
+               GLenum type;
+       };
+
+private:
+       unsigned id;
+       std::list<Shader *> shaders;
+       bool del_shaders;
+       bool linked;
+       std::map<std::string, UniformInfo> uniforms;
+
+public:
        Program();
+       Program(const StandardFeatures &);
        Program(const std::string &, const std::string &);
+private:
+       void init();
+public:
        virtual ~Program();
 
        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(int, const std::string &);
-       bool link();
-       int get_param(GLenum param) const;
-       bool get_linked() const { return linked; }
+       void bind_attribute(unsigned, const std::string &);
+       void link();
+       bool is_linked() const { return linked; }
        std::string get_info_log() const;
-       void bind();
+       void bind() const;
        int get_uniform_location(const std::string &) const;
-       void uniform(int, int);
-       void uniform(int, float);
-       void uniform(int, float, float);
-       void uniform(int, float, float, float);
-       void uniform(int, float, float, float, float);
-       void uniform4(int, const float *);
-       void uniform_matrix4(int, const float *);
 
        static void unbind();
-
-private:
-       void maybe_bind();
 };
 
 } // namespace GL