Take the 2-minute tour ×

I load obj models and try to render them with OpenGL ES using Android NDK:

class ObjModel{

    int numVertex, numNormal,numTexCoord, numTriange;

    float *vertexArray;
    float *normalArray;
    float *texCoordArray;
    unsigned short *indexArray;

    void loadModel(string fileName);


glVertexPointer(3, GL_FLOAT, 0,  &(model->vertexArray[0]));
glNormalPointer(GL_FLOAT, 0,  &(model->normalArray[0]));
glDrawElements(GL_TRIANGLES, model->numTriange, GL_UNSIGNED_SHORT,

Model is not rendered fully, I see only part of it. I checked the data in arrays and they are parsed properly. I think that the only issue might be with passing arguments. Am I doing it right?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Hope this helps! I think you are just missing the number 3!

glDrawElements(GL_TRIANGLES, 3 * model->numTriange, GL_UNSIGNED_SHORT,
share|improve this answer
Thanks, it was the issue! I confused the parameter with the number of triangles to draw. –  Mighter Jan 17 '12 at 15:14
It's the number of indices in the buffer! Enjoy! –  Nico Jan 17 '12 at 15:17
@Mighter And of course, accepting is the correct repsonse if this answer was the solution to your problem. –  Christian Rau Jan 17 '12 at 15:24
add comment

Your Answer


