• Advertisement
Sign in to follow this  

Index Buffer Issues

This topic is 1919 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok I am having this problem and its been the bane of my existence for like two weeks now lol. And I am sure its because I don't fully understand the index buffer. The problem is I am making geometry in 3dsMax and when I load geometry in my program it looks fine when rendered with out using wire frame but the problem is when I try to use wire frame the wires like make no sense to me at all. Ill include images to show what I am talking about.

This is it rendered with out wire frame.
[attachment=11842:rendered skin.PNG]

This is the same surface rendered with wire frame.
[attachment=11843:rendered wire.PNG]

So you can see that each triangle is not defined with lines, there are these strange gaps that I don't understand and I also don't understand how the surface is rendering correctly but the wire frame is not. with that said I am not using GL_LINE_LOOP or GL_TRIANGLE_LOOP it is just triangle and lines. so what am i missing? Now is this something that would be a result of how my index buffer is set up or am I completely not understanding this. Any light shed on the situation would be awesome.

This is a problem for me when i am trying to create my own file types for storing the vertex info. I am not getting a real number of faces or a full triangle face information.

thanks

Share this post


Link to post
Share on other sites
Advertisement
BY any chance are you using GL_LINES to draw your wireframe?

GL_LINES draws one line segment between each pair of vertices. GL_TRIANGLES draws triangle between each triplet of vertices. Thus if you have, for example, an index buffer:
1,2,3,3,2,4
It defines two adjacent triangles (sharing edge 2-3), but if drawn with GL_LINES, only two line segments (1-2 and 2-4) will be drawn.

Primitive types (GL_TRIANGLES, GL_LINES, etc.) define the topology of your mesh. In your case the topology is triangles so you have to use GL_TRIANGLES always.
glPolygonMode defines whether you want your triangles to be filled or outlined.

So you have to set glPolygonMode to GL_LINE and use glDrawElements with GL_TRIANGLES in your code for wireframe mode.

Share this post


Link to post
Share on other sites
You can check up the primitives section in OpenGL's spec. I was going to say that you could use a GL_LINE_STRIP in your glDraw call for obtaining a wireframe, though what Lauris said (glPolygonMode) works better from what I've seen...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement