By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,813 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,813 IT Pros & Developers. It's quick & easy.

pyopenGL: glutInit : TypeError: not a list

P: n/a
Hi,
I am starting to write this sample program in Python to use the GLUT
library.
<-->

from OpenGL.GL import *
from OpenGL.GLUT import *

def init():
glClearColor(0, 0, 0, 0)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glLightfv(GL_LIGHT0, GL_AMBIENT,
[0.0, 0.0, 0.0, 1.0])
glLightfv(GL_LIGHT0, GL_DIFFUSE,
[1.0, 1.0, 1.0, 1.0])
glLightfv(GL_LIGHT0, GL_POSITION,
[0.0, 3.0, 3.0, 0.0])
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,
[0.2, 0.2, 0.2, 1.0])
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)

def display():
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glMaterialfv(GL_FRONT, GL_AMBIENT,
[0.1745, 0.0, 0.1, 0.0])
glMaterialfv(GL_FRONT, GL_DIFFUSE,
[0.1, 0.0, 0.6, 0.0])
glMaterialfv(GL_FRONT, GL_SPECULAR,
[0.7, 0.6, 0.8, 0.0])
glMaterialf(GL_FRONT, GL_SHININESS, 80)
glutSolidTeapot(0.5)
glFlush()

glutInit(' ')
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutInitWindowSize(250, 250)
glutCreateWindow('Hello GLUT')
glutSetDisplayFuncCallback(display)
glutDisplayFunc()
init()
glutMainLoop()

<-->

This program is just supposed to display a teapot .

When I run it I get the following error.
C:\>python usenetviz.py
Traceback (most recent call last):
File "usenetviz.py", line 31, in ?
glutInit(' ')
TypeError: not a list

I run MS Windows (XP - SP 2)
I run Python 2.4
and the latest version of PyOpenGL compatible with the same.

Please let me know what needs to be done in this regard to fix the
above error.

I searched the archives of this newsgroup before posting this one. And
I could not get the fix to the same.

Thanks for helping.

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
After some playing around, here is how my code looks like and it works:
from OpenGL.GL import *
from OpenGL.GLUT import *
import sys

def init():
glClearColor(0, 0, 0, 0)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glLightfv(GL_LIGHT0, GL_AMBIENT,
[0.0, 0.0, 0.0, 1.0])
glLightfv(GL_LIGHT0, GL_DIFFUSE,
[1.0, 1.0, 1.0, 1.0])
glLightfv(GL_LIGHT0, GL_POSITION,
[0.0, 3.0, 3.0, 0.0])
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,
[0.2, 0.2, 0.2, 1.0])
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)

def display():
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glMaterialfv(GL_FRONT, GL_AMBIENT,
[0.1745, 0.0, 0.1, 0.0])
glMaterialfv(GL_FRONT, GL_DIFFUSE,
[0.1, 0.0, 0.6, 0.0])
glMaterialfv(GL_FRONT, GL_SPECULAR,
[0.7, 0.6, 0.8, 0.0])
glMaterialf(GL_FRONT, GL_SHININESS, 80)
glutSolidTeapot(0.5)
glFlush()

glutInit(sys.argv)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutInitWindowSize(250, 250)
glutCreateWindow('Hello GLUT')
glutDisplayFunc(display)
init()
glutMainLoop()

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.