2

Hello guys I am having a real hard time getting .obj wavefront files to render correctly using IBO.

Now I wrote a parser, its very simple at the moment but it loads vertices and normals. If I bind the parsed vertex and normals I get great results, but if I bind the indices as GL_element... I get a hot mess.

Now I've been working on this for about a week, I've checked at least 20 pages on here and finally decided to ask a question.

I am not really sure whats wrong so I brought my code, some debugging info i wrote to the console, file that i wrote out from the program, screenshots, and videos. I really hope someone here can help me get past this hump.

pastebin : http://pastebin.com/uZs74DSn

You can see from the pastebin that I already account for the .obj file not being zero based by subtracting one from all the indices.

videos : 1. http://www.youtube.com/watch?v=tfqhDEMCjPA&feature=plcp monkey parsed and drawn with glarrays.

  1. http://www.youtube.com/watch?v=SDeJk7sv2ZA&feature=plcp exact same model parsed but drawn with gldrawelements.

  2. http://www.youtube.com/watch?v=3_HS8Q7FXsk&feature=plcp sphere parsed and drawn wigh gldrawelements

  3. http://www.youtube.com/watch?v=w6Oqy3JdTRg&feature=plcp model i found on opengame art, rendered with lineloops but its fine since i used glarray.

  4. http://www.youtube.com/watch?v=xHiCcK5QuE0&feature=plcp a lot of basic shapes rendered and well lit w/ glarrays.

I am really at a loss and hope someone out there can help me get past this hump. I would like to continue to learn shaders. This may be trivial for someone out there, I hope they are able to stop by and give a guiding idea!

bluBee

Will Kru
  • 5,164
  • 3
  • 28
  • 41
user1610950
  • 1,837
  • 5
  • 33
  • 49

1 Answers1

0

After a second look, I think that's really going on is that your offsets are not what you think they are. You're reading your data in, and the vertices are getting duplicated and you're writing duplicate data more than once into your vertex buffer. So, when you later want to refer to index 4, you actually have the data from vertex 2 at that position of the vertex array.

Try pre-sorting the vertex data and writing it all out so that your vertex array is no larger than [max_index_number * 3], then just stream your indices out as is. I think that might work.

Learn OpenGL ES
  • 4,759
  • 1
  • 36
  • 38