diff --git a/tests/test_texture_formats.h b/tests/test_texture_formats.h index 172e0c9..0e9c0e0 100644 --- a/tests/test_texture_formats.h +++ b/tests/test_texture_formats.h @@ -188,6 +188,11 @@ public: /* ------------------------------------------------- glTexSubImage2D */ void test_subimage_updates_only_target_region() { + /* The 2-wide RGB sub-image below is tightly packed (6 bytes/row), so it + * does not satisfy the default GL_UNPACK_ALIGNMENT of 4 (which would pad + * each row to 8 bytes). Tell GL the rows are tightly packed. */ + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + /* Start with an all-black 16x16 RGB565 texture. */ std::vector img(16 * 16 * 3, 0); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, img.data()); diff --git a/tools/gl_test.h b/tools/gl_test.h index 152fb4b..1ad3a6a 100644 --- a/tools/gl_test.h +++ b/tools/gl_test.h @@ -78,6 +78,10 @@ public: glDepthFunc(GL_LESS); glShadeModel(GL_SMOOTH); + /* Restore the spec default so a test that changes pixel-store state + * doesn't leak into the next (we no longer re-init per test). */ + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glBindTexture(GL_TEXTURE_2D, 0); glMatrixMode(GL_PROJECTION); glLoadIdentity();