2014-11-23 68 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')