Utah茶壶(http://en.wikipedia.org/wiki/Utah_teapot)
主要针对的是在使用python语言编译茶壶时出现的问题。
在写该茶壶程序时对于出现下列问题:
unctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling
或者其他类似的出现未定义的函数,解决方法为:(1)检查你安装的pyopengl库是否满足要求。
可以从这个链接 https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl 下载 你需要的版本。
(2)检查你程序运行的C:\Windows\SysWOW64(64位系统) C:\Windows\System32(32位系统)下是否缺少
glut.lib,glut32.lib运行程序,如果缺少将其添加进去就可以解决 问题了。
相关网址http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
相关代码为:
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
def drawFunc():
glClear(GL_COLOR_BUFFER_BIT)
glRotatef(1, 0, 1, 0)
glutWireTeapot(0.5)
glFlush()
glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
glutInitWindowSize(400, 400)
glutCreateWindow(b"First")
glutDisplayFunc(drawFunc)
glutIdleFunc(drawFunc)
glutMainLoop()