I'm creating a glBufferData using an array explicitly defined of vertex coordinates and everything works fine. When using a non explicitly defined array the result is totally different althought I'm using the same coordinates values. The drawcall renders things in a different vertexs order.
The vertexs are a grid of triangles.
Code 1 that works fine:
this->graphics->createBuffers(1, vboIndexsID);
this->graphics->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, *vboIndexsID);
this->graphics->bufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort)*numIndexs, ind, GL_STATIC_DRAW);
this->graphics->createBuffers(1, vboVertexsID);
this->graphics->bindBuffer(GL_ARRAY_BUFFER, *vboVertexsID);
this->graphics->bufferData(GL_ARRAY_BUFFER, 300, quad_verts2, GL_STATIC_DRAW);
where quad_verts2 is:
GLfloat quad_verts2[75] =
{
0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 100.0f,
0.0f, 0.0f, 200.0f,
0.0f, 0.0f, 300.0f,
0.0f, 0.0f, 400.0f,
100.0f, 0.0f, 0.0f,
100.0f, 0.0f, 100.0f,
100.0f, 0.0f, 200.0f,
100.0f, 0.0f, 300.0f,
100.0f, 0.0f, 400.0f,
200.0f, 0.0f, 0.0f,
200.0f, 0.0f, 100.0f,
200.0f, 0.0f, 200.0f,
200.0f, 0.0f, 300.0f,
200.0f, 0.0f, 400.0f,
300.0f, 0.0f, 0.0f,
300.0f, 0.0f, 100.0f,
300.0f, 0.0f, 200.0f,
300.0f, 0.0f, 300.0f,
300.0f, 0.0f, 400.0f,
400.0f, 0.0f, 0.0f,
400.0f, 0.0f, 100.0f,
400.0f, 0.0f, 200.0f,
400.0f, 0.0f, 300.0f,
400.0f, 0.0f, 400.0f
};
Code 2 that doesn't work:
this->graphics->createBuffers(1, vboIndexsID);
this->graphics->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, *vboIndexsID);
this->graphics->bufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort)*numIndexs, ind, GL_STATIC_DRAW);
this->graphics->createBuffers(1, vboVertexsID);
this->graphics->bindBuffer(GL_ARRAY_BUFFER, *vboVertexsID);
this->graphics->bufferData(GL_ARRAY_BUFFER, 300, list, GL_STATIC_DRAW);
exactly the same as before, but the list data instead of quad_vert2.
where list is:
GLfloat list[75];
int j = 0;
for(int i=0;i<numVertexs;++i) {
list[j] = v->coord.x;j++;
list[j] = v->coord.y;j++;
list[j] = v->coord.z;j++;
++v;
}
the data in v, is exactly the same values than in quad_vert2.
glGetError, after glBufferData is always 0. If I get the data in the buffer using glGetBufferSubData the values are the same.
Ideas?
thanks in advance.
numVertexs?