Advertisement

Lesson 1: Problems with Python

Started by November 13, 2005 06:50 PM
5 comments, last by ryancharpen 19 years ago
Ok, well, I've spent near around the last hour working with this. I've read NeHe's Lesson 1, and downloaded the appropiate code for Python. I looked at the code, and saw that it said it needed OpenGL, PyOpenGL, PyNumeric, and GLUT. I used the download link on NeHe to download the OpenGL SDK, where I placed it in a folder named C++, where the C++ folder was located with my python24 folder. I used the latest stable release, not alpha, executable for PyOpenGL, and installed that fine. I DLed GLUT, and placed the files according to where the readme had said. And I could not find PyNumeric anywhere. The first time I ran it, was before I installed all this stuff and it had a problem with the:

from OpenGL.GL import *

But after installing everything else, it didn't have a problem with that. But now, where I'm currenly stuck, it has issues with the very next line:

from OpenGL.GLUT import *

Also, when trying to run it, not through the IDE, it gives me this error: The procedure entry point __glutInitWithExit could not be located in the dynamic link library glut32.dll. On a side note, I was wondering if anyone has had succesfull use of OpenGL with Python. The reason I'm going through this trouble, is because I've been learning and using Python, and would like to start working on 3D applications/games.
Sounds like your glut32.dll file is out of date (PyOpenGL needs a rather new version), try updating from here:
http://www.xmission.com/~nate/glut.html
Advertisement
Thanks! That fixed that, but new problems occur!

My error:

Hit ESC key to quit.Traceback (most recent call last):  File "C:\Python24\lesson1.py", line 135, in ?    main()  File "C:\Python24\lesson1.py", line 86, in main    glutInit("")TypeError: not a list


What it hates:

The Main():
print "Hit ESC key to quit."main()

^^ That code is at the very end of it

What its calling:
def main():	global window	glutInit("")	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)	glutInitWindowSize(640, 480)	glutInitWindowPosition(0, 0)	glutSetDisplayFuncCallback(DrawGLScene)	glutDisplayFunc()	glutSetIdleFuncCallback(DrawGLScene)	glutIdleFunc()	glutSetReshapeFuncCallback(ReSizeGLScene)	glutReshapeFunc()	glutSetKeyboardFuncCallback(keyPressed)	glutKeyboardFunc()	InitGL(640, 480)	glutMainLoop()


At first I thought it was an error, because its drawing a window and not a console, but thats not what the reported problem is. Apparently something is left out of glutInit("") thats needed, a list, but I'm too new to know what.
I don't know PyOpenGL (Or even Python very well), a search seems to suggest that you should replace


glutInit("")


with


glutInit( sys.argv )
Doesn't work.

With quotes, it tells me that its not a list. Without quotes, it says the global name sys is not defined.
import sys
glutInit(sys.argv)

(Not trying to be mean, but I suggest you spend a bit more time learning python before jumping into python+pyopengl. You'll have a lot less headaches)
Advertisement
Instead of using GLUT to setup your window you should consider using Pygame www.pygame.org, which is an SDL wrapper for Python. It seems to work well with PyOpenGL and best of all, someone has even gone to the trouble of converting some of NeHe's tutorials to use PyOpenGL and Pygame.

You can download the conversions here

This topic is closed to new replies.

Advertisement