diff options
Diffstat (limited to 'progs/tests')
| -rw-r--r-- | progs/tests/arbgpuprog.c | 4 | ||||
| -rw-r--r-- | progs/tests/getprocaddress.c | 2 | ||||
| -rw-r--r-- | progs/tests/getteximage.c | 20 | ||||
| -rw-r--r-- | progs/tests/mipmap_limits.c | 237 | ||||
| -rw-r--r-- | progs/tests/packedpixels.c | 79 | ||||
| -rw-r--r-- | progs/tests/sharedtex.c | 8 | ||||
| -rw-r--r-- | progs/tests/texcmp.c | 17 | ||||
| -rw-r--r-- | progs/tests/texcomp_image.h | 2 | ||||
| -rw-r--r-- | progs/tests/texcompsub.c | 8 | ||||
| -rw-r--r-- | progs/tests/zreaddraw.c | 84 | 
10 files changed, 306 insertions, 155 deletions
| diff --git a/progs/tests/arbgpuprog.c b/progs/tests/arbgpuprog.c index 23aa899d96..6098dca787 100644 --- a/progs/tests/arbgpuprog.c +++ b/progs/tests/arbgpuprog.c @@ -134,6 +134,8 @@ static void Init( const char *vertProgFile,        }        len = fread(buf, 1, 10*1000,f); +      fclose(f); +        glProgramStringARB_func(GL_VERTEX_PROGRAM_ARB,                                GL_PROGRAM_FORMAT_ASCII_ARB,                                len, @@ -170,6 +172,8 @@ static void Init( const char *vertProgFile,        }        len = fread(buf, 1, 10*1000,f); +      fclose(f); +        glProgramStringARB_func(GL_FRAGMENT_PROGRAM_ARB,                                GL_PROGRAM_FORMAT_ASCII_ARB,                                len, diff --git a/progs/tests/getprocaddress.c b/progs/tests/getprocaddress.c index a09ea58e1d..b905eeaf81 100644 --- a/progs/tests/getprocaddress.c +++ b/progs/tests/getprocaddress.c @@ -3516,7 +3516,7 @@ check_functions( const char *extensions )     struct name_test_pair *entry;     int failures = 0, passes = 0, untested = 0;     int totalFail = 0, totalPass = 0, totalUntested = 0, totalUnsupported = 0; -   int doTests; +   int doTests = 0;     const char *version = (const char *) glGetString(GL_VERSION);     /* The functions list will have "real" entries (consisting of diff --git a/progs/tests/getteximage.c b/progs/tests/getteximage.c index 71f29b4ac8..e4053b8de1 100644 --- a/progs/tests/getteximage.c +++ b/progs/tests/getteximage.c @@ -58,6 +58,26 @@ TestGetTexImage(GLboolean npot)              abort();           }        } + +      /* get as BGRA */ +      glGetTexImage(GL_TEXTURE_2D, level, GL_BGRA, GL_UNSIGNED_BYTE, data2); + +      /* compare */ +      { +         const GLubyte *rgba = (GLubyte *) data; +         const GLubyte *bgra = (GLubyte *) data2; +         for (i = 0; i < w * h; i += 4) { +            if (rgba[i+0] != bgra[i+2] || +                rgba[i+1] != bgra[i+1] || +                rgba[i+2] != bgra[i+0] || +                rgba[i+3] != bgra[i+3]) { +               printf("glTexImage + glGetTexImage(GL_BGRA) failure!\n"); +               printf("Expected value %d, found %d\n", data[i], data2[i]); +               abort(); +            } +         } +      } +     }     printf("Passed\n"); diff --git a/progs/tests/mipmap_limits.c b/progs/tests/mipmap_limits.c index 5b899cd155..9418e90981 100644 --- a/progs/tests/mipmap_limits.c +++ b/progs/tests/mipmap_limits.c @@ -77,15 +77,16 @@ InitValues(void)  } -static void MakeImage(int level, int width, int height, const GLubyte color[4]) +static void +MakeImage(int level, int width, int height, const GLubyte color[4])  {     const int makeStripes = 0; -   GLubyte img[512*512*3]; +   GLubyte img[512 * 512 * 3];     int i, j;     for (i = 0; i < height; i++) {        for (j = 0; j < width; j++) {           int k = (i * width + j) * 3; -         int p = (i/8) & makeStripes; +         int p = (i / 8) & makeStripes;           if (p == 0) {              img[k + 0] = color[0];              img[k + 1] = color[1]; @@ -104,7 +105,8 @@ static void MakeImage(int level, int width, int height, const GLubyte color[4])  } -static void makeImages(int image) +static void +makeImages(int image)  {  #define WIDTH 512  #define HEIGHT 512 @@ -121,19 +123,20 @@ static void makeImages(int image)        if (width != WIDTH || height != HEIGHT) {           GLubyte *newImage = malloc(WIDTH * HEIGHT * 4);           gluScaleImage(format, width, height, GL_UNSIGNED_BYTE, image, -               WIDTH, HEIGHT, GL_UNSIGNED_BYTE, newImage); +                       WIDTH, HEIGHT, GL_UNSIGNED_BYTE, newImage);           free(image);           image = newImage;        }        printf("Using GL_SGIS_generate_mipmap\n");        glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);        glTexImage2D(GL_TEXTURE_2D, 0, format, WIDTH, HEIGHT, 0, -            format, GL_UNSIGNED_BYTE, image); +                   format, GL_UNSIGNED_BYTE, image);        glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);        free(image);        /* make sure mipmap was really generated correctly */ -      width = WIDTH; height = HEIGHT; +      width = WIDTH; +      height = HEIGHT;        for (i = 0; i < 10; i++) {           GLint w, h;           glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_WIDTH, &w); @@ -142,18 +145,19 @@ static void makeImages(int image)           width /= 2;           height /= 2;        } -   } else { +   } +   else {        static const GLubyte colors[10][3] = { -         {128, 128, 128 }, -         { 0, 255, 255 }, -         { 255, 255, 0 }, -         { 255, 0, 255 }, -         { 255, 0, 0 }, -         { 0, 255, 0 }, -         { 0, 0, 255 }, -         { 0, 255, 255 }, -         { 255, 255, 0 }, -         { 255, 255, 255 } +         {128, 128, 128}, +         {0, 255, 255}, +         {255, 255, 0}, +         {255, 0, 255}, +         {255, 0, 0}, +         {0, 255, 0}, +         {0, 0, 255}, +         {0, 255, 255}, +         {255, 255, 0}, +         {255, 255, 255}        };        int i, sz = 512; @@ -165,7 +169,8 @@ static void makeImages(int image)     }  } -static void myinit(void) +static void +myinit(void)  {     InitValues(); @@ -191,14 +196,16 @@ static void myinit(void)     glEnable(GL_TEXTURE_2D);  } -static void display(void) +static void +display(void)  {     GLfloat tcm = 1.0;     glBindTexture(GL_TEXTURE_2D, texCurrent); -   printf("BASE_LEVEL=%d  MAX_LEVEL=%d  MIN_LOD=%.2g  MAX_LOD=%.2g  Bias=%.2g  Filter=%s\n", -         BaseLevel, MaxLevel, MinLod, MaxLod, LodBias, -         NearestFilter ? "NEAREST" : "LINEAR"); +   printf +      ("BASE_LEVEL=%d  MAX_LEVEL=%d  MIN_LOD=%.2g  MAX_LOD=%.2g  Bias=%.2g  Filter=%s\n", +       BaseLevel, MaxLevel, MinLod, MaxLod, LodBias, +       NearestFilter ? "NEAREST" : "LINEAR");     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel);     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel); @@ -208,103 +215,44 @@ static void display(void)     if (NearestFilter) {        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, -            GL_NEAREST_MIPMAP_NEAREST); +                      GL_NEAREST_MIPMAP_NEAREST);     }     else {        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, -            GL_LINEAR_MIPMAP_LINEAR); +                      GL_LINEAR_MIPMAP_LINEAR);     }     glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias);     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);     glBegin(GL_QUADS); -   glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0); -   glTexCoord2f(0.0, tcm); glVertex3f(-2.0, 1.0, 0.0); -   glTexCoord2f(tcm * 3000.0, tcm); glVertex3f(3000.0, 1.0, -6000.0); -   glTexCoord2f(tcm * 3000.0, 0.0); glVertex3f(3000.0, -1.0, -6000.0); +   glTexCoord2f(0.0, 0.0); +   glVertex3f(-2.0, -1.0, 0.0); +   glTexCoord2f(0.0, tcm); +   glVertex3f(-2.0, 1.0, 0.0); +   glTexCoord2f(tcm * 3000.0, tcm); +   glVertex3f(3000.0, 1.0, -6000.0); +   glTexCoord2f(tcm * 3000.0, 0.0); +   glVertex3f(3000.0, -1.0, -6000.0);     glEnd();     glFlush();  } -static void myReshape(int w, int h) +static void +myReshape(int w, int h)  {     glViewport(0, 0, w, h);     glMatrixMode(GL_PROJECTION);     glLoadIdentity(); -   gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0); +   gluPerspective(60.0, 1.0 * (GLfloat) w / (GLfloat) h, 1.0, 30000.0);     glMatrixMode(GL_MODELVIEW);     glLoadIdentity();  } -static void -key(unsigned char k, int x, int y) -{ -  (void) x; -  (void) y; -  switch (k) { -  case 'b': -     BaseLevel--; -     if (BaseLevel < 0) -        BaseLevel = 0; -     break; -  case 'B': -     BaseLevel++; -     if (BaseLevel > 10) -        BaseLevel = 10; -     break; -  case 'm': -     MaxLevel--; -     if (MaxLevel < 0) -        MaxLevel = 0; -     break; -  case 'M': -     MaxLevel++; -     if (MaxLevel > 10) -        MaxLevel = 10; -     break; -  case 'l': -     LodBias -= 0.25; -     break; -  case 'L': -     LodBias += 0.25; -     break; -  case 'n': -     MinLod -= 0.25; -     break; -  case 'N': -     MinLod += 0.25; -     break; -  case 'x': -     MaxLod -= 0.25; -     break; -  case 'X': -     MaxLod += 0.25; -     break; -  case 'f': -     NearestFilter = !NearestFilter; -     break; -  case 't': -     if (texCurrent == texColor) -        texCurrent = texImage; -     else -        texCurrent = texColor; -     break; -  case ' ': -     InitValues(); -     break; -  case 27:  /* Escape */ -    exit(0); -    break; -  default: -    return; -  } -  glutPostRedisplay(); -} - -static void usage(void) +static void +usage(void)  {     printf("usage:\n");     printf("  b/B    decrease/increase GL_TEXTURE_BASE_LEVEL\n"); @@ -317,19 +265,88 @@ static void usage(void)     printf("  SPACE  reset values\n");  } +static void +key(unsigned char k, int x, int y) +{ +   (void) x; +   (void) y; +   switch (k) { +   case 'b': +      BaseLevel--; +      if (BaseLevel < 0) +         BaseLevel = 0; +      break; +   case 'B': +      BaseLevel++; +      if (BaseLevel > 10) +         BaseLevel = 10; +      break; +   case 'm': +      MaxLevel--; +      if (MaxLevel < 0) +         MaxLevel = 0; +      break; +   case 'M': +      MaxLevel++; +      if (MaxLevel > 10) +         MaxLevel = 10; +      break; +   case 'l': +      LodBias -= 0.25; +      break; +   case 'L': +      LodBias += 0.25; +      break; +   case 'n': +      MinLod -= 0.25; +      break; +   case 'N': +      MinLod += 0.25; +      break; +   case 'x': +      MaxLod -= 0.25; +      break; +   case 'X': +      MaxLod += 0.25; +      break; +   case 'f': +      NearestFilter = !NearestFilter; +      break; +   case 't': +      if (texCurrent == texColor) +         texCurrent = texImage; +      else +         texCurrent = texColor; +      break; +   case ' ': +      InitValues(); +      /* fall-through */ +   case 'u': +      usage(); +      break; +   case 27:                    /* Escape */ +      exit(0); +      break; +   default: +      return; +   } +   glutPostRedisplay(); +} + -int main(int argc, char** argv) +int +main(int argc, char **argv)  { -    glutInit(&argc, argv); -    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); -    glutInitWindowSize (600, 600); -    glutCreateWindow (argv[0]); -    glewInit(); -    myinit(); -    glutReshapeFunc (myReshape); -    glutDisplayFunc(display); -    glutKeyboardFunc(key); -    usage(); -    glutMainLoop(); -    return 0;             /* ANSI C requires main to return int. */ +   glutInit(&argc, argv); +   glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); +   glutInitWindowSize(600, 600); +   glutCreateWindow(argv[0]); +   glewInit(); +   myinit(); +   glutReshapeFunc(myReshape); +   glutDisplayFunc(display); +   glutKeyboardFunc(key); +   usage(); +   glutMainLoop(); +   return 0;                    /* ANSI C requires main to return int. */  } diff --git a/progs/tests/packedpixels.c b/progs/tests/packedpixels.c index 1703b271cb..c8884bb79f 100644 --- a/progs/tests/packedpixels.c +++ b/progs/tests/packedpixels.c @@ -17,53 +17,53 @@ struct pixel_format {     GLenum format;     GLenum type;     GLint bytes; -   GLuint redTexel, greenTexel; +   GLuint redTexel, greenTexel; /* with approx 51% alpha, when applicable */  };  static const struct pixel_format Formats[] = {     { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8", -     GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000000, 0x00ff0000 }, +     GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000080, 0x00ff0080 },     { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8_REV", -     GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x000000ff, 0x0000ff00 }, +     GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x800000ff, 0x8000ff00 },     { "GL_RGBA/GL_UNSIGNED_INT_10_10_10_2", -     GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00000, 0x3ff000 }, +     GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00002, 0x3ff002 },     { "GL_RGBA/GL_UNSIGNED_INT_2_10_10_10_REV", -     GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0x3ff, 0xffc00 }, +     GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0xc00003ff, 0xc00ffc00 },     { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4", -     GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf000, 0x0f00 }, +     GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf008, 0x0f08 },     { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4_REV", -     GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x000f, 0x00f0 }, +     GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x800f, 0x80f0 },     { "GL_RGBA/GL_UNSIGNED_SHORT_5_5_5_1", -     GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf800, 0x7c0 }, +     GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf801, 0x7c1 },     { "GL_RGBA/GL_UNSIGNED_SHORT_1_5_5_5_REV", -     GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x1f, 0x3e0 }, +     GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x801f, 0x83e0 },     { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8", -     GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff00, 0x00ff0000 }, +     GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff80, 0x00ff0080 },     { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV", -     GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x00ff0000, 0x0000ff00 }, +     GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x80ff0000, 0x8000ff00 },     { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4", -     GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f0, 0x0f00 }, +     GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f8, 0x0f08 },     { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4_REV", -     GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x0f00, 0x00f0 }, +     GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x8f00, 0x80f0 },     { "GL_BGRA/GL_UNSIGNED_SHORT_5_5_5_1", -     GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3e, 0x7c0 }, +     GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3f, 0x7c1 },     { "GL_BGRA/GL_UNSIGNED_SHORT_1_5_5_5_REV", -     GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x7c00, 0x3e0 }, +     GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0xfc00, 0x83e0 },     { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8", -     GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x000000ff, 0x0000ff00 }, +     GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x800000ff, 0x8000ff00 },     { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8_REV", -     GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000000, 0x00ff0000 }, +     GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000080, 0x00ff0080 },     { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4", -     GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x000f, 0x00f0 }, +     GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x800f, 0x80f0 },     { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4_REV", -     GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf000, 0x0f00 }, +     GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf008, 0x0f08 },     { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_5_5_5_1", -     GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x1, 0x3e }, +     GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf801, 0xf83e },     { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_1_5_5_5_REV", -     GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x8000, 0x7c00 }, +     GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x800f, 0x7c0f },     { "GL_RGB/GL_UNSIGNED_SHORT_5_6_5",       GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 2, 0xf800, 0x7e0 }, @@ -108,7 +108,7 @@ static const struct name_format IntFormats[] = {  static GLuint CurFormat = 0;  static GLboolean Test3D = GL_FALSE; - +static GLboolean Blend = GL_FALSE;  static void @@ -191,6 +191,19 @@ MakeTexture(const struct pixel_format *format, GLenum intFormat, GLboolean swap)                     format->format, format->type, texBuffer);     } +   if (0) { +      GLint r, g, b, a, l, i; +      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r); +      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g); +      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b); +      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a); +      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l); +      glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i); +      printf("IntFormat: 0x%x  R %d  G %d  B %d  A %d  L %d  I %d\n", +             intFormat, r, g, b, a, l, i); +      glGetError(); +   }                               +     if (glGetError()) {        printf("GL Error for %s\n", format->name);        memset(texBuffer, 255, 1000); @@ -221,6 +234,10 @@ Draw(void)             glEnable(GL_TEXTURE_3D);          else             glEnable(GL_TEXTURE_2D); + +        if (Blend) +           glEnable(GL_BLEND); +          glBegin(GL_POLYGON);          glTexCoord3f(0, 0, 0.5);  glVertex2f(0, 0);          glTexCoord3f(1, 0, 0.5);  glVertex2f(w, 0); @@ -232,6 +249,9 @@ Draw(void)             glDisable(GL_TEXTURE_3D);          else             glDisable(GL_TEXTURE_2D); + +        glDisable(GL_BLEND); +          glColor3f(0, 0, 0);          glRasterPos2i(8, 6);          PrintString(Formats[i].name); @@ -252,7 +272,7 @@ Draw(void)     glPushMatrix();     glTranslatef(2, (i + 1) * (h + 2), 0);     glRasterPos2i(8, 6); -   sprintf(s, "Internal Texture Format [f/F]: %s (%d of %d)", +   sprintf(s, "Internal Texture Format [f/F]: %s (%d of %lu)",             IntFormats[CurFormat].name, CurFormat + 1, NUM_INT_FORMATS);     PrintString(s);     glPopMatrix(); @@ -266,6 +286,15 @@ Draw(void)        PrintString("Target [2/3]: GL_TEXTURE_2D");     glPopMatrix(); +   glPushMatrix(); +   glTranslatef(2, (i + 3) * (h + 2), 0); +   glRasterPos2i(8, 6); +   if (Blend) +      PrintString("Blend: Yes"); +   else +      PrintString("Blend: No"); +   glPopMatrix(); +     glutSwapBuffers();  } @@ -288,6 +317,9 @@ Key(unsigned char key, int x, int y)     (void) x;     (void) y;     switch (key) { +      case 'b': +         Blend = !Blend; +         break;        case 'F':           if (CurFormat == 0)              CurFormat = NUM_INT_FORMATS - 1; @@ -323,6 +355,7 @@ Init(void)     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);     glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); +   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);  } diff --git a/progs/tests/sharedtex.c b/progs/tests/sharedtex.c index c07ebd719c..2337b88d3f 100644 --- a/progs/tests/sharedtex.c +++ b/progs/tests/sharedtex.c @@ -424,13 +424,13 @@ main(int argc, char *argv[])  {     const char *dpyName = XDisplayName(NULL); -   struct window *h0, *h1, *h2, *h3; +   struct window *h0;     /* four windows and contexts sharing display lists and texture objects */     h0 = AddWindow(dpyName,  10,  10, NULL); -   h1 = AddWindow(dpyName, 330,  10, h0); -   h2 = AddWindow(dpyName,  10, 350, h0); -   h3 = AddWindow(dpyName, 330, 350, h0); +   (void) AddWindow(dpyName, 330,  10, h0); +   (void) AddWindow(dpyName,  10, 350, h0); +   (void) AddWindow(dpyName, 330, 350, h0);     InitGLstuff(h0); diff --git a/progs/tests/texcmp.c b/progs/tests/texcmp.c index 45935e19a3..c5d352fdae 100644 --- a/progs/tests/texcmp.c +++ b/progs/tests/texcmp.c @@ -106,6 +106,8 @@ static void Display( void )     glRotatef(Rot, 0, 0, 1);     glEnable(GL_TEXTURE_2D); +   glEnable(GL_BLEND); +     glBegin(GL_POLYGON);     glTexCoord2f(0, 1);  glVertex2f(-1, -0.5);     glTexCoord2f(1, 1);  glVertex2f( 1, -0.5); @@ -115,7 +117,10 @@ static void Display( void )     glPopMatrix(); +   glDisable(GL_TEXTURE_2D); +     /* info */ +   glDisable(GL_BLEND);     glColor4f(1, 1, 1, 1);     glRasterPos3f(-1.2, -0.7, 0); @@ -176,6 +181,18 @@ static void ReInit( GLenum TC, TEXTURE *Tx )                                 GL_TEXTURE_INTERNAL_FORMAT, &v);        printf("Requested internal format = 0x%x, actual = 0x%x\n", TC, v); +      if (0) { +         GLint r, g, b, a, l, i; +         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r); +         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g); +         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b); +         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a); +         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l); +         glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i); +         printf("Compressed Bits per R: %d  G: %d  B: %d  A: %d  L: %d  I: %d\n", +                r, g, b, a, l, i); +      } +        /* okay, now cache the compressed texture */        Tx->TC = TC;        if (Tx->cData != NULL) { diff --git a/progs/tests/texcomp_image.h b/progs/tests/texcomp_image.h index e63a56774f..a3884d4d0d 100644 --- a/progs/tests/texcomp_image.h +++ b/progs/tests/texcomp_image.h @@ -1,4 +1,4 @@ -static int ImgSize = 131072; +#define ImgSize 131072  static unsigned char ImgData[131072] =  {     0x4d, 0xbc, 0x0b, 0xb4, 0xda, 0x0a, 0x78, 0xa8, 0x8d, 0xbc, 0x0c, 0xac, 0x8b, 0x7f, 0xeb, 0xf7, 0x8d, 0xbc, 0xeb, 0xab, 0xba, 0xb7, 0x82, 0xa2, 0x8d, 0xbc, 0x2b, 0xb4, 0xa2, 0xfd, 0xee, 0x2f, diff --git a/progs/tests/texcompsub.c b/progs/tests/texcompsub.c index 50106bf1e2..215f5711d9 100644 --- a/progs/tests/texcompsub.c +++ b/progs/tests/texcompsub.c @@ -35,6 +35,8 @@ LoadCompressedImage(void)     unsigned char ImgDataTemp[ImgSize / 4];     unsigned i;     const GLenum filter = GL_LINEAR; +   const int half = ImgSize / 2; +     glTexImage2D(Target, 0, CompFormat, ImgWidth, ImgHeight, 0,                  GL_RGB, GL_UNSIGNED_BYTE, NULL); @@ -42,11 +44,11 @@ LoadCompressedImage(void)     glCompressedTexSubImage2DARB(Target, 0,                                  0, 0, /* pos */                                  ImgWidth, ImgHeight / 2, -                                CompFormat, ImgSize / 2, ImgData + ImgSize / 2); +                                CompFormat, ImgSize / 2, ImgData /*+ ImgSize / 2*/);     /* top left */     for (i = 0; i < ImgHeight / 8; i++) { -      memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth], ImgWidth); +      memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[half + i * 2 * ImgWidth], ImgWidth);     }     glCompressedTexSubImage2DARB(Target, 0,                                  0, ImgHeight / 2, /* pos */ @@ -55,7 +57,7 @@ LoadCompressedImage(void)     /* top right */     for (i = 0; i < ImgHeight / 8; i++) { -      memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth + ImgWidth], ImgWidth); +      memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[half + i * 2 * ImgWidth + ImgWidth], ImgWidth);     }     glCompressedTexSubImage2DARB(Target, 0,                                  ImgWidth / 2, ImgHeight / 2, /* pos */ diff --git a/progs/tests/zreaddraw.c b/progs/tests/zreaddraw.c index 8839e10836..7740695bb6 100644 --- a/progs/tests/zreaddraw.c +++ b/progs/tests/zreaddraw.c @@ -12,14 +12,17 @@  #include <GL/glut.h>  static GLint WinWidth = 500, WinHeight = 500; +static GLboolean Invert = GL_FALSE; +static GLboolean TestPacking = GL_FALSE; +static GLboolean TestList = GL_FALSE;  static void Display(void)  { -   GLfloat depth[100 * 100]; -   GLfloat depth2[400 * 400]; -   GLfloat min, max; -   int i; +   GLfloat depth[100 * 100 * 2]; +   GLfloat depth2[400 * 400]; /* *2 to test pixelstore stuff */ +   GLuint list; +   GLenum depthType = GL_FLOAT;     glClearColor(0.5, 0.5, 0.5, 1.0);     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -35,22 +38,65 @@ static void Display(void)     glLoadIdentity();     glutSolidSphere(1.0, 20, 10); +   if (TestPacking) { +      glPixelStorei(GL_PACK_ROW_LENGTH, 120); +      glPixelStorei(GL_PACK_SKIP_PIXELS, 5); +   } +     /* read the depth image */ -   glReadPixels(0, 0, 100, 100, GL_DEPTH_COMPONENT, GL_FLOAT, depth); -   min = max = depth[0]; -   for (i = 1; i < 100 * 100; i++) { -      if (depth[i] < min) -         min = depth[i]; -      if (depth[i] > max) -         max = depth[i]; +   glReadPixels(0, 0, 100, 100, GL_DEPTH_COMPONENT, depthType, depth); +   if (depthType == GL_FLOAT) { +      GLfloat min, max; +      int i; +      min = max = depth[0]; +      for (i = 1; i < 100 * 100; i++) { +         if (depth[i] < min) +            min = depth[i]; +         if (depth[i] > max) +            max = depth[i]; +      } +      printf("Depth value range: [%f, %f]\n", min, max); +   } + +   /* Draw the Z image as luminance above original rendering */ +   glWindowPos2i(0, 100); +   glDrawPixels(100, 100, GL_LUMINANCE, depthType, depth); + +   if (TestPacking) { +      glPixelStorei(GL_PACK_ROW_LENGTH, 0); +      glPixelStorei(GL_PACK_SKIP_PIXELS, 0); +      glPixelStorei(GL_UNPACK_ROW_LENGTH, 120); +      glPixelStorei(GL_UNPACK_SKIP_PIXELS, 5);     } -   printf("Depth value range: [%f, %f]\n", min, max);     /* draw depth image with scaling (into z buffer) */     glPixelZoom(4.0, 4.0);     glColor4f(1, 0, 0, 0);     glWindowPos2i(100, 0); -   glDrawPixels(100, 100, GL_DEPTH_COMPONENT, GL_FLOAT, depth); +   if (Invert) { +      glPixelTransferf(GL_DEPTH_SCALE, -1.0); +      glPixelTransferf(GL_DEPTH_BIAS, 1.0); +   } +   if (TestList) { +      list = glGenLists(1); +      glNewList(list, GL_COMPILE); +      glDrawPixels(100, 100, GL_DEPTH_COMPONENT, depthType, depth); +      glEndList(); +      glCallList(list); +      glDeleteLists(list, 1); +   } +   else { +      glDrawPixels(100, 100, GL_DEPTH_COMPONENT, depthType, depth); +   } +   if (Invert) { +      glPixelTransferf(GL_DEPTH_SCALE, 1.0); +      glPixelTransferf(GL_DEPTH_BIAS, 0.0); +   } + +   if (TestPacking) { +      glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); +      glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); +   }     glDisable(GL_DEPTH_TEST); @@ -58,6 +104,7 @@ static void Display(void)     glReadPixels(100, 0, 400, 400, GL_DEPTH_COMPONENT, GL_FLOAT, depth2);     /* draw as luminance */     glPixelZoom(1.0, 1.0); +   glWindowPos2i(100, 0);     glDrawPixels(400, 400, GL_LUMINANCE, GL_FLOAT, depth2);     glutSwapBuffers(); @@ -77,6 +124,17 @@ static void Key(unsigned char key, int x, int y)     (void) x;     (void) y;     switch (key) { +      case 'i': +         Invert = !Invert; +         break; +      case 'p': +         TestPacking = !TestPacking; +         printf("Test pixel pack/unpack: %d\n", TestPacking); +         break; +      case 'l': +         TestList = !TestList; +         printf("Test dlist: %d\n", TestList); +         break;        case 27:           exit(0);           break; | 
