# HG changeset patch # User James Bergstra # Date 1258396672 18000 # Node ID 533b9a0a14f36fb24563b8c81a184a1600aac8d9 # Parent 04115110bb67e723665f619d2e1c14b8482fe28f Added support for still images in float storage to glviewer diff -r 04115110bb67 -r 533b9a0a14f3 pylearn/dataset_ops/glviewer.py --- a/pylearn/dataset_ops/glviewer.py Mon Nov 16 13:37:01 2009 -0500 +++ b/pylearn/dataset_ops/glviewer.py Mon Nov 16 13:37:52 2009 -0500 @@ -57,7 +57,16 @@ glPixelStorei(GL_UNPACK_ALIGNMENT,1) return glTexImage2D(GL_TEXTURE_2D, 0, 3, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf[::-1].flatten()) + elif str(x.dtype).startswith('float'): + rows, cols = x.shape + buf = numpy.zeros((rows, cols, 4), dtype='uint8') + buf += x.reshape( (rows, cols, 1)) * 255 + glPixelStorei(GL_UNPACK_ALIGNMENT,1) + debug( 'HHUH? %f'% buf.sum()) + return glTexImage2D(GL_TEXTURE_2D, 0, 3, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, + buf[::-1].flatten()) else: + debug('NOOO....') raise NotImplementedError() elif x.ndim == 3: rows, cols, channels = x.shape