Skip to content
Snippets Groups Projects
Commit 0a4b040e authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Rendering is broken for odd-sized images because some OpenGL renderers

seem to ignore (UN)PACK_ALIGNMENT. This doesn't fix the problem under
virtualbox though (I think the renderer simply does not support
odd-sized textures).
parent d98c6d1d
No related branches found
No related tags found
No related merge requests found
......@@ -341,12 +341,12 @@ class ImageTexture(texture.Texture, notifier.Notifier):
# first dimension as the fastest changing.
data = data.flatten(order='F')
self.bindTexture()
# Enable storage of tightly packed data of any size (i.e.
# our texture shape does not have to be divisible by 4).
gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1)
gl.glPixelStorei(gl.GL_PACK_ALIGNMENT, 1)
self.bindTexture()
gl.glPixelStorei(gl.GL_PACK_ALIGNMENT, data.dtype.alignment)
gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, data.dtype.alignment)
# set interpolation routine
interp = self.__interp
......
......@@ -261,9 +261,17 @@ class Texture2D(Texture):
raise ValueError('Invalid size: {}'.format((self.__width,
self.__height)))
data = self.__data
if data is not None:
data = data.ravel('F')
alignment = data.dtype.alignemnt
else:
alignment = 1
self.bindTexture()
gl.glPixelStorei(gl.GL_PACK_ALIGNMENT, 1)
gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1)
gl.glPixelStorei(gl.GL_PACK_ALIGNMENT, alignment)
gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, alignment)
gl.glTexParameteri(gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MAG_FILTER,
......@@ -278,11 +286,6 @@ class Texture2D(Texture):
gl.GL_TEXTURE_WRAP_T,
gl.GL_CLAMP_TO_BORDER)
data = self.__data
if data is not None:
data = data.ravel('F')
log.debug('Configuring {} ({}) with size {}x{}'.format(
type(self).__name__,
self.getTextureHandle(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment