views:

1485

answers:

6

I am looking to do some tinkering with openGL and Python and haven't been able to find good reasons for using PyOpenGl versus pyglet

Which would you recommend and why?

+2  A: 

pyglet has a lot of nice extras included with it (like image loading and sound). If you're starting out, I'd try pyglet first, and then switch to PyOpenGL if you feel like you want to get closer to the metal.

The real important question though is: what are you trying to accomplish?

Tony Arkles
+9  A: 

As Tony said, this is really going to depend on your goals. If you're "tinkering" to try to learn about OpenGL or 3D rendering in general that I would dispense with all pleasantries and start working with PyOpenGL, which is as close are your going to get to "raw" 3D programming using Python.

On the other hand, if your "tinkering" by way of mocking up a game or multimedia application, or trying to learn about programming practices in general than Pyglet will save you lots of up-front development time by providing hooks for input events, sounds, text/billboarding, etc. Often, this up-front investment is what prevents people from completing their projects, so having it done for you is not something to be ignored. (It is also very Pythonic to avoid reinventing the wheel.)

If you are looking to do any sort of heavy-duty lifting (which normally falls outside my definition of "tinkering", but maybe not if your tinkering with 3D engine design) then you might want to take a look at Python-Ogre, which wraps the very full-featured and robust OGRE 3D graphics engine.

bouvard
+1  A: 

I promote pyglet because it has the nicest API I've yet seen on stuff like this.

Pyglet has opengl API as well. But it's often nicer to use the recently added vertex list support.

pyglet.gl

Cheery
+1  A: 

I would recommend Pyglet because it is very easy to get started and have something basic running, and then you can add more advanced techniques at your own pace.

Kiv
+1  A: 

I'd say that Pyglet is actually more evolved than PyOpenGL. It has a nice API of it's own, and it has a full wrapper around OpenGL accessed through the pyglet.gl module! PyOpenGL doesn't even wrap all the functions OpenGL has. Pyglet also has a great library for rendering 2D with hardware acceleration through OpenGL, and it's really well made.

If you want a powerful ready made 3D engine you've got Ogre and such

Sir Oddfellow
+1  A: 

pyglet's GL API is nowhere near as nice as PyOpenGL's - pyglet's is at the raw ctypes layer which means you'll need to learn ctypes as well. If you're planning on doing a bunch of OpenGL programming you'll want to use PyOpenGL.

The nice thing is you can mix the two just fine. Use pyglet to provide the GL context, sounds, events, image loading and texture management, text rendering, etc, etc. Use PyOpenGL for the actual OpenGL programming you need to do.

Richard Jones