I am starting to learn OpenGL and I tried to run the program in this tutorial. This is the code I have got together from that page. I had to lower the GLSL version in the shaders to get it to run at all on my laptop (they were 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()
This is the error I am getting if I run the program. The error repeats if I move my mouse on top of the small window that appears, so the app is alive, but not really functional. The window shows what was behind it when the app started, so no real picture.
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'
I am a complete noob when it comes to OpenGL, so I really don't know where to start looking for a problem, as it is not even directly from my code, but by some callback. Do I have somehow incompatible packages?
My versions:
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)
The error is a bug in one of the libraries used and not in your code. Essentially Python tells you, that the way perspectiveMatrix
is invoked liked, doesn't match the actual signature of the function.
You need to file a bug report with the creators of the libraries you use.