Thread: [PyOpenGL-Users] Attribute error using PyOpenGL and PyOpenCL
Brought to you by:
mcfletch
From: Walter W. <hom...@gm...> - 2014-09-24 11:40:23
|
Hello, I came across a problem and hope that you can help me, since I could not find a solution crawling the net. I was trying to run some examples to visualize OpenCL calculations using OpenGL with shared buffers using Python 3.3 PyOpenGL 3.1.0 PyOpenGL-accelarate 3.1.0 pyopencl 2014.1 The examples are similar, one that might serve as example is https://gitorious.org/openclgltest/openclgltest Trying to run this throws the error: Traceback (most recent call last): File ".\testpyopengl.py", line 234, in <module> mytest = test() File ".\testpyopengl.py", line 91, in __init__ self.loadclData() File ".\testpyopengl.py", line 205, in loadclData self.arr_cl = cl.GLBuffer(self.ctx, mf.READ_WRITE, int(self.arrvbo.buffers[0])) File "vbo.pyx", line 177, in OpenGL_accelerate.vbo.VBO.__ getattr__ (D:\Build\PyOpenGL\pyopengl-bzr\OpenGL_accelerate\src\vbo.c:2757) AttributeError: 'numpy.ndarray' object has no attribute 'buffers' Here are two things that might be related to the issue: 1.) PyOpenGL 3.1.0b3; Py_buffer on Python3 unsupported https://sourceforge.net/p/pyopengl/mailman/message/32385909/ 2.) This post that mentions that Python 3 might be the problem. Is that the case? http://stackoverflow.com/questions/21821045/numpy-getbuffer-causes-attributeerror-module-object-has-no-attribute-getbuff I found that another example https://github.com/enjalot/adventures_in_opencl/blob/master/python/part2/part2.py was trying to fix this like try: self.pos_cl = cl.GLBuffer(self.ctx, mf.READ_WRITE, int(self.pos_vbo.buffer)) self.col_cl = cl.GLBuffer(self.ctx, mf.READ_WRITE, int(self.col_vbo.buffer)) except AttributeError: self.pos_cl = cl.GLBuffer(self.ctx, mf.READ_WRITE, int(self.pos_vbo.buffers[0])) self.col_cl = cl.GLBuffer(self.ctx, mf.READ_WRITE, int(self.col_vbo.buffers[0])) But changing the example above like this results in Traceback (most recent call last): File ".\python-3.3.3.amd64\lib\site-packages\OpenGL\GLUT\special.py", line 130, in safeCall return function( *args, **named ) File ".\testpyopengl.py", line 182, in draw gl.glVertexPointer(4, gl.GL_FLOAT, 0, self.arrvbo) File "latebind.pyx", line 32, in OpenGL_accelerate.latebind.LateBind.__call__ (D:\Build\PyOpenGL\pyopengl-bzr\OpenGL_accelerate\src\latebind.c:992) File "wrapper.pyx", line 314, in OpenGL_accelerate.wrapper.Wrapper.__call__ (D:\Build\PyOpenGL\pyopengl-bzr\OpenGL_accelerate\src\wrapper.c:6508) File "wrapper.pyx", line 311, in OpenGL_accelerate.wrapper.Wrapper.__call__ (D:\Build\PyOpenGL\pyopengl-bzr\OpenGL_accelerate\src\wrapper.c:6442) File ".\python-3.3.3.amd64\lib\site-packages\OpenGL\platform\baseplatform.py", line 402, in __call__ return self( *args, **named ) ctypes.ArgumentError: ("argument 4: <class 'TypeError'>: wrong type", (4, GL_FLOAT, 0, <OpenGL_accelerate.vbo.VBO object at 0x0000000004752A60>)) GLUT Display callback <bound method test.draw of <__main__.test object at 0x0000000003A959B0>> with (),{} failed: returning None ("argument 4: <class 'TypeError'>: wrong type", (4, GL_FLOAT, 0, <OpenGL_accelerate.vbo.VBO object at 0x0000000004752A60>)) Well, that for now. I hope you have some ideas on how to fix this. Kind regards, Joe |
From: Mike C. F. <mcf...@vr...> - 2014-09-30 19:24:53
|
On 14-09-24 07:40 AM, Walter White wrote: > Hello, > > I came across a problem and hope that you can help me, > since I could not find a solution crawling the net. Basically the code is trying to access the "buffers" member of the VBO object. The OpenGL_accelerate version of the VBO (the cython-implemented one) does *not* have a .buffers (list), only a .buffer (int). Probably the attributes should be named _buffer and/or _buffers, as they aren't normally used by external code, the normal way to get the ID of the VBO is int(<vbo>). HTH, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |
From: Joe <hom...@gm...> - 2014-10-06 10:24:35
|
Hello, thanks for your reply. The example is working now, I replaced the buffers entry with int(<vbo>) as you suggested. But after that I ran into another problem, which I found a solution for but I don't know why it works. Here again the link to the example: https://gitorious.org/openclgltest/openclgltest/source/7b9969ef093e7bc04100a860588e6bb115731d97:testpyopengl.py#L173 There was a "wrong type" error in the last parameter of the following calls: > 173 gl.glVertexPointer(4, gl.GL_FLOAT, 0, self.arrvbo) > 175 gl.glColorPointer(4, gl.GL_FLOAT, 0, self.colvbo) I did not know what to do and changed it to "None": > 173 gl.glVertexPointer(4, gl.GL_FLOAT, 0, None) > 175 gl.glColorPointer(4, gl.GL_FLOAT, 0, None) and that worked. But I have absolutly no idea why. Why do the functions know where the vertices / colors are as I do not specify a pointer to the VBO? Has it something to do with the .bind() calls of the VBO before glVertexPointer / glColorPointer? > self.arrvbo.bind() > gl.glVertexPointer(4, gl.GL_FLOAT, 0, self.arrvbo) > self.colvbo.bind() > gl.glColorPointer(4, gl.GL_FLOAT, 0, self.colvbo) Kind regards, Joe Am 30.09.2014 21:24, schrieb Mike C. Fletcher: > On 14-09-24 07:40 AM, Walter White wrote: >> Hello, >> >> I came across a problem and hope that you can help me, >> since I could not find a solution crawling the net. > > Basically the code is trying to access the "buffers" member of the VBO > object. The OpenGL_accelerate version of the VBO (the cython-implemented > one) does *not* have a .buffers (list), only a .buffer (int). Probably > the attributes should be named _buffer and/or _buffers, as they aren't > normally used by external code, the normal way to get the ID of the VBO > is int(<vbo>). > > HTH, > Mike > |