[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] OBJ loader using VBOs



Hi, I'm working on a standalone OBJ loader based on the well-known one on the pygame wiki:
http://www.pygame.org/wiki/OBJFileLoader

My goal is to speed up load times by making the model objects picklable, so the OBJ file doesn't have to be read every time you start up. Here's my current version:
http://christophernight.net/stuff/fasterobj-0.tgz

It still needs some cleaning up, but it's got almost all the functionality I wanted. In addition to making things picklable, it has a small optimization by combining triangles and quads when possible to reduce the number of GL calls.

There are three classes: OBJ (using fixed function), OBJ_array (using vertex arrays), and OBJ_vbo (using vertex buffer objects). Additionally, any of these can be used with or without a display list. Here's the results of my test on some model I had lying around:

   type  list? parse save load   render
1. fixed False  146   13   14    0.03fps
2. fixed  True  124   10  950  117.80fps
3. array False  179    8    9    1.26fps
4. array  True  174    7   30  121.08fps
5. vbo   False  143    7    8   16.06fps
6. vbo    True  142    8   12  112.98fps

#2 is the method in the original OBJ loader. The times listed under parse, save, and load are times in milliseconds to read from the OBJ file and do some preprocessing, pickle to a file, and unpickle from a file. The load step also includes generating the display list, if necessary. Obviously methods #1 and #3 render far too slow; they're just there for comparison.

So anyway, it looks pretty good. I think that #4 or #6 would do fine for my purposes. However, I know that people don't like to put vertex arrays and VBOs inside display lists, so I want to know if there's some problem with this method. I understand that putting a VBO in a display list defeats the whole purpose of having a VBO, since you can't update it, but I imagine you're probably not going to be doing that with OBJ models anyway. Also, when I asked about this a few months ago, someone said that method #5 should outperform methods #1-4, and that doesn't seem to be the case. So I might be misusing the VBOs.

Any other comments welcome too! If you have any OBJ files you want me to test, just let me know.

-Christopher