tweaks to allow different read formats/types
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 31 Mar 2000 01:01:31 +0000 (01:01 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 31 Mar 2000 01:01:31 +0000 (01:01 +0000)
progs/demos/readpix.c

index dd3a0af6fc3200b1b4699ca99b110744be7a9d10..32225b7961c2b21ee4be8a1ef0562e7574ee2325 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: readpix.c,v 1.2 2000/03/23 19:47:25 brianp Exp $ */
+/* $Id: readpix.c,v 1.3 2000/03/31 01:01:31 brianp Exp $ */
 
 /*
  * glReadPixels and glCopyPixels test
@@ -8,6 +8,9 @@
 
 /*
  * $Log: readpix.c,v $
+ * Revision 1.3  2000/03/31 01:01:31  brianp
+ * tweaks to allow different read formats/types
+ *
  * Revision 1.2  2000/03/23 19:47:25  brianp
  * added benchmarking
  *
@@ -40,6 +43,19 @@ static GLboolean ScaleAndBias = GL_FALSE;
 static GLboolean Benchmark = GL_FALSE;
 static GLubyte *TempImage = NULL;
 
+#if 1
+#define ReadFormat ImgFormat
+#define ReadType GL_UNSIGNED_BYTE
+#endif
+#if 0
+static GLenum ReadFormat = GL_RGBA;
+static GLenum ReadType = GL_UNSIGNED_BYTE;
+#endif
+#if 0
+static GLenum ReadFormat = GL_RGB;
+static GLenum ReadType = GL_UNSIGNED_SHORT_5_6_5;
+#endif
+
 
 static void
 Reset( void )
@@ -110,7 +126,7 @@ Display( void )
       printf("Benchmarking...\n");
       do {
          glReadPixels(APosX, APosY, ImgWidth, ImgHeight,
-                      ImgFormat, GL_UNSIGNED_BYTE, TempImage);
+                      ReadFormat, ReadType, TempImage);
          reads++;
          endTime = glutGet(GLUT_ELAPSED_TIME);
       } while (endTime - startTime < 4000);   /* 4 seconds */
@@ -122,12 +138,12 @@ Display( void )
    }
    else {
       glReadPixels(APosX, APosY, ImgWidth, ImgHeight,
-                   ImgFormat, GL_UNSIGNED_BYTE, TempImage);
+                   ReadFormat, ReadType, TempImage);
    }
    glRasterPos2i(BPosX, BPosY);
    glDisable(GL_DITHER);
    SetupPixelTransfer(GL_FALSE);
-   glDrawPixels(ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, TempImage);
+   glDrawPixels(ImgWidth, ImgHeight, ReadFormat, ReadType, TempImage);
 
    /* do copypixels */
    glRasterPos2i(CPosX, 5);