patrikk
12-04-2009, 01:23 AM
Hi,
I want to render some objects using OpenGL ES 2.0 and the glDrawElements() function. The Data is parsed from an .obj File in simple flot-arrays for vertices, normals, texCoords,
float *vertices;
float *normals;
float *texCoords;
GLushort *indicies;
where the arrays are setup in this structure..
vertices[0] = v1.x;
vertices[1] = v1.y;
vertices[2] = v1.z;
vertices[3] = v2.x;
vertices[4] = v2.y;
vertices[5] = v2.z;
and the indicies are
indicies[0] = vert1.x;
indicies[1] = tex1.x;
indicies[2] = norm1.x;
indicies[3] = vert1.y;
indicies[4] = tex1.y;
indicies[5] = norm1.y;
indicies[6] = vert1.z;
indicies[7] = tex1.z;
indicies[8] = norm1.z;
when i try to render the scene i get some problems with the normals and texCoords. I'm sure that there is a problem while filling the indicies-array. For rendering I'm using the following Code:
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glEnableVertexAttribArray(ATTRIB_VERTEX);
glEnableVertexAttribArray(ATTRIB_NORMAL);
glVertexAttribPointer(ATTRIB_VERTEX, 3, GL_FLOAT, 0, 0, vertices);
glVertexAttribPointer(ATTRIB_NORMAL, 3, GL_FLOAT, 0, 0, normals);
glDrawElements(GL_TRIANGLES, numFaces, GL_UNSIGNED_SHORT, indicies);
So my Question is:
How should I organize the indicies-array for drawing vertices, normals, texCoords correct with the glDrawElements function?
I want to render some objects using OpenGL ES 2.0 and the glDrawElements() function. The Data is parsed from an .obj File in simple flot-arrays for vertices, normals, texCoords,
float *vertices;
float *normals;
float *texCoords;
GLushort *indicies;
where the arrays are setup in this structure..
vertices[0] = v1.x;
vertices[1] = v1.y;
vertices[2] = v1.z;
vertices[3] = v2.x;
vertices[4] = v2.y;
vertices[5] = v2.z;
and the indicies are
indicies[0] = vert1.x;
indicies[1] = tex1.x;
indicies[2] = norm1.x;
indicies[3] = vert1.y;
indicies[4] = tex1.y;
indicies[5] = norm1.y;
indicies[6] = vert1.z;
indicies[7] = tex1.z;
indicies[8] = norm1.z;
when i try to render the scene i get some problems with the normals and texCoords. I'm sure that there is a problem while filling the indicies-array. For rendering I'm using the following Code:
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glEnableVertexAttribArray(ATTRIB_VERTEX);
glEnableVertexAttribArray(ATTRIB_NORMAL);
glVertexAttribPointer(ATTRIB_VERTEX, 3, GL_FLOAT, 0, 0, vertices);
glVertexAttribPointer(ATTRIB_NORMAL, 3, GL_FLOAT, 0, 0, normals);
glDrawElements(GL_TRIANGLES, numFaces, GL_UNSIGNED_SHORT, indicies);
So my Question is:
How should I organize the indicies-array for drawing vertices, normals, texCoords correct with the glDrawElements function?