Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualKoehler

Posted 17 July 2013 - 12:05 PM

I'm guessing your problem is here:

 

glDrawArrays( GL_TRIANGLES, 12,indices.size());

 

This is for non-indexed geometry, where all vertices are stored in order in an array.

 

You have indexed geometry from your OBJ file, (So you have a minimal array of vertices, and then the array "indices" indexes into that vertex array.) This means you want to use:

glDrawElements( GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, &indices[0]);

 

Note that &indices[0] is because I'm not sure if you are using a vector or an array. If an array you could just pass "indices". If array vector you could pass "indices.data()"


#1Koehler

Posted 17 July 2013 - 12:03 PM

I'm guessing your problem is here:

 

glDrawArrays( GL_TRIANGLES, 12,indices.size());

 

This is for non-indexed geometry, where all vertices are stored in order in an array.

 

You have indexed geometry from your OBJ file, (So you have a minimal array of vertices, and then the array "indices" indexes into that vertex array.) This means you want to use:

glDrawElements( GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, &indices[0]);

 

Note that &indices[0] is because I'm not sure if you are using a vector or an array. If an array you could just pass "indices". If array you could pass "indices.data()"


PARTNERS