diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-06-18 14:39:30 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-06-18 14:39:30 -0700 |
commit | b72e2aaedfc3df159312fda3b2ecd355584e7281 (patch) | |
tree | 4b2257c21148d55ea7abf83f5740753a54f5a1c8 | |
parent | bb0ef4922b40822df62a72fb344a1f7e87bba350 (diff) |
test for decrunching more than one image
-rw-r--r-- | tests/bloom.dds | bin | 0 -> 32896 bytes | |||
-rwxr-xr-x | tests/runner.py | 6 | ||||
-rw-r--r-- | tests/s3tc_crunch.c | 55 | ||||
-rw-r--r-- | tests/s3tc_crunch.png | bin | 224849 -> 235053 bytes |
4 files changed, 44 insertions, 17 deletions
diff --git a/tests/bloom.dds b/tests/bloom.dds Binary files differnew file mode 100644 index 00000000..ed51ab51 --- /dev/null +++ b/tests/bloom.dds diff --git a/tests/runner.py b/tests/runner.py index 5372034e..861277e6 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -7809,9 +7809,11 @@ elif 'browser' in str(sys.argv): def test_s3tc_crunch(self): shutil.copyfile(path_from_root('tests', 'ship.dds'), 'ship.dds') - Popen(['python', FILE_PACKAGER, 'test.data', '--pre-run', '--crunch', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate() - assert os.stat('test.data').st_size < 0.5*os.stat('ship.dds').st_size, 'Compressed should be smaller than 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.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 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 9e642e7d..1169f462 100644 --- a/tests/s3tc_crunch.c +++ b/tests/s3tc_crunch.c @@ -85,27 +85,51 @@ int main(int argc, char *argv[]) glLoadIdentity(); - // Load the OpenGL texture + // Load the OpenGL textures GLuint texture; - #define DDS_SIZE 65664 - FILE *dds = fopen("ship.dds", "rb"); - assert(dds); - char *ddsdata = (char*)malloc(DDS_SIZE); - assert(fread(ddsdata, 1, DDS_SIZE, dds) == DDS_SIZE); - fclose(dds); - - glGenTextures( 1, &texture ); - glBindTexture( GL_TEXTURE_2D, texture ); + { + #define DDS_SIZE 65664 + FILE *dds = fopen("ship.dds", "rb"); + assert(dds); + char *ddsdata = (char*)malloc(DDS_SIZE); + assert(fread(ddsdata, 1, DDS_SIZE, dds) == DDS_SIZE); + fclose(dds); + + glGenTextures( 1, &texture ); + glBindTexture( GL_TEXTURE_2D, texture ); + + assert(!glGetError()); + glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 256, 256, 0, DDS_SIZE-128, ddsdata+128); + assert(!glGetError()); + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + } - assert(!glGetError()); - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 256, 256, 0, DDS_SIZE-128, ddsdata+128); - assert(!glGetError()); + // second texture - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + GLuint texture2; + { + #define DDS_SIZE 32896 + FILE *dds = fopen("bloom.dds", "rb"); + assert(dds); + char *ddsdata = (char*)malloc(DDS_SIZE); + assert(fread(ddsdata, 1, DDS_SIZE, dds) == DDS_SIZE); + fclose(dds); + + glGenTextures( 1, &texture2 ); + glBindTexture( GL_TEXTURE_2D, texture2 ); + + assert(!glGetError()); + glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 256, 256, 0, DDS_SIZE-128, 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 @@ -136,6 +160,7 @@ int main(int argc, char *argv[]) glDisableClientState(GL_VERTEX_ARRAY); // Render the last item using oldschool glBegin etc + glBindTexture( GL_TEXTURE_2D, texture2 ); glBegin( GL_TRIANGLE_STRIP ); glTexCoord2i( 0, 0 ); glVertex3f( 100, 300, 0 ); glTexCoord2i( 1, 0 ); glVertex3f( 300, 300, 0 ); diff --git a/tests/s3tc_crunch.png b/tests/s3tc_crunch.png Binary files differindex d320bf61..920f3915 100644 --- a/tests/s3tc_crunch.png +++ b/tests/s3tc_crunch.png |