Python glutCreateWindow错误'错误类型'

Gre*_*ims 6 python glut glutcreatewindow

我正在尝试在python中创建一个过剩的窗口,并具有以下代码:

glutInit()
    glutInitWindowSize(windowWidth, windowHeight)
    glutInitWindowPosition(int(centreX - windowWidth/2), int(centreY - windowHeight/2))
    glutCreateWindow("MyWindow")
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
    glutDisplayFunc(displayFun)
    glutIdleFunc(animateFun)
    glutKeyboardFunc(keyboardFun)
    glutPassiveMotionFunc(mouseFun)

    glutReshapeFunc(reshapeFun)
    initFun()
    #loadTextures()
    glutMainLoop()
Run Code Online (Sandbox Code Playgroud)

我在'glutCreateWindow'一行中收到错误说:

Traceback (most recent call last):
  File "F:\MyProject\main.py", line 301, in <module>
    glutCreateWindow("MyWindow")
  File "C:\Python34\lib\site-packages\OpenGL\GLUT\special.py", line 73, in glutCreateWindow
    return __glutCreateWindowWithExit(title, _exitfunc)
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
Run Code Online (Sandbox Code Playgroud)

有关此函数的文档指定

int glutCreateWindow(char *name);
Run Code Online (Sandbox Code Playgroud)

小智 18

我刚遇到完全相同的问题,发现此博客条目:

http://codeyarns.com/2012/04/27/pyopengl-glut-ctypes-error/

基本上,您需要指定传递字节数据而不是使用字符串 b'Window Title'