Hello, I have problem with QGLBuffer. I did not find any example so I do not know how exactly it works.
In this example I am drawing some tria elements, which is working correctly when QGLBuffer is NOT used.
When I use QGLBuffer, function glDrawElements causes application to crash.
It looks like array copied to buffer is different from source.
This is the fragment of code.
GLuint list = glGenLists(1);
faceColor = qtGreen.redF();
faceColor = qtGreen.greenF();
faceColor = qtGreen.blueF();
faceColor = qtGreen.alphaF();
m_vertexBuffer = new QGLBuffer(QGLBuffer::VertexBuffer);
glVertexPointer(3, GL_FLOAT, 0, 0); // THIS IS NOT WORKING - glDrawElements cause app to crash.
// glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); // THIS IS WORKING PERFECTLY glDrawElements draws elements as intended.
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, faceColor);
glDrawElements(GL_TRIANGLES,m_count, GL_UNSIGNED_INT, m_index.constData()); // AFTER CALLING THIS FUNCTION APP CRASHES ( when i use QGLBuffer.
Do you have any idea what can be wrong.
Thank you very much.
Typhlosion last edited by
Do not forget to release the GLBuffer when you don't need it anymore.
But I am having issues with this QGLBuffer too.
Any working example would be fine...
m_vertexBuffer->allocate(vertices.constData(), vertices.count() * sizeof(GLfloat));
The second argument to "allocate":http://doc.qt.nokia.com/4.7/qglbuffer.html#allocate expects the number of bytes of space required, not the number of vertices.
i just stumbled of the same problem.
Have you found a solution?
never mind ... i used setAttributeArray instead of using setAttributeBuffer