X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fvertexarray.cpp;h=38d490c05e8758511da2d0a92a2fc7ef5ca0e29d;hp=6da0f9c0d44812ad6294d769200af558d5532bf0;hb=d1800d7ea80290f4913d0203241cef1409656522;hpb=a80b074c70ec991f27114efd13686038cf42c493 diff --git a/source/vertexarray.cpp b/source/vertexarray.cpp index 6da0f9c0..38d490c0 100644 --- a/source/vertexarray.cpp +++ b/source/vertexarray.cpp @@ -48,6 +48,11 @@ void VertexArray::use_vertex_buffer(VertexBuffer *b) update_data(); } +void VertexArray::reserve(unsigned n) +{ + data.reserve(n*stride); +} + void VertexArray::clear() { data.clear(); @@ -78,29 +83,30 @@ void VertexArray::apply() const const float *base=vbuf?0:&data[0]; uint offset=0; uint found=0; + uint bpv=stride*sizeof(float); for(uint fmt=format; fmt; fmt>>=4) { - uint size=(fmt&3)+1; + uint sz=(fmt&3)+1; switch(fmt&12) { case 0: - glVertexPointer(size, GL_FLOAT, stride, base+offset); + glVertexPointer(sz, GL_FLOAT, bpv, base+offset); break; case 4: - glNormalPointer(GL_FLOAT, stride, base+offset); + glNormalPointer(GL_FLOAT, bpv, base+offset); break; case 8: - glTexCoordPointer(size, GL_FLOAT, stride, base+offset); + glTexCoordPointer(sz, GL_FLOAT, bpv, base+offset); break; case 12: - if(size==1) - glColorPointer(4, GL_UNSIGNED_BYTE, stride, base+offset); + if(sz==1) + glColorPointer(4, GL_UNSIGNED_BYTE, bpv, base+offset); else - glColorPointer(size, GL_FLOAT, stride, base+offset); + glColorPointer(sz, GL_FLOAT, bpv, base+offset); break; } found|=1<<((fmt&12)>>2); - offset+=size; + offset+=sz; } set_array(GL_VERTEX_ARRAY, found&1, 1);