]> git.tdb.fi Git - libs/gl.git/blobdiff - source/vertexarray.cpp
Add append() method and and operator[] to VertexArray
[libs/gl.git] / source / vertexarray.cpp
index 0d4fd919cffa8daa210c416414024357a07d9d59..c166e98718338c55bcfb175dde856d7c44e41c74 100644 (file)
@@ -71,11 +71,6 @@ void VertexArray::reset(VertexFormat f)
        stride=get_stride(format);
 }
 
-RefPtr<VertexArrayBuilder> VertexArray::modify()
-{
-       return new VertexArrayBuilder(*this);
-}
-
 void VertexArray::apply() const
 {
        if(format==NODATA)
@@ -118,7 +113,8 @@ void VertexArray::apply() const
        set_array(GL_TEXTURE_COORD_ARRAY, found&4, 4);
        set_array(GL_COLOR_ARRAY, found&8, 8);
 
-       VertexBuffer::unbind();
+       if(vbuf)
+               VertexBuffer::unbind();
 }
 
 /**
@@ -127,7 +123,16 @@ Updates the VertexArray data to the VertexBuffer tied to the array, if any.
 void VertexArray::update_data()
 {
        if(vbuf)
+       {
                vbuf->data(data.size()*sizeof(float), &data[0]);
+               VertexBuffer::unbind();
+       }
+}
+
+float *VertexArray::append()
+{
+       data.insert(data.end(), stride, 0.0f);
+       return &*data.end()-stride;
 }
 
 void VertexArray::set_array(unsigned array, unsigned bit, unsigned mask) const