diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-06-20 10:55:26 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-06-20 10:56:18 -0700 |
commit | 67ae1a27f32d1fc6ac6f7262fc3d22cf1003e7e3 (patch) | |
tree | 58416e871cd86b130463f772430a9add3907e61c /tests | |
parent | 6d34633796954f2edb225c66e62ab5a188d59bb0 (diff) |
support for non-square crunch textures with mipmaps
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runner.py | 6 | ||||
-rw-r--r-- | tests/s3tc_crunch.c | 32 | ||||
-rw-r--r-- | tests/s3tc_crunch.png | bin | 235053 -> 353714 bytes | |||
-rw-r--r-- | tests/water.dds | bin | 0 -> 43920 bytes |
4 files changed, 33 insertions, 5 deletions
diff --git a/tests/runner.py b/tests/runner.py index d840465d..7c4df494 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -7829,10 +7829,12 @@ elif 'browser' in str(sys.argv): def test_s3tc_crunch(self): shutil.copyfile(path_from_root('tests', 'ship.dds'), 'ship.dds') shutil.copyfile(path_from_root('tests', 'bloom.dds'), 'bloom.dds') - Popen(['python', FILE_PACKAGER, 'test.data', '--pre-run', '--crunch', '--preload', 'ship.dds', 'bloom.dds'], stdout=open('pre.js', 'w')).communicate() - assert os.stat('test.data').st_size < 0.5*(os.stat('ship.dds').st_size+os.stat('bloom.dds').st_size), 'Compressed should be smaller than dds' + shutil.copyfile(path_from_root('tests', 'water.dds'), 'water.dds') + Popen(['python', FILE_PACKAGER, 'test.data', '--pre-run', '--crunch', '--preload', 'ship.dds', 'bloom.dds', 'water.dds'], stdout=open('pre.js', 'w')).communicate() + assert os.stat('test.data').st_size < 0.5*(os.stat('ship.dds').st_size+os.stat('bloom.dds').st_size+os.stat('water.dds').st_size), 'Compressed should be smaller than dds' shutil.move('ship.dds', 'ship.donotfindme.dds') # make sure we load from the compressed shutil.move('bloom.dds', 'bloom.donotfindme.dds') # make sure we load from the compressed + shutil.move('water.dds', 'water.donotfindme.dds') # make sure we load from the compressed self.btest('s3tc_crunch.c', reference='s3tc_crunch.png', args=['--pre-js', 'pre.js']) def test_pre_run_deps(self): diff --git a/tests/s3tc_crunch.c b/tests/s3tc_crunch.c index 1169f462..57974109 100644 --- a/tests/s3tc_crunch.c +++ b/tests/s3tc_crunch.c @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) GLuint texture; { - #define DDS_SIZE 65664 + const int DDS_SIZE = 65664; FILE *dds = fopen("ship.dds", "rb"); assert(dds); char *ddsdata = (char*)malloc(DDS_SIZE); @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) GLuint texture2; { - #define DDS_SIZE 32896 + const int DDS_SIZE = 32896; FILE *dds = fopen("bloom.dds", "rb"); assert(dds); char *ddsdata = (char*)malloc(DDS_SIZE); @@ -131,6 +131,29 @@ int main(int argc, char *argv[]) glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); } + // third, a non-square texture with mipmaps + + GLuint texture3; + + { + const int DDS_SIZE = 43920; + FILE *dds = fopen("water.dds", "rb"); + assert(dds); + char *ddsdata = (char*)malloc(DDS_SIZE); + assert(fread(ddsdata, 1, DDS_SIZE, dds) == DDS_SIZE); + fclose(dds); + + glGenTextures( 1, &texture3 ); + glBindTexture( GL_TEXTURE_2D, texture3 ); + + assert(!glGetError()); + glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 512, 64, 0, 512*64, ddsdata+128); + assert(!glGetError()); + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + } + // Prepare and Render // Clear the screen before drawing @@ -154,7 +177,10 @@ int main(int argc, char *argv[]) glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 4*4, &vertexData[2]); - glDrawArrays(GL_QUADS, 0, 8); + glDrawArrays(GL_QUADS, 0, 4); + + glBindTexture( GL_TEXTURE_2D, texture3 ); + glDrawArrays(GL_QUADS, 4, 4); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); diff --git a/tests/s3tc_crunch.png b/tests/s3tc_crunch.png Binary files differindex 920f3915..383d4c5b 100644 --- a/tests/s3tc_crunch.png +++ b/tests/s3tc_crunch.png diff --git a/tests/water.dds b/tests/water.dds Binary files differnew file mode 100644 index 00000000..2a78a859 --- /dev/null +++ b/tests/water.dds |