X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Finstancearray.h;h=627051f75b123a973ef878546fddd762708afe59;hb=HEAD;hp=ffba39e072c7f35c3ed5d2c3c89cc7ed41b22dcb;hpb=b0059bd068c99dadfc922584911fcb25a21b737b;p=libs%2Fgl.git diff --git a/source/instancearray.h b/source/instancearray.h deleted file mode 100644 index ffba39e0..00000000 --- a/source/instancearray.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef MSP_GL_INSTANCEARRAY_H_ -#define MSP_GL_INSTANCEARRAY_H_ - -#include -#include "programdata.h" -#include "renderable.h" - -namespace Msp { -namespace GL { - -class Buffer; -class Object; -class ObjectInstance; -class VertexArray; -class VertexSetup; - -/** -Renders multiple instances of an Object in an efficient manner. If instanced -rendering is supported, only one draw call per Batch needs to be issued. - -Changing the Mesh of the Object while an InstanceArray exists is not supported. -*/ -class InstanceArray: public Renderable -{ -public: - template - class Instance: public T - { - private: - InstanceArray &array; - unsigned index; - - public: - Instance(const Object &o, InstanceArray &a, unsigned i): T(o), array(a), index(i) { } - - virtual void set_matrix(const Matrix &); - }; - -private: - const Object &object; - std::vector instances; - VertexArray *instance_data; - Buffer *instance_buffer; - VertexSetup *vtx_setup; - unsigned matrix_offset; - -public: - InstanceArray(const Object &); - ~InstanceArray(); - - void set_matrix_attribute(const std::string &); - - template - T &append(); -private: - void append(ObjectInstance *); - void update_instance_matrix(unsigned); -public: - void remove(ObjectInstance &); - - virtual void render(Renderer &, const Tag &) const; -}; - -template -T &InstanceArray::append() -{ - Instance *inst = new Instance(object, *this, instances.size()); - append(inst); - return *inst; -} - -template -void InstanceArray::Instance::set_matrix(const Matrix &m) -{ - T::set_matrix(m); - array.update_instance_matrix(index); -} - -} // namespace GL -} // namespace Msp - -#endif