Re: [PyOpenGL-Users] Problem with numpy arrays and OpenGL textures
Brought to you by:
mcfletch
From: Adeola B. <the...@gm...> - 2008-01-08 15:10:25
|
Well, Now I have a recognisable image that just seems to be "twisted funny" (not again...), after I decided to use GL_UNSIGNED_BYTE instead of GL_FLOAT. I think the strange orientation of my picture might just be due to placing the corners in the wrong order or some such. Last time, I resolved the whole "twisted funny" problem with an offset of +/-1. It's also a bit dark, but that's definitely fixable. Here's a picture of the "funny looking" image to compare to the "good" image I sent earlier. Thank you so much for all your help - I think the ctypes call made the difference between rendering gook and rendering the texture. Adeola On Jan 5, 2008 5:03 PM, Mike C. Fletcher <mcf...@vr...> wrote: > Adeola Bannis wrote: > > Thanks Mike, > > > > It wasn't so much a script I sent as a class definition. There > > probably should have been some main function for testing, but I didn't > > feel like writing up the wxApp. > > > > I don't currently have OpenGLContext installed, so I can't (yet) > > directly run your code. > > The +1 in the dimensions were necessary in my code before, at least in > > the horizontal direction - otherwise the image had a characteristic > > "twist". I had already tried it without them, but with little > > improvement. If you're interested I've attached the image I get with > > pylab.imshow() and the image I get on my GLCanvas. > > > > I tried the image.ctypes.data_as() conversion, but then my program > > segfaults whenever it gets to the gluBuild2DMipmaps call. > > > The problem I'm having here is that I can't reproduce your failure, as > your code doesn't seem to include the failing code (though as I > mentioned, the off-by-one dimensions are suspicious). I've got my > float-based image displaying properly with the code I sent you. The > most likely sources of segfaulting is that you're passing a > non-contiguous array, or you are passing dimensions that are too large. > Either one will cause OpenGL to overstep it's array bounds. In your > code you are calling contiguous and then throwing away the result IIRC, > any chance you intended to use those results? > > Good luck, > > Mike > > -- > ________________________________________________ > Mike C. Fletcher > Designer, VR Plumber, Coder > http://www.vrplumber.com > http://blog.vrplumber.com > > |