From 1c7fe8c51803529f4d52d8f265515db4b01d8dbf Mon Sep 17 00:00:00 2001 From: vlj Date: Thu, 14 Aug 2014 16:14:36 +0200 Subject: [PATCH] Use mapbuffer to modify animated mesh buffer content. --- src/graphics/stkanimatedmesh.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp index 6ae55c0a7..c49f02361 100644 --- a/src/graphics/stkanimatedmesh.cpp +++ b/src/graphics/stkanimatedmesh.cpp @@ -117,8 +117,11 @@ void STKAnimatedMesh::render() if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS || irr_driver->getPhase() == TRANSPARENT_PASS || irr_driver->getPhase() == SHADOW_PASS) { glBindVertexArray(0); + size_t size = mb->getVertexCount() * GLmeshes[i].Stride; glBindBuffer(GL_ARRAY_BUFFER, getVBO(mb->getVertexType())); - glBufferSubData(GL_ARRAY_BUFFER, GLmeshes[i].vaoBaseVertex * GLmeshes[i].Stride, mb->getVertexCount() * GLmeshes[i].Stride, mb->getVertices()); + void * buf = glMapBufferRange(GL_ARRAY_BUFFER, GLmeshes[i].vaoBaseVertex * GLmeshes[i].Stride, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT); + memcpy(buf, mb->getVertices(), size); + glUnmapBuffer(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, 0); } }