summaryrefslogtreecommitdiff
path: root/tests/s3tc_crunch.c
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-06-20 10:55:26 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-06-20 10:56:18 -0700
commit67ae1a27f32d1fc6ac6f7262fc3d22cf1003e7e3 (patch)
tree58416e871cd86b130463f772430a9add3907e61c /tests/s3tc_crunch.c
parent6d34633796954f2edb225c66e62ab5a188d59bb0 (diff)
support for non-square crunch textures with mipmaps
Diffstat (limited to 'tests/s3tc_crunch.c')
-rw-r--r--tests/s3tc_crunch.c32
1 files changed, 29 insertions, 3 deletions
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);