summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--progs/tests/yuvsquare.c60
1 files changed, 54 insertions, 6 deletions
diff --git a/progs/tests/yuvsquare.c b/progs/tests/yuvsquare.c
index eab255b4275..494586776a0 100644
--- a/progs/tests/yuvsquare.c
+++ b/progs/tests/yuvsquare.c
@@ -19,6 +19,9 @@
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
static GLint ImgWidth, ImgHeight;
static GLushort *ImageYUV = NULL;
+static GLubyte *ImageRGB = NULL;
+static const GLuint yuvObj = 100;
+static const GLuint rgbObj = 101;
static void DrawObject(void)
@@ -46,9 +49,20 @@ static void Display( void )
glClear( GL_COLOR_BUFFER_BIT );
glPushMatrix();
+ glTranslatef( -1.1, 0.0, -15.0 );
glRotatef(Xrot, 1.0, 0.0, 0.0);
glRotatef(Yrot, 0.0, 1.0, 0.0);
glRotatef(Zrot, 0.0, 0.0, 1.0);
+ glBindTexture(GL_TEXTURE_2D, yuvObj);
+ DrawObject();
+ glPopMatrix();
+
+ glPushMatrix();
+ glTranslatef( 1.1, 0.0, -15.0 );
+ glRotatef(Xrot, 1.0, 0.0, 0.0);
+ glRotatef(Yrot, 0.0, 1.0, 0.0);
+ glRotatef(Zrot, 0.0, 0.0, 1.0);
+ glBindTexture(GL_TEXTURE_2D, rgbObj);
DrawObject();
glPopMatrix();
@@ -61,7 +75,7 @@ static void Reshape( int width, int height )
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
- glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 );
+ glFrustum( -1.1, 1.1, -1.1, 1.1, 10.0, 100.0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0, 0.0, -15.0 );
@@ -113,9 +127,9 @@ static void SpecialKey( int key, int x, int y )
static void Init( int argc, char *argv[] )
{
- GLuint texObj = 100;
const char *file;
int error;
+ GLenum format;
if (!glutExtensionSupported("GL_MESA_ycbcr_texture")) {
printf("Sorry, GL_MESA_ycbcr_texture is required\n");
@@ -124,15 +138,18 @@ static void Init( int argc, char *argv[] )
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glBindTexture(GL_TEXTURE_2D, texObj);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
if (argc > 1)
file = argv[1];
else
file = TEXTURE_FILE;
+ /* First load the texture as YCbCr.
+ */
+
+ glBindTexture(GL_TEXTURE_2D, yuvObj);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
ImageYUV = LoadYUVImage(file, &ImgWidth, &ImgHeight );
if (!ImageYUV) {
printf("Couldn't read %s\n", TEXTURE_FILE);
@@ -152,6 +169,35 @@ static void Init( int argc, char *argv[] )
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+
+ /* Now load the texture as RGB.
+ */
+
+ glBindTexture(GL_TEXTURE_2D, rgbObj);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ ImageRGB = LoadRGBImage(file, &ImgWidth, &ImgHeight, &format );
+ if (!ImageRGB) {
+ printf("Couldn't read %s\n", TEXTURE_FILE);
+ exit(0);
+ }
+
+ printf("Image: %dx%d\n", ImgWidth, ImgHeight);
+
+
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ format,
+ ImgWidth, ImgHeight, 0,
+ format,
+ GL_UNSIGNED_BYTE, ImageRGB);
+
+ glEnable(GL_TEXTURE_2D);
+
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+
glShadeModel(GL_FLAT);
glClearColor(0.3, 0.3, 0.4, 1.0);
@@ -162,6 +208,8 @@ static void Init( int argc, char *argv[] )
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
+
+ printf( "Both images should appear the same.\n" );
}