diff options
Diffstat (limited to 'progs')
| -rw-r--r-- | progs/demos/copypix.c | 22 | ||||
| -rw-r--r-- | progs/demos/cubemap.c | 5 | ||||
| -rw-r--r-- | progs/demos/lodbias.c | 4 | ||||
| -rw-r--r-- | progs/fp/add-sat.txt | 6 | ||||
| -rw-r--r-- | progs/fp/mov-alias.txt | 6 | ||||
| -rw-r--r-- | progs/fp/mul-alias.txt | 6 | ||||
| -rw-r--r-- | progs/tests/zreaddraw.c | 79 | 
7 files changed, 115 insertions, 13 deletions
| diff --git a/progs/demos/copypix.c b/progs/demos/copypix.c index 51435acfa0..a13339ea62 100644 --- a/progs/demos/copypix.c +++ b/progs/demos/copypix.c @@ -26,6 +26,7 @@ static int Scissor = 0;  static float Xzoom, Yzoom;  static GLboolean DrawFront = GL_FALSE;  static GLboolean Dither = GL_TRUE; +static GLboolean Invert = GL_FALSE;  static void Reset( void ) @@ -59,6 +60,15 @@ static void Display( void )     if (Scissor)        glEnable(GL_SCISSOR_TEST); +   if (Invert) { +      glPixelTransferf(GL_RED_SCALE, -1.0); +      glPixelTransferf(GL_GREEN_SCALE, -1.0); +      glPixelTransferf(GL_BLUE_SCALE, -1.0); +      glPixelTransferf(GL_RED_BIAS, 1.0); +      glPixelTransferf(GL_GREEN_BIAS, 1.0); +      glPixelTransferf(GL_BLUE_BIAS, 1.0); +   } +     /* draw copy */     glPixelZoom(Xzoom, Yzoom);     glWindowPos2iARB(Xpos, Ypos); @@ -67,6 +77,15 @@ static void Display( void )     glDisable(GL_SCISSOR_TEST); +   if (Invert) { +      glPixelTransferf(GL_RED_SCALE, 1.0); +      glPixelTransferf(GL_GREEN_SCALE, 1.0); +      glPixelTransferf(GL_BLUE_SCALE, 1.0); +      glPixelTransferf(GL_RED_BIAS, 0.0); +      glPixelTransferf(GL_GREEN_BIAS, 0.0); +      glPixelTransferf(GL_BLUE_BIAS, 0.0); +   } +     if (DrawFront)        glFinish();     else @@ -105,6 +124,9 @@ static void Key( unsigned char key, int x, int y )           else              glDisable(GL_DITHER);           break; +      case 'i': +         Invert = !Invert; +         break;        case 's':           Scissor = !Scissor;           break; diff --git a/progs/demos/cubemap.c b/progs/demos/cubemap.c index 0df5ff09c3..015d50d86b 100644 --- a/progs/demos/cubemap.c +++ b/progs/demos/cubemap.c @@ -58,6 +58,7 @@ static GLint ClampIndex = 0;  static GLboolean supportFBO = GL_FALSE;  static GLboolean supportSeamless = GL_FALSE;  static GLboolean seamless = GL_FALSE; +static GLuint TexObj = 0;  static struct { @@ -543,6 +544,10 @@ static void init( GLboolean useImageFiles )     printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); + +   glGenTextures(1, &TexObj); +   glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, TexObj); +     if (useImageFiles) {        load_envmaps();     } diff --git a/progs/demos/lodbias.c b/progs/demos/lodbias.c index 30b1ed13d5..8d39bd605a 100644 --- a/progs/demos/lodbias.c +++ b/progs/demos/lodbias.c @@ -43,6 +43,7 @@ static GLboolean Anim = GL_TRUE;  static GLint Bias = 0, BiasStepSign = +1; /* ints avoid fp precision problem */  static GLint BiasMin = -400, BiasMax = 400;  static int win = 0; +static GLuint TexObj = 0;  static void @@ -214,6 +215,9 @@ static void Init( void )     glPixelStorei(GL_UNPACK_ALIGNMENT, 1); +   glGenTextures(1, &TexObj); +   glBindTexture(GL_TEXTURE_2D, TexObj); +     if (glutExtensionSupported("GL_SGIS_generate_mipmap")) {        /* test auto mipmap generation */        GLint width, height, i; diff --git a/progs/fp/add-sat.txt b/progs/fp/add-sat.txt new file mode 100644 index 0000000000..2253efb085 --- /dev/null +++ b/progs/fp/add-sat.txt @@ -0,0 +1,6 @@ +!!ARBfp1.0 +TEMP R0; +MOV R0, fragment.color; +ADD_SAT R0, R0, R0; +MUL result.color, {0.5}.x, R0; +END diff --git a/progs/fp/mov-alias.txt b/progs/fp/mov-alias.txt new file mode 100644 index 0000000000..5f04e9c76e --- /dev/null +++ b/progs/fp/mov-alias.txt @@ -0,0 +1,6 @@ +!!ARBfp1.0 +TEMP R0; +MOV R0, fragment.color; +MOV R0, R0.zyxw; +MOV result.color, R0; +END diff --git a/progs/fp/mul-alias.txt b/progs/fp/mul-alias.txt new file mode 100644 index 0000000000..cf7d359e78 --- /dev/null +++ b/progs/fp/mul-alias.txt @@ -0,0 +1,6 @@ +!!ARBfp1.0 +TEMP R0; +MOV R0, fragment.color; +MUL R0, R0.zyxw, fragment.color; +MOV result.color, R0; +END diff --git a/progs/tests/zreaddraw.c b/progs/tests/zreaddraw.c index 8839e10836..7dfed20cfb 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,61 @@ 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); +   } + +   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); @@ -77,6 +119,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; | 
