]> git.tdb.fi Git - libs/gl.git/blobdiff - source/program.h
Require import module names to be identifiers
[libs/gl.git] / source / program.h
index 4feb862d29483cf99359e52750d671726e1175ef..d2032a5cd46843e36def08c91f8a95d699025bd1 100644 (file)
@@ -1,8 +1,8 @@
 #ifndef MSP_GL_PROGRAM_H_
 #define MSP_GL_PROGRAM_H_
 
-#include <list>
 #include <string>
+#include <vector>
 #include <msp/datafile/objectloader.h>
 #include "bindable.h"
 #include "gl.h"
@@ -31,6 +31,7 @@ public:
 
                void attribute(unsigned, const std::string &);
                void fragment_shader(const std::string &);
+               void geometry_shader(const std::string &);
                void standard();
                void vertex_shader(const std::string &);
        };
@@ -58,9 +59,18 @@ public:
                LayoutHash layout_hash;
        };
 
-       typedef std::list<Shader *> ShaderList;
+       struct AttributeInfo
+       {
+               std::string name;
+               unsigned location;
+               unsigned size;
+               GLenum type;
+       };
+
+       typedef std::vector<Shader *> ShaderList;
        typedef std::map<std::string, UniformInfo> UniformMap;
        typedef std::map<std::string, UniformBlockInfo> UniformBlockMap;
+       typedef std::map<std::string, AttributeInfo> AttributeMap;
 
 private:
        unsigned id;
@@ -70,6 +80,7 @@ private:
        UniformBlockMap uniform_blocks;
        UniformMap uniforms;
        LayoutHash uniform_layout_hash;
+       AttributeMap attributes;
        bool legacy_vars;
 
 public:
@@ -79,6 +90,9 @@ public:
        /// Constructs a Program with standard features.
        Program(const ProgramBuilder::StandardFeatures &);
 
+       /// Constructs a Program from unified source code using ProgramCompiler.
+       Program(const std::string &);
+
        /// Constructs a Program from vertex and fragment shader source code.
        Program(const std::string &, const std::string &);
 
@@ -90,7 +104,7 @@ public:
        void attach_shader(Shader &shader);
        void attach_shader_owned(Shader *shader);
        void detach_shader(Shader &shader);
-       const ShaderList &get_shaders() const { return shaders; }
+       const ShaderList &get_attached_shaders() const { return shaders; }
 
        void bind_attribute(unsigned, const std::string &);
        void bind_attribute(VertexComponent, const std::string &);
@@ -98,6 +112,9 @@ public:
 
        void link();
 private:
+       void query_uniforms();
+       void query_uniform_blocks(const std::vector<UniformInfo *> &);
+       void query_attributes();
        static LayoutHash compute_layout_hash(const std::vector<const UniformInfo *> &);
        static bool uniform_location_compare(const UniformInfo *, const UniformInfo *);
 public:
@@ -110,6 +127,9 @@ public:
        const UniformMap &get_uniforms() const { return uniforms; }
        const UniformInfo &get_uniform_info(const std::string &) const;
        int get_uniform_location(const std::string &) const;
+       const AttributeMap &get_attributes() const { return attributes; }
+       const AttributeInfo &get_attribute_info(const std::string &) const;
+       int get_attribute_location(const std::string &) const;
 
        bool uses_legacy_variables() const { return legacy_vars; }