forked from Mirrorlandia_minetest/irrlicht
Remove extra memcpy in ogles2 driver
This commit is contained in:
parent
6928c7eb6f
commit
51ae495c4a
@ -441,9 +441,8 @@ COGLES2Driver::~COGLES2Driver()
|
|||||||
const E_VERTEX_TYPE vType = mb->getVertexType();
|
const E_VERTEX_TYPE vType = mb->getVertexType();
|
||||||
const u32 vertexSize = getVertexPitchFromType(vType);
|
const u32 vertexSize = getVertexPitchFromType(vType);
|
||||||
|
|
||||||
//buffer vertex data, and convert colours...
|
const void *buffer = vertices;
|
||||||
core::array<c8> buffer(vertexSize * vertexCount);
|
size_t bufferSize = vertexSize * vertexCount;
|
||||||
memcpy(buffer.pointer(), vertices, vertexSize * vertexCount);
|
|
||||||
|
|
||||||
//get or create buffer
|
//get or create buffer
|
||||||
bool newBuffer = false;
|
bool newBuffer = false;
|
||||||
@ -453,7 +452,7 @@ COGLES2Driver::~COGLES2Driver()
|
|||||||
if (!HWBuffer->vbo_verticesID) return false;
|
if (!HWBuffer->vbo_verticesID) return false;
|
||||||
newBuffer = true;
|
newBuffer = true;
|
||||||
}
|
}
|
||||||
else if (HWBuffer->vbo_verticesSize < vertexCount*vertexSize)
|
else if (HWBuffer->vbo_verticesSize < bufferSize)
|
||||||
{
|
{
|
||||||
newBuffer = true;
|
newBuffer = true;
|
||||||
}
|
}
|
||||||
@ -462,15 +461,15 @@ COGLES2Driver::~COGLES2Driver()
|
|||||||
|
|
||||||
// copy data to graphics card
|
// copy data to graphics card
|
||||||
if (!newBuffer)
|
if (!newBuffer)
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, vertexCount * vertexSize, buffer.const_pointer());
|
glBufferSubData(GL_ARRAY_BUFFER, 0, bufferSize, buffer);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HWBuffer->vbo_verticesSize = vertexCount * vertexSize;
|
HWBuffer->vbo_verticesSize = bufferSize;
|
||||||
|
|
||||||
if (HWBuffer->Mapped_Vertex == scene::EHM_STATIC)
|
if (HWBuffer->Mapped_Vertex == scene::EHM_STATIC)
|
||||||
glBufferData(GL_ARRAY_BUFFER, vertexCount * vertexSize, buffer.const_pointer(), GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_STATIC_DRAW);
|
||||||
else
|
else
|
||||||
glBufferData(GL_ARRAY_BUFFER, vertexCount * vertexSize, buffer.const_pointer(), GL_DYNAMIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_DYNAMIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user