2014-07-12 48 views
0

我剛剛在Mac OS 10.6.8上安裝了python 2.7(.6)。我通過自制軟件安裝了python,我需要的許多模塊都可以通過pip來完成,剩下的從源碼編譯。PyOpenGL沒有數組類型處理程序類型<class'ctypes.c_ubyte'>

我正在用Pygame和PyOpenGL製作遊戲。遊戲在我以前的python安裝(2.6版本)上運行良好,但不幸的是pygame/SDL中的某些內容出錯了,它不會再加載PNG,所以我覺得是時候更新了。但是,我知道這個代碼運行。

所有的模塊導入都很好,但glTexImage2D失敗。代碼片段:

import numpy 
from OpenGL.GL import * 
from OpenGL.arrays import vbo 
from OpenGLContext.arrays import * 
from OpenGL.GL import shaders 
from OpenGL.GLU import * 

--- snip --- 

def makeTexture(self, image, w, h, name = False): 
    texture = glGenTextures(1) 
    glActiveTexture(GL_TEXTURE0) 
    glBindTexture(GL_TEXTURE_2D, texture) 
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w,h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image) 
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) 
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) 
    if name: 
     self.textures[name] = texture 
    else: 
     self.texture = texture 

和錯誤:

Traceback (most recent call last): 
--- snip --- 
    File "GameParts/Shader.py", line 88, in makeTexture 
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w,h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image) 
    File "latebind.pyx", line 32, in OpenGL_accelerate.latebind.LateBind.__call__ (src/latebind.c:989) 
    File "wrapper.pyx", line 314, in OpenGL_accelerate.wrapper.Wrapper.__call__ (src/wrapper.c:6505) 
ctypes.ArgumentError: ("argument 9: <type 'exceptions.TypeError'>: No array-type handler for type <class 'ctypes.c_ubyte'> (value: c_ubyte(0)) registered", (GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, c_ubyte(0))) 

$ pip list 
mercurial (2.9.2) 
numpy (1.8.1) 
OpenGLContext (2.3.0b1) 
Pillow (2.5.1) 
pip (1.5.4) 
PyDispatcher (2.0.3) 
pygame (1.9.2a0) 
PyOpenGL (3.1.0) 
PyOpenGL-accelerate (3.1.0) 
PyOpenGL-Demo (3.0.1b1) 
PyVRML97 (2.3.0a3) 
setuptools (3.4.1) 
wsgiref (0.1.2) 
wxPython (3.0.0.0) 
wxPython-common (3.0.0.0) 

據我所知,這可能是與秩序的東西的問題進行了安裝?

回答

0

我通過「image」傳遞了錯誤的數據 - 這是我的錯誤。真正的問題是爲什麼它在第一個地方工作...

相關問題