Commit d9cdd85a authored by Janis Born's avatar Janis Born

use provided pixel unpack alignment when setting Texture data from a TextureData object

fixes #1826
parent 004694a7
......@@ -266,6 +266,7 @@ SharedTextureData loadTextureDataFromLodepng(const std::string &_filename, Color
data->setHeight(height);
data->setType(glType);
data->setFormat(glFormat);
data->setPadding(0); // LodePNG data has no padding
data->setColorSpace(_colorSpace); // no auto-detection
// Flip
......
......@@ -594,11 +594,16 @@ bool TextureCubeMap::cubeSideIsValid( const GLenum _cubeSide ) const
return false;
}
void TextureCubeMap::texImage2DCube( const SharedTextureData &_data, GLenum _cubeSide, GLint _mipmapLevel )
{
mWidth = _data->getWidth();
mHeight = _data->getHeight();
GLint previousUnpackAlignment;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &previousUnpackAlignment);
glPixelStorei(GL_UNPACK_ALIGNMENT, std::min(_data->getPackAlignment(), 8));
bind();
glTexImage2D(
_cubeSide,
......@@ -609,10 +614,16 @@ void TextureCubeMap::texImage2DCube( const SharedTextureData &_data, GLenum _cub
_data->getFormat(),
_data->getType(),
_data->getData() );
glPixelStorei(GL_UNPACK_ALIGNMENT, previousUnpackAlignment);
}
void TextureCubeMap::texSubImage2DCube( const SharedTextureData &_data, GLenum _cubeSide, GLint _mipmapLevel, glm::ivec2 _offset )
{
GLint previousUnpackAlignment;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &previousUnpackAlignment);
glPixelStorei(GL_UNPACK_ALIGNMENT, std::min(_data->getPackAlignment(), 8));
bind();
glTexSubImage2D(
_cubeSide,
......@@ -622,6 +633,8 @@ void TextureCubeMap::texSubImage2DCube( const SharedTextureData &_data, GLenum _
_data->getFormat(),
_data->getType(),
_data->getData() );
glPixelStorei(GL_UNPACK_ALIGNMENT, previousUnpackAlignment);
}
......@@ -630,6 +643,10 @@ void TextureBase::texImage1D( const SharedTextureData &_data, GLint _mipmapLevel
{
mWidth = _data->getWidth();
GLint previousUnpackAlignment;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &previousUnpackAlignment);
glPixelStorei(GL_UNPACK_ALIGNMENT, std::min(_data->getPackAlignment(), 8));
bind();
glTexImage1D(
mTarget,
......@@ -640,6 +657,8 @@ void TextureBase::texImage1D( const SharedTextureData &_data, GLint _mipmapLevel
_data->getFormat(),
_data->getType(),
_data->getData() );
glPixelStorei(GL_UNPACK_ALIGNMENT, previousUnpackAlignment);
}
void TextureBase::texSubImage1D( const SharedTextureData &_data, GLint _mipmapLevel, uint32_t _offset )
......@@ -647,6 +666,10 @@ void TextureBase::texSubImage1D( const SharedTextureData &_data, GLint _mipmapLe
bind();
GLsizei w = std::min( mWidth, _data->getWidth() );
GLint previousUnpackAlignment;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &previousUnpackAlignment);
glPixelStorei(GL_UNPACK_ALIGNMENT, std::min(_data->getPackAlignment(), 8));
glTexSubImage1D(
mTarget,
_mipmapLevel,
......@@ -655,6 +678,8 @@ void TextureBase::texSubImage1D( const SharedTextureData &_data, GLint _mipmapLe
_data->getFormat(),
_data->getType(),
_data->getData() );
glPixelStorei(GL_UNPACK_ALIGNMENT, previousUnpackAlignment);
}
void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel )
......@@ -663,6 +688,11 @@ void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel
mHeight = _data->getHeight();
bind();
GLint previousUnpackAlignment;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &previousUnpackAlignment);
glPixelStorei(GL_UNPACK_ALIGNMENT, std::min(_data->getPackAlignment(), 8));
glTexImage2D(
mTarget,
_mipmapLevel,
......@@ -672,6 +702,8 @@ void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel
_data->getFormat(),
_data->getType(),
_data->getData() );
glPixelStorei(GL_UNPACK_ALIGNMENT, previousUnpackAlignment);
}
void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec2 _offset )
......@@ -679,6 +711,10 @@ void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLe
GLsizei w = std::min( mWidth, _data->getWidth() );
GLsizei h = std::max( std::min( mHeight, _data->getHeight() ), 1);
GLint previousUnpackAlignment;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &previousUnpackAlignment);
glPixelStorei(GL_UNPACK_ALIGNMENT, std::min(_data->getPackAlignment(), 8));
bind();
glTexSubImage2D(
mTarget,
......@@ -688,6 +724,8 @@ void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLe
_data->getFormat(),
_data->getType(),
_data->getData() );
glPixelStorei(GL_UNPACK_ALIGNMENT, previousUnpackAlignment);
}
......@@ -697,6 +735,10 @@ void TextureBase::texImage3D( const SharedTextureData &_data, GLint _mipmapLevel
mHeight = _data->getHeight();
mDepth = _data->getDepth();
GLint previousUnpackAlignment;
glGetIntegerv(GL_UNPACK_ALIGNMENT, &previousUnpackAlignment);
glPixelStorei(GL_UNPACK_ALIGNMENT, std::min(_data->getPackAlignment(), 8));
bind();
glTexImage3D(
mTarget,
......@@ -707,6 +749,8 @@ void TextureBase::texImage3D( const SharedTextureData &_data, GLint _mipmapLevel
_data->getFormat(),
_data->getType(),
_data->getData() );
glPixelStorei(GL_UNPACK_ALIGNMENT, previousUnpackAlignment);
}
void TextureBase::texSubImage3D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec3 _offset )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment