progs/demos: added RGB invert option
authorBrian Paul <brianp@vmware.com>
Tue, 8 Sep 2009 22:45:07 +0000 (16:45 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 8 Sep 2009 22:45:07 +0000 (16:45 -0600)
progs/demos/copypix.c

index 51435acfa0fb2a3f85b753dbc6a3fdb68720806b..a13339ea62f86a803f6cd017a31ab92c92045e99 100644 (file)
@@ -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;