Monday 15 April 2013

opengl - glDrawElements() parameters -


I want to render a 3D box by reading my geometry from the VRML file. Index of VRML files are given as follows:

  Coordination [0, 1, 2, -1, 2, 3, 0, -1, 3, 2, 4, -1, 4 , 5, 3, -1, 5, 4, 7, -1, 7, 6, 5, -1, 6, 7, 1, -1, 1, 6, -1, 6, 0, 3, -1 , 3, 5, 6, -1, 1, 7, 2, -1, 7, 4, 2, -1,]   

I want to call the glDrawElements function to render On the box I am not sure about the "count" and "index" parameter. Should be 12 to indicate the number of faces 12 or the total indices of the verticals? Also, please tell me about the index array that should be:

  Glint index [] = {0,1,2,2,3,0,3,2,4, ....., 7, 4, 2}; Or GLIT index [] = {0,1,2, -1,2,3,0, -1, ...., 7,4,2};    

According to the man page

When GlDrawElements said It uses sequential elements to be counted from a capable array

So it will be 36 for the total index in your indexbuff.

For the index array you must select the first version index should be & gt; = 0 and the constant 3 index will draw a triangle.

No comments:

Post a Comment