Hello!
First of all: I experienced buffer mapping to be a complete pain performance-wise for many graphics cards, as it involves a lot of synchronisation. So may I introduce you to the classic way of updating a vertex buffer?
Initialization:
m_vertexBuffer = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
if (!m_vertexBuffer->create() ||!m_vertexBuffer->bind())
{
// error handling
}
m_vertexBuffer->setUsagePattern(QOpenGLBuffer::DynamicDraw);
m_vertexBuffer->allocate(sizeof(float) * vertexStride * vertexCount);
m_vertexBuffer->release();
Update:
if (m_needsUpdate)
{
m_vertexBuffer->write(0, pointerToVertexData, sizeof(float) * vertexStride * vertexCount);
m_needsUpdate = false;
}
Render:
m_vertexArray->bind();
m_vertexBuffer->bind();
// bind other stuff / modify shader program
// update vertex data if needed, look above
// now we have to enable the vertex attrib arrays and bind them to shader IN variables
// we now assume your vertex data looks like this:
// { x, y, z }, { x, y, z } ... in the shader program: "layout(location = 0) in vec3 pos;"
gl->glEnableVertexAttribArray(0); // location of vec3 pos
gl->glVertexAttribPointer(0 /* loc */, 3 /* length */, GL_FLOAT, GL_FALSE, 3 /* stride */, nullptr /* start of first element of triple (is nullptr since we only have one) */);
gl->glDrawArrays(GL_POINTS, GL_ZERO /* we have a vertex array, so we dont need this */, vertexCount);
If you have any questions, feel free to ask me!
--
It might also be useful if you showed us your shader program. Many NVIDIA graphics cards use EGL (GLES) as backend and won't compile shader programs that define a version attribute that is anything else than "#version 100" and "#version 300 es" :).