Hello there.
I’m trying to replicate this strategy in OpenGL, but have no clear idea how.
//transfer transformed vertices to GPU (before drawing)
VertexPositionColorTexture *pData = NULL; //destination to copy vertices into
if (SUCCEEDED(m_VB->Lock( 0, 0, ( void** )&pData, m_vertexBufferPosition == 0 ? D3DLOCK_DISCARD : D3DLOCK_NOOVERWRITE )))
{
//move pointer to unused section of vertex buffer
pData += m_vertexBufferPosition * VERTICES_PER_SPRITE;
for (int i = 0; i < batchSize; i++)
{
sprites[i]->FillVertices(pData, i * VERTICES_PER_SPRITE);
}
m_VB->Unlock();
}
So far I’ve found glMapBuffer and glMapBufferRange (similar to lock operation in directx), but I’m not sure if I understand them right.
When I lock the buffer in DX with flag D3DLOCK_DISCARD I’m sure that if the data in a vertex buffer is currently being used - I will get a new chunk of memory (while GPU keeps using old memory for drawing behind the scenes), will the same happen with glMapBuffer? or should I do it myself? and if so how I should do it? Talking about D3DLOCK_NOOVERWRITE I see it as just mapping the buffer in the range it is not being used, so here glMapBufferRange might work perfectly for the situation.
What do you think?
How would you go about it?
Thanks for any help.