void VAOManager::append(scene::IMeshBuffer *mb, VTXTYPE tp, RenderInfo* ri) { size_t old_vtx_cnt = last_vertex[tp]; size_t old_idx_cnt = last_index[tp]; regenerateBuffer(tp, old_vtx_cnt + mb->getVertexCount(), old_idx_cnt + mb->getIndexCount()); #if !defined(USE_GLES2) if (CVS->supportsAsyncInstanceUpload()) { void *tmp = (char*)VBOPtr[tp] + old_vtx_cnt * getVertexPitch(tp); memcpy(tmp, mb->getVertices(), mb->getVertexCount() * getVertexPitch(tp)); } else #endif { glBindBuffer(GL_ARRAY_BUFFER, vbo[tp]); glBufferSubData(GL_ARRAY_BUFFER, old_vtx_cnt * getVertexPitch(tp), mb->getVertexCount() * getVertexPitch(tp), mb->getVertices()); } #if !defined(USE_GLES2) if (CVS->supportsAsyncInstanceUpload()) { void *tmp = (char*)IBOPtr[tp] + old_idx_cnt * sizeof(u16); memcpy(tmp, mb->getIndices(), mb->getIndexCount() * sizeof(u16)); } else #endif { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo[tp]); glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, old_idx_cnt * sizeof(u16), mb->getIndexCount() * sizeof(u16), mb->getIndices()); } std::pair<scene::IMeshBuffer*, RenderInfo*> key(mb, ri); mappedBaseVertex[tp][key] = old_vtx_cnt; mappedBaseIndex[tp][key] = old_idx_cnt * sizeof(u16); }
void VAOManager::append(scene::IMeshBuffer *mb, VTXTYPE tp) { size_t old_vtx_cnt = last_vertex[tp]; size_t old_idx_cnt = last_index[tp]; regenerateBuffer(tp, old_vtx_cnt + mb->getVertexCount(), old_idx_cnt + mb->getIndexCount()); if (CVS->supportsAsyncInstanceUpload()) { void *tmp = (char*)VBOPtr[tp] + old_vtx_cnt * getVertexPitch(tp); memcpy(tmp, mb->getVertices(), mb->getVertexCount() * getVertexPitch(tp)); } else { glBindBuffer(GL_ARRAY_BUFFER, vbo[tp]); glBufferSubData(GL_ARRAY_BUFFER, old_vtx_cnt * getVertexPitch(tp), mb->getVertexCount() * getVertexPitch(tp), mb->getVertices()); } if (CVS->supportsAsyncInstanceUpload()) { void *tmp = (char*)IBOPtr[tp] + old_idx_cnt * sizeof(u16); memcpy(tmp, mb->getIndices(), mb->getIndexCount() * sizeof(u16)); } else { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo[tp]); glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, old_idx_cnt * sizeof(u16), mb->getIndexCount() * sizeof(u16), mb->getIndices()); } mappedBaseVertex[tp][mb] = old_vtx_cnt; mappedBaseIndex[tp][mb] = old_idx_cnt * sizeof(u16); }