Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
    
Try reversing the triangle winding order, maybe you are not seeing anything because of backface culling –  melak47 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
add comment

1 Answer

up vote 3 down vote accepted

Some observations:

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

  • The obj loading seems incorrect.

    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?

  • Why not using an asset loading library?

share|improve this answer
    
Thanks for taking the time to respond, I have taken time to add some more OpenGL error checking since I have posted the question. Now on the subject of the obj loading I have implmented your sugestions I think with nothing still loading on the screen. And on the subject of the third part library, I decided to roll my own for the learning experience. Here is my new post process code: pastebin.com/rnmNFhHW –  ceriosNerd May 29 '12 at 13:19
    
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
    
Oh ok I understand now, But another question if you don't mind. Don't you need 24 vertices for proper normals to work? Or am i completely wrong there also? Also wouldn't I at least see some garbage displayed if my vertices ore wrong? I'm reading over that introduction now. I'll mark this as the answer when I get done reading. –  ceriosNerd May 29 '12 at 14:49
    
Another tidbit of info, I tried using draw arrays instead with my original code and nothing showed either, wouldn't of that for sure displayed something? –  ceriosNerd May 29 '12 at 15:06
    
Sorry to spam your StackExchange but even immediate mode doesn't draw anything. pastebin.com/AH6QEVus –  ceriosNerd May 29 '12 at 15:13
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.