Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Wavefront Object Loader Problem

  1. #1
    Newbie Newbie
    Join Date
    Dec 2012
    Posts
    1

    Wavefront Object Loader Problem

    Hey guys,

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

    http://openglsamples.sourceforge.net/files/glut_obj.cpp

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

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    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

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,129
    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:

    Code :
    glMatrixMode(GL_PROJECTION); 
    glViewport(0, 0, win.width, win.height); 
    GLfloat aspect = (GLfloat) win.width / win.height; 
    glMatrixMode(GL_PROJECTION); 
    glLoadIdentity(); 
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •