pyglet + pyopengl

41 views
Skip to first unread message

Noyan Tokgozoglu

unread,
Nov 21, 2008, 2:44:47 PM11/21/08
to pyglet-users
First of all, I love pyglet, and I would never want to use pyopengl.

However, I need to load 3ds files. And this person wrote some code to
load 3ds files ( http://www.aerojockey.com/software/dice3ds/index.html
), which requries pyopengl to put it into a display list easily.

I tried to modify his code to work with pyglet, and after lots of
ctypes pain and dozens of segfaults, I gave up.

Now I just run pyglet and pyopengl together. However, if I import
pyglet first, pyopengl gives an error while importing, saying:

Traceback (most recent call last):
File "interpolator.py", line 30, in <module>
from Dice3DS.example import glmodel, gltexture
File "C:\Python25\lib\site-packages\Dice3DS\example\glmodel.py",
line 11, in <
module>
from Dice3DS.example import basicmodel, gltexture
File "C:\Python25\lib\site-packages\Dice3DS\example\gltexture.py",
line 14, in
<module>
from OpenGL.GLU import *
File "c:\python25\lib\site-packages\PyOpenGL-3.0.0b6-py2.5.egg\OpenGL
\GLU\__in
it__.py", line 10, in <module>
from OpenGL.GLU.glunurbs import *
File "c:\python25\lib\site-packages\PyOpenGL-3.0.0b6-py2.5.egg\OpenGL
\GLU\glun
urbs.py", line 147, in <module>
cb = _callbackWithType( funcType )
File "c:\python25\lib\site-packages\PyOpenGL-3.0.0b6-py2.5.egg\OpenGL
\GLU\glun
urbs.py", line 140, in _callbackWithType
simple.gluNurbsCallback
File "c:\python25\lib\site-packages\PyOpenGL-3.0.0b6-py2.5.egg\OpenGL
\platform
\baseplatform.py", line 192, in copyBaseFunction
extension = original.argNames,
File "c:\python25\lib\site-packages\PyOpenGL-3.0.0b6-py2.5.egg\OpenGL
\platform
\baseplatform.py", line 134, in createBaseFunction
extension = extension,
File "c:\python25\lib\site-packages\PyOpenGL-3.0.0b6-py2.5.egg\OpenGL
\platform
\baseplatform.py", line 80, in constructFunction
if extension and not self.checkExtension( extension ):
File "c:\python25\lib\site-packages\PyOpenGL-3.0.0b6-py2.5.egg\OpenGL
\platform
\baseplatform.py", line 158, in checkExtension
current = set.get( name )
TypeError: list objects are unhashable


And if I try to import pyopengl first, it works, however all my
textures are gone, and only the textures of the imported model are
displayed.

So help me pelase! How can I make the two opengl libraries work
together? Or should I really try to modify his code harder? The
problem I've had with his code is basically related to (I think)
glVertexPointer, numpy ndarrays and the fact that pyglet expects
glfloats. However, I searched a lot on this and kept getting crashes
that looked like segfaults. So I'd appreciate it if you could please
focus on making pyopengl and pyglet working together instead of
solving this issue.

Thanks!

Noyan Tokgozoglu

unread,
Nov 21, 2008, 2:56:11 PM11/21/08
to pyglet-users
Actually, now that I look closely, the textures aren't gone, they are
barely visible on distant objects... The loaded model looks fine
though...
Here is now it looks:

http://i32.photobucket.com/albums/d7/thepicturesofnayon/bug.png

On Nov 21, 9:44 pm, Noyan Tokgozoglu <cladinapa...@gmail.com> wrote:
> First of all, I love pyglet, and I would never want to use pyopengl.
>
> However, I need to load 3ds files. And this person wrote some code to
> load 3ds files (http://www.aerojockey.com/software/dice3ds/index.html

Noyan Tokgozoglu

unread,
Nov 22, 2008, 6:33:25 AM11/22/08
to pyglet-users
I solved it.

Turns out his code turned off GL_TEXTURE_2D. I enabled it within my
code after drawing the model, and everything got solved. Simple, eh?

Jonathan Hartley

unread,
Nov 22, 2008, 10:38:52 AM11/22/08
to pyglet-users
So how does it look now it's fixed? :-)

Noyan Tokgozoglu

unread,
Nov 22, 2008, 12:14:47 PM11/22/08
to pyglet-users
Here:

http://i32.photobucket.com/albums/d7/thepicturesofnayon/bug2.png

My original polygonal bug, standing next to the modeled one. The app
has 4xmultisampling,mipmaps, and sme other stuff enabled. Looks pretty
good, right? I'm trying to get some shadows to work now.

Matthew Edwards

unread,
Nov 23, 2008, 3:55:23 PM11/23/08
to pyglet...@googlegroups.com
Awesome! Are we going to see a finished product?

Noyan Tokgozoglu

unread,
Nov 24, 2008, 3:39:25 PM11/24/08
to pyglet-users
Umm, I'm running into a few problems right now, but I'll try! This was
for a school project, and I completed the requirements, so we'll see
what happens!

On Nov 23, 10:55 pm, "Matthew Edwards" <cheeseboy...@gmail.com> wrote:
> Awesome! Are we going to see a finished product?
>

Jonathan Hartley

unread,
Nov 24, 2008, 8:24:19 PM11/24/08
to pyglet-users
Brilliant. That really is awesome. Thanks for the screenshot, Noyan.

Carl Banks

unread,
Nov 30, 2008, 8:29:50 PM11/30/08
to pyglet-users
A good library affects its caller's state as little as possible. I
definitely dropped the ball in this respect. I'll make a note to
preserve the enable flags in the next Dice3DS release.

I'm not the biggest fan of pyglet (sorry) but maybe I'll also try to
update the example code to accommodate Pyglet's OpenGL interface.
Pyglet's built-in OpenGL calls are not as robust to all the different
array types as PyOpenGL is, so the code would need to be careful to
make sure arrays are contiguous and alignments correct.

Carl Banks

Tristam MacDonald

unread,
Nov 30, 2008, 9:20:20 PM11/30/08
to pyglet...@googlegroups.com
On Sun, Nov 30, 2008 at 8:29 PM, Carl Banks <pavlove...@gmail.com> wrote:

A good library affects its caller's state as little as possible.  I
definitely dropped the ball in this respect.  I'll make a note to
preserve the enable flags in the next Dice3DS release.

I'm not the biggest fan of pyglet (sorry) but maybe I'll also try to
update the example code to accommodate Pyglet's OpenGL interface.
Pyglet's built-in OpenGL calls are not as robust to all the different
array types as PyOpenGL is, so the code would need to be careful to
make sure arrays are contiguous and alignments correct.

I could be wrong, but my impression is that the arrays must be contiguous and alignment must be correct to achieve any sort of performance - otherwise PyOpenGL has to manually convert the array before sending it to OpenGL.

- Tristam
Reply all
Reply to author
Forward
0 new messages