Jump to content
  • Advertisement
Sign in to follow this  
zerorepent

Python, trying to get pyopengl working

This topic is 3940 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im trying to get started with pygame, and pyopengl, however I get some weird errors, when I try to run some of the example codes in the book, Game Programming with python, by Sean Riley. And when I try to run the pyopengl on this site: http://www.willmcgugan.com/2007/06/04/opengl-sample-code-for-pygame/ I get the fellowing output: Traceback (most recent call last): File "C:\Downloads\simpleopengl\simpleopengl\firstopengl.py", line 233, in <module> run() File "C:\Downloads\simpleopengl\simpleopengl\firstopengl.py", line 227, in run map.render() File "C:\Downloads\simpleopengl\simpleopengl\firstopengl.py", line 135, in render cube.render() File "C:\Downloads\simpleopengl\simpleopengl\firstopengl.py", line 74, in render glColor( self.color ) File "build\bdist.win32\egg\OpenGL\GL\exceptional.py", line 207, in glColor function = glColorDispatch[arrays.GLfloatArray.arraySize( arg )] KeyError: 1 I'm not sure if the problem is incompatibility between python 2.5 and pyopengl. Heck, I'm not even sure if PyOpenGL got installed correctly, since I used easy_install. I didn't quite work out as supposed. I can't write anything in the commandwindow for it, because it closes before I manage to read what is says. I think this might be due to Windows Vista. Anyhow, I downloaded the PyOpenGL .egg-file from sourceforge and opened it with easy_install (and it worked), afterwards it stood something like "PyOpenGL 2.5 has been installed". I appreciate any help I can get.

Share this post


Link to post
Share on other sites
Advertisement
the PyOpenGL downloads on Sourceforge only indicate compatibility with Python 2.4. This may or may not be a problem; I've found PyOpenGL very brittle and delicate in the past and I'm not terribly confident in it.

That said, the error you're experiencing is a KeyError, which occurs when a dictionary key is not found:

glColorDispatch[arrays.GLfloatArray.arraySize( arg )]

The object returned by arrays.GLfloatArray.arraySize(arg) is not a valid key for the dictionary glColorDispatch.

Share this post


Link to post
Share on other sites
It's also worth noting that the only version of PyOpenGL that is going to see any support in the future is version 3.

Share this post


Link to post
Share on other sites
ok, thanks a lot for the answers (even though they don't solve anything). Apparently I'm using the 3.0.0a6 alpha version. And if I remove the "glColor( self.color )" in the code I get no errors. And the window created looks like this:


Do you thinks changing to an olderversion of python and pyopengl will solve the problem? maybe 2.4 or maybe even 2.2? or is it better to stay up to date on the different versions?

When I run the code outside of idle when removing the text, I get "Pygame error: couldn't load map.png", this is getting really weird.

Maybe I just should try to install a GNU/linux dis. on my laptop instead if I am going to play around with python...

Share this post


Link to post
Share on other sites
Quote:
Original post by zerorepent
ok, thanks a lot for the answers (even though they don't solve anything). Apparently I'm using the 3.0.0a6 alpha version. And if I remove the "glColor( self.color )" in the code I get no errors. And the window created looks like this:


Do you thinks changing to an olderversion of python and pyopengl will solve the problem? maybe 2.4 or maybe even 2.2? or is it better to stay up to date on the different versions?

When I run the code outside of idle when removing the text, I get "Pygame error: couldn't load map.png", this is getting really weird.

Maybe I just should try to install a GNU/linux dis. on my laptop instead if I am going to play around with python...

I posted about my problems with the latest version of python 2.5 and pyopengl myself not long ago and found the quickest solution on windows anyways was to just use an older version of python to get started.
I think I finally did get 2.5 to work after doing some googling and finding some updated pyopengl executables somebody built for windows that did work(they did mention they had to tweak the pyopengl source for it to work and was a pain in the but to compile) but I don't have the link now?
There were some changes in Python 2.5 that makes older versions of pyopengl not work anymore from what I understood.

Share this post


Link to post
Share on other sites
Moving to Linux won't help here. Unfortunately it's quite likely that your book code may not work with newer Python and/or PyOpenGL because some aspects will have changed. There is a PyOpenGL mailing list, so if your problem is quite specific then it's worth posting there to see if someone more knowledgeable can help.

Share this post


Link to post
Share on other sites
I see, then it's worth a try to migrate to python 2.4 instead. (or older depending on how the 2.4 version works).

Atleast i seem to have found what's causing the trouble (in this code, might be more if I continue with other examples in the book)
It seems that glColor can't handle self.color at some point. When I run the program with print self.color before the glColor part, it writes, (0.0,1.0,0.0) however if i change the code to glColor(0.0,1.0,0.0) it works, with the exception that all the 3d-objects are in the same color. (which they aren't in the picture on the example's site.

Share this post


Link to post
Share on other sites
Okay I think these are the binaries I tried on windows with Python 2.5 and got pyopengl to work with:
Hello,

since I tested Python 2.5b2 on my applications, I have rebuilt some extension
modules I needed. It wasn't a very simple or fast task, so I thought I'd share
the result of the efforts:

http://www.develer.com/oss/Py25Bins

this page contains the Windows binaries (installers) for the following
packages:

- NumPy 0.98
- Numeric 24.2
- PyOpenGL 2.0.2.01 (with Numeric 24.2)
- Pyrex 0.9.4.1 (with a Python 2.5 compatibility patch posted in its mailing
list)

I plan to update this page later as I build more installers (but don't hold
your breath). Hope this helps everybody!
--
Giovanni Bajo

Share this post


Link to post
Share on other sites
Very interesting thread. I had considered doing some OpenGL development in python as I thought it was a cool language and quite mature for games (http://www.pygame.org/). I never knew pyopengl was this flaky. Are their any non flaky scripting languages that work well with OpenGL? Has anyone done anything with Ruby or perl?

Share this post


Link to post
Share on other sites
Quote:
Original post by FILO
Has anyone done anything with Ruby or perl?

Their OpenGL bindings are flakier.

This is a problem with PyOpenGL, which I have found problematic for at least 3 years. *shrug*.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!