Re: [PyOpenGL-Users] Problem with numpy arrays and OpenGL textures
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@vr...> - 2008-01-04 20:56:17
|
Adeola Bannis wrote: > Hi everyone, > > I'm doing a project using wxPython and pyopengl, and I seem to have a > problem rendering textures. This is code that worked before my hard > drive had a meltdown, but not since I re-installed everything. > > I've determined the problem is in the OpenGL part of my program. I do > some calculations to generate a 2D numpy array that holds the image > data, and pylab.imshow() shows me the image as it is meant to be. I > used the same algorithm in Octave and MATLAB, and all are giving me > the right picture. > > However, using pyOpenGL and the numpyhandler functions (http://cours- > info.iut-bm.univ-fcomte.fr/docs/python/OpenGL/ > OpenGL.arrays.numpymodule.NumpyHandler-class.html) doesn't seem to > work. I get a garbled screen pocked with black pixels. I am including > my openGL code below. What am I doing wrong? > > And yes, I did make the dtype of my array 'float32'. > When I alter your code to actually run (the attached script doesn't seem to do anything) I wind up with a working script. It does point to a bug in the current PyOpenGL 3.0.0b1's handling of void pointer arrays (they are supposed to auto-convert numpy arrays, but I had to explicitly extract a void pointer to make it work). I note that your spec for the image size is wrong, you're adding 1 to the dimensions, which should not be necessary, and could have the effect you described (garbled, with black pixels). I've attached what I'm running, so you can point out what's different. Enjoy, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |