]> git.tdb.fi Git - libs/gl.git/blobdiff - source/object.h
Allow copying of Uniforms and ProgramData
[libs/gl.git] / source / object.h
index bf4a05249436f5453ec678a274431958597a61fb..d81c4ade6fa0453aadbd5fd27cb5a212204df36d 100644 (file)
@@ -9,6 +9,7 @@ Distributed under the LGPL
 #define MSP_GL_OBJECT_H_
 
 #include <vector>
+#include "misc.h"
 #include "objectpass.h"
 #include "renderable.h"
 
@@ -22,10 +23,7 @@ class Technique;
 class Texture;
 
 /**
-Stores data for a complete 3D object.  An Object must always have a Mesh, and
-may also have a Technique to determine its appearance.  Textures and material
-specified by the Technique may be overridden.  Simple textured objects are also
-possible without a Technique.
+Stores a Mesh together with a Technique to determine its appearance.
 
 It is possible to use a single Object for rendering multiple identical or
 similar objects.  See class ObjectInstance.
@@ -34,10 +32,8 @@ class Object: public Renderable
 {
 private:
        std::vector<const Mesh *> meshes;
+       bool own_technique;
        const Technique *technique;
-       std::vector<const Texture *> textures;
-       const Texture *main_texture;
-       const Material *material;
 
 public:
        class Loader: public DataFile::CollectionObjectLoader<Object>
@@ -46,13 +42,9 @@ public:
                Loader(Object &, Collection &);
 
        private:
-               virtual void finish();
                void lod_mesh(unsigned, const std::string &);
-               void material_inline();
                void mesh(const std::string &);
-               void shader_texture(const std::string &);
-               void technique(const std::string &);
-               void texture(const std::string &);
+               void technique();
        };
 
        Object();
@@ -81,20 +73,16 @@ public:
        template<typename Iter>
        void render(Iter begin, Iter end, const Tag &tag=Tag()) const
        {
-               if(!can_render(tag))
+               const RenderPass *pass=get_pass(tag);
+               if(!pass)
                        return;
 
-               const ObjectPass *pass=get_pass(tag);
-               setup_render(pass);
+               Bind bind(*pass);
                for(Iter i=begin; i!=end; ++i)
                        render_instance(**i, tag);
-               finish_render(pass);
        }
 private:
-       bool can_render(const Tag &) const;
-       const ObjectPass *get_pass(const Tag &) const;
-       void setup_render(const ObjectPass *) const;
-       void finish_render(const ObjectPass *) const;
+       const RenderPass *get_pass(const Tag &) const;
        void render_instance(const ObjectInstance &, const Tag &) const;
 };