我开始学习OpenGL,我尝试在这个教程中运行这个程序。这是我从那一页上收集到的代码。我不得不降低GLSL版本的着色器,使它在我的笔记本电脑上运行(他们是330)。
from OpenGLContext import testingcontext
BaseContext = testingcontext.getInteractive()
from OpenGL.GL import *
from OpenGL.arrays import vbo
from OpenGLContext.arrays import *
from OpenGL.GL import shaders
class TestContext( BaseContext ):
"""Creates a simple vertex shader..."""
def OnInit(self):
VERTEX_SHADER = shaders.compileShader("""
#version 130
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
""", GL_VERTEX_SHADER)
FRAGMENT_SHADER = shaders.compileShader("""
#version 130
void main() {
gl_FragColor = vec4(0, 1, 0, 1);
}""", GL_FRAGMENT_SHADER)
self.shader = shaders.compileProgram(VERTEX_SHADER, FRAGMENT_SHADER)
self.vbo = vbo.VBO(
array( [
[ 0, 1, 0 ],
[ -1,-1, 0 ],
[ 1,-1, 0 ],
[ 2,-1, 0 ],
[ 4,-1, 0 ],
[ 4, 1, 0 ],
[ 2,-1, 0 ],
[ 4, 1, 0 ],
[ 2, 1, 0 ],
],'f')
)
def render(self, mode):
shaders.glUseProgram(self.shader)
try:
self.vbo.bind()
try:
glEnableClientState(GL_VERTEX_ARRAY)
glVertexPointerf(self.vbo)
glDrawArrays(GL_TRIANGLES, 0, 9)
finally:
self.vbo.unbind()
glDisableClientState(GL_VERTERX_ARRAY)
finally:
shaders.glUseProgram(0)
if __name__ == "__main__":
TestContext.ContextMainLoop()如果我运行这个程序,这就是我得到的错误。如果我将鼠标移动到出现的小窗口上,这个错误就会重复发生,所以应用程序是活的,但没有真正的功能。这个窗口显示了应用程序启动时它背后的内容,所以没有真正的图片。
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 314, in 'calling callback function'
File "/usr/lib/python2.7/site-packages/OpenGLContext/events/glutevents.py", line 33, in glutOnMouseMove
self.triggerPick()
File "/usr/lib/python2.7/site-packages/OpenGLContext/context.py", line 590, in triggerPick
self.OnDraw()
File "/usr/lib/python2.7/site-packages/OpenGLContext/context.py", line 515, in OnDraw
visibleChange = self.renderPasses( self )
File "/usr/lib/python2.7/site-packages/OpenGLContext/passes/renderpass.py", line 866, in __call__
return FLAT( context )
File "/usr/lib/python2.7/site-packages/OpenGLContext/passes/flatcompat.py", line 298, in __call__
self.setViewPlatform( vp )
File "/usr/lib/python2.7/site-packages/OpenGLContext/passes/flatcompat.py", line 334, in setViewPlatform
self.projection = vp.viewMatrix().astype('f')
File "/usr/lib/python2.7/site-packages/OpenGLContext/move/viewplatform.py", line 158, in viewMatrix
inverse=inverse,
File "tmatrixaccel.pyx", line 55, in vrml_accelerate.tmatrixaccel.perspectiveMatrix (src/tmatrixaccel.c:1990)
TypeError: perspectiveMatrix() got an unexpected keyword argument 'inverse'对于OpenGL,我是一个完全的新手,所以我真的不知道从哪里开始寻找问题,因为它甚至不是直接从我的代码中,而是通过一些回调。我有不兼容的包裹吗?
我的版本:
Python 2.7.5 (default, Oct 8 2013, 12:19:40)
[GCC 4.8.1 20130603 (Red Hat 4.8.1-1)] on linux2
PyOpenGL - Standard OpenGL bindings for Python
INSTALLED: 3.1.0a3 (latest)
OpenGLContext - Demonstration and testing contexts for PyOpenGL/OpenGL-ctypes
INSTALLED: 2.2.0a3 (latest)
PyOpenGL-accelerate - Acceleration code for PyOpenGL
INSTALLED: 3.1.0a3 (latest)
OpenGLContext-full - Installs all of OpenGLContext with optional dependencies
INSTALLED: 2.1.0a9 (latest)发布于 2013-11-08 16:11:41
错误是使用的一个库中的错误,而不是代码中的错误。本质上,Python告诉您,调用perspectiveMatrix的方式很受欢迎,与函数的实际签名不匹配。
您需要向您使用的库的创建者提交一个bug报告。
https://stackoverflow.com/questions/19861762
复制相似问题