小编Leo*_*nth的帖子

运行pyOpenGL时出现NameError

我有兴趣设置一个环境来使用 pyOpenGL 编写粒子模拟器。我已经安装了 pyOpenGL。这是测试代码,只是为了确保 opengl 正常工作。

from OpenGL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *


window = 0 
width, height = 500,400

def draw():
    glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT)           
    glLoadIdentity()

glutDwapBuffers()                                           




#initialization
glutInit()
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(width,height)
glutInitWindowPosition(0,0)
window = glutCreateWindow(b"noobtute")
glutDisplayFunc(draw)                                                                       
glutIdleFunc(draw)  
glutMainLoop()              
Run Code Online (Sandbox Code Playgroud)

但是,当我从命令运行脚本时,出现以下错误:

NameError: name 'glClear' is not defined
GLUT Display callback <function draw at 0x0000000002F8CB70> with (),{} failed: 
returning None name 'glClear' is not defined
Run Code Online (Sandbox Code Playgroud)

我尝试重新安装 pyOpengl 但没有成功。

我在 Windows 8.1 上运行 Python …

python pyopengl nameerror python-3.x windows-8.1

1
推荐指数
1
解决办法
2094
查看次数

matplotlib format offset string

So I am looking to simply format the offset string (at least that is what i think it is called, see image) that matplotlib places along with an axis that has been set to show tick labels in scientific notation, but where the range is less than one order of magnitude (power of 10).

here is what I am talking about: 在此处输入图片说明 Essentially, how do I make it bigger/coloured?

python format plot matplotlib

1
推荐指数
1
解决办法
602
查看次数