sole@... wrote:
> Hello,
>
> Quoting "Mike C. Fletcher" <mcfletch@...>:
>
>
>> ... Can you produce a minimal test that shows
>> the error occurring? The system *should* be able to convert from double
>> to float (as shown with this test). Could be that it's some bug I don't
>> recall fixing, but that doesn't seem likely.
>>
>>
>
> I send you a file showing the problem.
>
> python OpenGLTest.py 0 uses float32
> python OpenGLTest.py 1 uses float64 and crashes
> python OpenGLTest.py 2 uses float64 and glColorPointerd and does not crash.
>
> My platform is windows XP. The problem is present on Python 2.4 and Python 2.5
>
The problem was actually in the caching of the temporary array. Under
the covers, PyOpenGL has to retain a copy of the copied array in order
to prevent it going out of scope and causing crashes. There was a bug
in the code that stores the copy, so that it was recording based on the
array data-type (e.g. float) rather than the array role (e.g. vertex
array). So if you used two arrays that both had to be converted and
both were of the same final type, you'd overwrite the one array with the
next and wind up with a crash when you tried to access the data in the
first array.
This patch seems to fix the issue:
Index: OpenGL/GL/pointers.py
===================================================================
RCS file: /cvsroot/pyopengl/OpenGL-ctypes/OpenGL/GL/pointers.py,v
retrieving revision 1.22
diff -C3 -r1.22 pointers.py
*** OpenGL/GL/pointers.py 8 Feb 2007 02:24:40 -0000 1.22
--- OpenGL/GL/pointers.py 9 Oct 2007 02:13:50 -0000
***************
*** 105,120 ****
function= wrapper.wrapper( baseFunction )
assert not getattr( function, 'pyConverters', None ), """Reusing
wrappers?"""
if arrayType:
! arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[ glType ]
! function.setPyConverter( 'pointer',
arrays.asArrayType(arrayType) )
! function.setCResolver( 'pointer',
arrayType.voidDataPointer )
else:
function.setPyConverter( 'pointer',
arrays.AsArrayOfType('pointer','type') )
function.setCResolver( 'pointer',
arrays.ArrayDatatype.voidDataPointer )
function.setCConverter( 'pointer', converters.getPyArgsName(
'pointer' ) )
if 'size' in function.argNames:
function.setPyConverter( 'size' )
! function.setCConverter( 'size',
arrays.arraySizeOfFirstType(arrayType,defaultSize) )
if 'type' in function.argNames:
function.setPyConverter( 'type' )
function.setCConverter( 'type', glType )
--- 105,120 ----
function= wrapper.wrapper( baseFunction )
assert not getattr( function, 'pyConverters', None ), """Reusing
wrappers?"""
if arrayType:
! arrayModuleType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[ glType ]
! function.setPyConverter( 'pointer',
arrays.asArrayType(arrayModuleType) )
! function.setCResolver( 'pointer',
arrayModuleType.voidDataPointer )
else:
function.setPyConverter( 'pointer',
arrays.AsArrayOfType('pointer','type') )
function.setCResolver( 'pointer',
arrays.ArrayDatatype.voidDataPointer )
function.setCConverter( 'pointer', converters.getPyArgsName(
'pointer' ) )
if 'size' in function.argNames:
function.setPyConverter( 'size' )
! function.setCConverter( 'size',
arrays.arraySizeOfFirstType(arrayModuleType,defaultSize) )
if 'type' in function.argNames:
function.setPyConverter( 'type' )
function.setCConverter( 'type', glType )
> BTW, glReadPixelsub(x, y, 1, 1, GL_RGBA) returns 'int8' instead of 'uint8' and I
> am forced to implement things like:
>
> color = GL.glReadPixelsub(x, y, 1, 1, GL.GL_RGBA)
> #workaround a PyOpenGL bug?
> if color.dtype == 'int8':
> color = color.astype(numpy.uint8)
I'm using glReadPixelsub in the readpixelleak test in OpenGLContext and
the result is coming back as a uint8 array there. Sorry to be a pain,
but have you got a bit of code where I could see the failure (it's
pretty easy to fire up pdb and trace through the wrappers to see where
something goes wrong with the 3.x version)?
HTH, and thanks for the bug report,
Mike
--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
|