void VertexArray::use_vertex_buffer()
{
- if(vbuf) return;
+ if(vbuf && own_vbuf)
+ return;
vbuf=new VertexBuffer();
own_vbuf=true;
+
update_data();
}
void VertexArray::use_vertex_buffer(VertexBuffer *b)
{
- if(vbuf) return;
-
+ if(own_vbuf)
+ delete vbuf;
vbuf=b;
+ own_vbuf=false;
+
update_data();
}
RefPtr<VertexArrayBuilder> VertexArray::modify()
{
- return new VertexArrayBuilder(*this, data);
+ return new VertexArrayBuilder(*this);
}
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();
}
/**
void VertexArray::update_data()
{
if(vbuf)
+ {
vbuf->data(data.size()*sizeof(float), &data[0]);
+ VertexBuffer::unbind();
+ }
}
void VertexArray::set_array(unsigned array, unsigned bit, unsigned mask) const
VertexArray::Loader::Loader(VertexArray &a):
- VertexArrayBuilder(a, a.data)
+ VertexArrayBuilder(a)
{
add("vertex2", static_cast<void (Loader::*)(float, float)>(&Loader::vertex));
add("vertex3", static_cast<void (Loader::*)(float, float, float)>(&Loader::vertex));