]> git.tdb.fi Git - libs/gl.git/blobdiff - source/renderpass.h
Use texture unit numbers instead of slot names in RenderPass
[libs/gl.git] / source / renderpass.h
index e2ea4c97175eb6a62e14bfa6ec636a4c63b12b1d..10960b3f37cb1b082d0cf26d20404514297982b8 100644 (file)
@@ -8,6 +8,7 @@ Distributed under the LGPL
 #ifndef MSP_GL_RENDERPASS_H_
 #define MSP_GL_RENDERPASS_H_
 
+#include <msp/core/refptr.h>
 #include <msp/datafile/objectloader.h>
 #include "bindable.h"
 
@@ -36,30 +37,35 @@ public:
                void init();
                virtual void finish();
                void material();
-               void shader(const std::string &);
-               void texture(const std::string &);
+               void material(const std::string &);
+               void texunit(unsigned);
                void uniforms();
        };
 
 private:
        struct TextureSlot
        {
-               class Loader: public DataFile::ObjectLoader<TextureSlot>
+               class Loader: public DataFile::CollectionObjectLoader<TextureSlot>
                {
                public:
                        Loader(TextureSlot &);
+                       Loader(TextureSlot &, Collection &);
+
+               private:
+                       void init();
+                       void texture(const std::string &);
+                       void texture2d();
                };
 
-               const Texture *texture;
-               std::string name;
+               unsigned index;
+               RefPtr<const Texture> texture;
 
-               TextureSlot(const Texture *);
+               TextureSlot(unsigned);
        };
 
        Program *shprog;
        ProgramData *shdata;
-       bool own_material;
-       const Material *material;
+       RefPtr<const Material> material;
        std::vector<TextureSlot> textures;
 
        RenderPass &operator=(const RenderPass &);
@@ -69,8 +75,7 @@ public:
        ~RenderPass();
 
        void set_material(const Material *);
-       unsigned get_texture_index(const std::string &) const;
-       void set_texture(const std::string &, const Texture *);
+       void set_texture(unsigned, const Texture *);
 
        void bind() const;