[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] OBJ loader using VBOs
- To: pygame-users@xxxxxxxx
- Subject: [pygame] OBJ loader using VBOs
- From: Christopher Night <cosmologicon@xxxxxxxxx>
- Date: Sat, 4 Dec 2010 15:21:00 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sat, 04 Dec 2010 15:21:12 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=5cbMq9tqmlfijkeulymTi5xItISf/NNNlEi9iI3MJfw=; b=saN9P93RQo4/c7/+rR+78hoCOurvk+exgw7NZZYrDSMgc61CH6FUF4bZ/IRR2rWR9C vT5l975lgnMMUZvDV9qyAFf2NcVbSRb3X4PKTE2ZJz0qQoO8MNWwA+0AQr3VpDqZ/EUy 8/nHdLWxvW603VU+/dT5y6JAEOWkHQFNZ8uzo=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=kIcElHcU+yzB4EgBe9s6qeao47KjOdEXPFnPDlKES084PqSpTuosmdTa5enc4UdupY KZWD3Ang42pDawRHBmJaCfyQvSi7m9vUhJSBV7WL6X/bgNkITsptTNlSuivBsbteCDqJ N2bi08hoCj2qDngze1Y0xMLC1LB6QDeuzLnqc=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hi, I'm working on a standalone OBJ loader based on the well-known one on the pygame wiki:
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:
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