]> git.tdb.fi Git - libs/gl.git/blobdiff - source/vertexarray.cpp
Add an asynchronous update interface to Bufferable
[libs/gl.git] / source / vertexarray.cpp
index e8fa36a030bf5991a89bf4ed8f79944543ced413..3848109973c9dca9c8c49c830ebfa10e0285c6e9 100644 (file)
@@ -103,11 +103,6 @@ unsigned VertexArray::get_data_size() const
        return data.size()*sizeof(float);
 }
 
-void VertexArray::upload_data() const
-{
-       get_buffer()->sub_data(get_offset(), get_data_size(), &data[0]);
-}
-
 void VertexArray::apply() const
 {
        if(format.empty())
@@ -125,19 +120,13 @@ void VertexArray::apply() const
                return;
 
        Buffer *vbuf = get_buffer();
-       if(vbuf)
-       {
-               vbuf->bind_to(ARRAY_BUFFER);
-               if(dirty)
-                       update_buffer();
-       }
+       Bind _bind_vbuf(vbuf, ARRAY_BUFFER);
+       if(vbuf && dirty)
+               update_buffer();
 
        const float *base = (vbuf ? reinterpret_cast<float *>(get_offset()) : &data[0]);
        unsigned stride_bytes = stride*sizeof(float);
        apply_arrays(&arrays, (old ? &old->arrays : 0), base, stride_bytes);
-
-       if(vbuf)
-               Buffer::unbind_from(ARRAY_BUFFER);
 }
 
 void VertexArray::apply_arrays(const vector<Array> *arrays, const vector<Array> *old_arrays, const float *base, unsigned stride_bytes)