Possible fix for #738

Explicitly set byte alignment in pixel transfer operations
master
Piotr Dziwinski 2016-03-22 23:27:54 +13:00
parent 08f3a03547
commit 926f7cf115
3 changed files with 18 additions and 0 deletions

View File

@ -823,6 +823,9 @@ Texture CGL21Device::CreateTexture(ImageData *data, const TextureCreateParams &p
PreparedTextureData texData = PrepareTextureData(data, params.format);
result.alpha = texData.alpha;
glPixelStorei(GL_UNPACK_ROW_LENGTH, texData.actualSurface->pitch / texData.actualSurface->format->BytesPerPixel);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texData.actualSurface->w, texData.actualSurface->h,
0, texData.sourceFormat, GL_UNSIGNED_BYTE, texData.actualSurface->pixels);
@ -894,6 +897,9 @@ void CGL21Device::UpdateTexture(const Texture& texture, Math::IntPoint offset, I
PreparedTextureData texData = PrepareTextureData(data, format);
glPixelStorei(GL_UNPACK_ROW_LENGTH, texData.actualSurface->pitch / texData.actualSurface->format->BytesPerPixel);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexSubImage2D(GL_TEXTURE_2D, 0, offset.x, offset.y, texData.actualSurface->w, texData.actualSurface->h,
texData.sourceFormat, GL_UNSIGNED_BYTE, texData.actualSurface->pixels);

View File

@ -852,6 +852,9 @@ Texture CGL33Device::CreateTexture(ImageData *data, const TextureCreateParams &p
PreparedTextureData texData = PrepareTextureData(data, params.format);
result.alpha = texData.alpha;
glPixelStorei(GL_UNPACK_ROW_LENGTH, texData.actualSurface->pitch / texData.actualSurface->format->BytesPerPixel);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texData.actualSurface->w, texData.actualSurface->h,
0, texData.sourceFormat, GL_UNSIGNED_BYTE, texData.actualSurface->pixels);
@ -921,6 +924,9 @@ void CGL33Device::UpdateTexture(const Texture& texture, Math::IntPoint offset, I
PreparedTextureData texData = PrepareTextureData(data, format);
glPixelStorei(GL_UNPACK_ROW_LENGTH, texData.actualSurface->pitch / texData.actualSurface->format->BytesPerPixel);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexSubImage2D(GL_TEXTURE_2D, 0, offset.x, offset.y, texData.actualSurface->w, texData.actualSurface->h,
texData.sourceFormat, GL_UNSIGNED_BYTE, texData.actualSurface->pixels);

View File

@ -725,6 +725,9 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par
PreparedTextureData texData = PrepareTextureData(data, params.format);
result.alpha = texData.alpha;
glPixelStorei(GL_UNPACK_ROW_LENGTH, texData.actualSurface->pitch / texData.actualSurface->format->BytesPerPixel);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texData.actualSurface->w, texData.actualSurface->h,
0, texData.sourceFormat, GL_UNSIGNED_BYTE, texData.actualSurface->pixels);
@ -826,6 +829,9 @@ void CGLDevice::UpdateTexture(const Texture& texture, Math::IntPoint offset, Ima
PreparedTextureData texData = PrepareTextureData(data, format);
glPixelStorei(GL_UNPACK_ROW_LENGTH, texData.actualSurface->pitch / texData.actualSurface->format->BytesPerPixel);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexSubImage2D(GL_TEXTURE_2D, 0, offset.x, offset.y, texData.actualSurface->w, texData.actualSurface->h,
texData.sourceFormat, GL_UNSIGNED_BYTE, texData.actualSurface->pixels);