2014-11-23 94 views
3

我想在Python創建與過剩的窗口,並有下面的代碼:Python的glutCreateWindow錯誤「錯誤類型」

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() 

我上「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 

這個函數的文檔指定

int glutCreateWindow(char *name); 

回答

-2

字符串

安裝:蟒蛇-3.4.0.amd64.exe

pip install image 
pip install numpy 

下載輪包來自:http://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype

有PyOpenGL-3.1.1-CP34-cp34m-win_amd64.whl

試圖安裝 PIP安裝PyOpenGL-3.1.1-CP34-cp34m-win_amd64.whl

得到消息:

PyOpenGL-3.1.1-cp34-cp34m-win_amd64.whl is not supported wheel on this platform 

升級PIP:

python -m pip --upgrade pip 

後升級它瓦特爲成功地安裝

pip install PyOpenGL-3.1.1-cp34-cp34m-win_amd64.whl 

pip install PyOpenGL_accelerate-3.1.1-cp34-cp34m-win_amd64.whl 

想跑代碼:http://noobtuts.com/python/opengl-introduction

遇到錯誤:

ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type 

變更後的功能:glutCreateWindow("name")glutCreateWindow(b'name')得到它運行。

總結:

python -m pip --upgrade pip 

pip install image 

pip install numpy 

pip install PyOpenGL-3.1.1-cp34-cp34m-win_amd64.whl 

pip install PyOpenGL_accelerate-3.1.1-cp34-cp34m-win_amd64.whl 

變化打來glutCreateWindow("name")glutCreateWindow(b'name')