Wavefront Object Loader Problem

Hey guys,

I’ve been trying to implement this object loader to no avail.


Right now I am just getting a blank screen and I am pretty sure I am copying it exactly! Advise anybody?

try to break your problem up into small bits - for example make your render code can display a simple bounding box that you hard code then look at the .obj

  1. Did you check for GL errors?
  2. If the GL code is clean, did you check your loaded data?

One thing I saw in your code is this:

glViewport(0, 0, win.width, win.height); 
GLfloat aspect = (GLfloat) win.width / win.height; 
gluPerspective(win.field_of_view_angle, aspect, win.z_near, win.z_far);

It’s technically not an error but unnecessary and redundant. glViewport() does not alter the matrix stack. You need only change the current if you actually involve matrix manipulation functions, like gluPerspective(), glFrustum(), glOrtho(), glLoadIdentity() and so on. In any case, setting the matrix mode to GL_PROJECTION twice in a row without any switch to another matrix stack, like GL_MODELVIEW, is a redundant state change. In the init function it doesn’t really make a difference but if this scheme becomes a habit and you introduce a lot of redundant state changes into performance critical code, you’ll probably see performance drops. Remember that for the future.

Finally, a little pedantry on the side: It’s vertices not verteces.