OpenGL in Python with Snow Leopard?

I am interested in playing with OpenGL in Python. I used OpenGL in C ++ and Objective-C, but I don't have much experience in Python. I am wondering if there is a good tutorial that works in Snow Leopard. I would prefer to stay in 64-bit mode, if possible, since I heard that 32-bit programs require downloading a large number of additional 32-bit libraries.

I already tried the PyOpenGL / wxPython tutorial . When I ran the code, it crashed with this message:

ImportError: /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode/wx/_core_.so: no appropriate 64-bit architecture (see "man python" for running in 32-bit mode) 

There seems to be an error in wxPython that prevents it from working on a 64-bit system.

I also looked at Pyglet, but they have a similar problem . They provide a workaround (setting Python to 32-bit mode), but it doesn't seem like they will fix it.

Finally, I looked at PyGLUT, but I think it is only for Windows.

Are there any other libraries that will allow me to access OpenGL and draw on the screen? Again, I would rather stay in 64-bit mode, but if all else fails, I will switch to 32-bit and try wxPython or Pyglet again.


Edit: I also tried PyGame. It depends on the SDL, which is broken in SL. I was thinking of trying to use Cocoa through PyObjc, but the Python Xcode application templates were removed .

+4
source share
4 answers

I used PyOpenGL 3.0.0 quite successfully on Snow Leopard. It uses ctypes, so it should make 64-bit calls if these libraries are available (and Snow Leopard Python includes a 64-bit version). I have not used wxPython stuff with PyOpenGL so that where you might run into problems, but PyOpenGL also includes GLUT, which both work fine.

+4
source

There is probably no good reason to avoid 32-bit mode. Unless your Python programs need a larger address space, of course.

+2
source

You can try pygame. Pygame is a python wrapper around the SDL. According to their website, they have Max OS X binaries. The following is an example of a simple example of using pygame with OpenGL. Once you can create windows and handle events, most OpenGL programs are similar to how they would be in C or C ++, but with some kindness added to python. For OpenGL, a great tutorial is NeHe.

0
source

Also when programming with OpenGL in python, remember that Python data structures can be quite slow when it comes to 3D graphics requirements. For example, PyGL developers recommend using ctypes for operations related to graphics, as this way you can get enough performance for some complex geometry with bareable FPS.

0
source

All Articles