# Problem rendering a Wavefront mesh, nothing displays(VBO)

I'm having a problem with displaying my wavefront obj file using VBO's My fps counter slows down like there is something being drawn but I cannot see anything. Is it a problem with my loader? Or maybe just a simple bug in my VBO rendering code?

I have checked that I am actually loading the data but maybe it's in the wrong order. I used OpenGL profiler and found nothing specious the texture and the VBO and IBO are in the GPU. I did try two different obj files, one of mine and a random one I found on NASA's site both rendered at the same speed(about 60 fps) with nothing on the screen. If you want any output from OpenGL profiler ask me.

BlockRender.cpp http://pastebin.com/3KuuWX9H

Renderer.cpp http://pastebin.com/gDCvi3t7

Relevant snippets of code http://pastebin.com/rTqRzYXL

Sample wavefront obj file http://pastebin.com/qVJ55gwn

• Try reversing the triangle winding order, maybe you are not seeing anything because of backface culling – user13213 May 28 '12 at 21:46
• I disabled backface culling with no success. I'll also try to change my winding order but that shouldn't make a difference with backface culling off. – ceriosNerd May 28 '12 at 22:25

Some observations:

• First, there's no error checking in the code.

The vertices are copied into mesh.vertices (l. 212-214 in BlockRenderer). Using the DefaultCube, mesh.vertices contains 12*3 vertices, and the index buffer 36 ints.

Problem seems that the indices reference into the original verts array and not into mesh.vertices. BlockRenderer.cpp l.216ff should IMO read like

mesh.indices.push_back(3*i+0); // not faces[i].v[0]
mesh.indices.push_back(3*i+1); // not faces[i].v[1]
mesh.indices.push_back(3*i+2); // not faces[i].v[2]

• However, when using indices, I'd expect the original vertices to stay untouched, and the faces defined by the indices. Then, the vertex buffer must contain 24 floats defining 8 vertices that define the cube's corners. For building the vertex buffer, the code needs to iterate over verts and just push the vertices into mesh.vertices; the corresponding index buffer then is built using the original code.

• You're sure the mesh is a triangle strip?

• Be sure to understand what the code does. Now the indices are such that they would be correct using your original code, but mesh.vertices now contains the first vertex of each face. This doesn't look like making much sense, huh? Check an introduction to the topic. – Stefan Hanke May 29 '12 at 14:41