大佬教程收集整理的这篇文章主要介绍了NameError: 名称 'glutInit' 未定义,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在关注此 guide 以进行我的计划活动
我安装了 pip install PyOpenGL PyOpenGL_accelerate ,一切都很好。
我通过测试代码测试了安装:
import OpenGl.GL import OpenGl.gluT import OpenGl.glu print("imports success!") # 如果你看到这个打印到控制台,那么安装成功
一切顺利
我现在运行这个脚本:
import OpenGL
import OpenGl.GL
import OpenGl.gluT
import OpenGl.glu
print("imports successful!") # If you see this printed to the console then installation was successful
def showScreen():
glClear(GL_color_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # Remove everything from screen (i.e. displays all whitE)
gluTinit() # Initialize a glut instance which will allow us to customize our window
gluTinitdisplaymode(gluT_RGBA) # Set the display mode to be colored
gluTinitwindowsize(500,500) # Set the wIDth and height of your window
gluTinitwindowposition(0,0) # Set the position at which this windows should appear
wind = glutCreateWindow("OpenGL Coding Practice") # Give your window a title
glutdisplayFunc(showScreen) # Tell OpenGL to call the showScreen method conTinuously
glutIDleFunc(showScreen) # Draw any graphics or shapes in the showScreen function at all times
glutMainLoop() # Keeps the window created above displaying/running in a loop
我在终端中得到了这个:
Python 3.7.9 (tags/v3.7.9:13c94747c7,Aug 17 2020,16:30:00) [MSC v.1900 64 bit (AMD64)] on win32
Type "Help","copyright","credits" or "license" for more information.
>>> import OpenGL
>>> import OpenGl.GL
>>> import OpenGl.gluT
>>> import OpenGl.glu
>>> print("imports successful!") # If you see this printed to the console then installation was successful
imports successful!
>>> def showScreen():
... glClear(GL_color_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # Remove everything from screen (i.e. displays all whitE)
...
>>> gluTinit() # Initialize a glut instance which will allow us to customize our window
TraceBACk (most recent call last):
file "<stdin>",line 1,in <module>
nameError: name 'gluTinit' is not defined
>>> gluTinitdisplaymode(gluT_RGBA) # Set the display mode to be colored
TraceBACk (most recent call last):
file "<stdin>",in <module>
nameError: name 'gluTinitdisplaymode' is not defined
>>> gluTinitwindowsize(500,500) # Set the wIDth and height of your window
TraceBACk (most recent call last):
file "<stdin>",in <module>
nameError: name 'gluTinitwindowsize' is not defined
>>> gluTinitwindowposition(0,0) # Set the position at which this windows should appear
TraceBACk (most recent call last):
file "<stdin>",in <module>
nameError: name 'gluTinitwindowposition' is not defined
>>> wind = glutCreateWindow("OpenGL Coding Practice") # Give your window a title
TraceBACk (most recent call last):
file "<stdin>",in <module>
nameError: name 'glutCreateWindow' is not defined
>>> glutdisplayFunc(showScreen) # Tell OpenGL to call the showScreen method conTinuously
TraceBACk (most recent call last):
file "<stdin>",in <module>
nameError: name 'glutdisplayFunc' is not defined
>>> glutIDleFunc(showScreen) # Draw any graphics or shapes in the showScreen function at all times
TraceBACk (most recent call last):
file "<stdin>",in <module>
nameError: name 'glutIDleFunc' is not defined
>>> glutMainLoop() # Keeps the window created above displaying/running in a loop
TraceBACk (most recent call last):
file "<stdin>",in <module>
nameError: name 'glutMainLoop' is not defined
我使用 Visual studio Code 作为编译器
我遵循了此 similar question 的答案,但它导致我出现此错误:
pip install PyOpenGL-3.1.5-cp39-cp39-win_amd64.whl
WARNING: requirement 'PyOpenGL‑3.1.5‑cp39‑cp39‑win_amd64.whl' looks like a filename,but the file does not exist
ERROR: PyOpenGL‑3.1.5‑cp39‑cp39‑win_amd64.whl is not a valID wheel filename.
我已经下载了所述的 .whl 文件
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的NameError: 名称 'glutInit' 未定义全部内容,希望文章能够帮你解决NameError: 名称 'glutInit' 未定义所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。