PDA

View Full Version : use VBO to define color & vertex variable in GPU



saman_artorious
06-21-2013, 11:35 PM
I added this to the initialization part:

verticesSize = sizeof(vertices);
colorsSize = sizeof(colors);

glGenBuffers(2, vbods);

glBindBuffer(GL_ARRAY_BUFFER, vbods[VERTEX]);

glBufferData(GL_ARRAY_BUFFER,
sizeof(vertices)+sizeof(colors),
vertices, GL_STATIC_DRAW );

glBufferSubData(GL_ARRAY_BUFFER, sizeof(vertices), sizeof(colors), colors);

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);

and this to the render part:

glBindBuffer(GL_ARRAY_BUFFER, vbods[VERTEX]);
glVertexPointer(2, QVector3D, 0, 0);
glColorPointer(3, GL_FLOAT, 0, (GLvoid *) (ANGLE_COUNT * RANGE_COUNT * 6));

though, I get errors in the functions glBufferData, It cannot cast it from QVector3D to GLvoid*, do you have any idea?

vertices is defined as

QVector<QVector3D>

saman_artorious
06-22-2013, 03:02 AM
vertices.constData
solved the problem