Re: [PyOpenGL-Users] Upcoming fix may cause minor incompatibility...
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2004-10-16 23:48:07
|
Just to expand a little on this: glDrawPixelsXX previously was working on the assumption that the graphics passed to it were stored such that array[0] was the first row. This meant that if you did array.tostring() and passed the array dimensions in to glDrawPixels you would wind up with a trashed image (since Numpy packs arrays to strings from the lowest dimension up). By switching to assuming that array[0] gives the first column of the image (that is, that the first dimension represents the index *into* the first row), we are basically using the natural order of the array and also making the two types of glDrawPixels calls match up as expected; so that array[20,30] is the pixel twenty from the right and 30 from the bottom, and dumping to a string and passing array dimensions works the same as passing in the array. I've so far come across 1 instance of an incompatibility in OpenGLContext. It actually turned out to be quite nasty (the work-around works fine, but figuring out how to eliminate the huge series of convolutions through which the code goes at the moment has been a bit of a pain...). Have fun all, Mike Mike C. Fletcher wrote: > I've just checked in changes on the 2.0.1 maintenance branch that fix > a bug in how glDrawPixelsXX (that is, all glDrawPixels calls which > take an array argument, rather than a string) operates. The code was > previously (unintentionally) reversing the first and second arguments, > so that it would take (height,width) rather than (width,height) from > the array to decide how to render it. > > If you have any code that uses glDrawPixelsXX you will find that this > fix causes your code to stop working. Solution is simply to use > properly-sized arrays (i.e. if you want an image 300x100 pixels wide > it's shape should be (300,100,depth), rather than (100,300,depth)). > If you can't make that change, then simply assigning array.shape = > (array.shape[1],array.shape[0]) + array.shape(2:]) will allow you to > continue operating as before. > > This bug does not affect string-based glDrawPixels calls. > > Enjoy yourselves, > Mike ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |