Added -clip option to test glCopyPixels beyond window bounds.
authorBrian Paul <brian.paul@tungstengraphics.com>
Mon, 16 Oct 2006 23:22:44 +0000 (23:22 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Mon, 16 Oct 2006 23:22:44 +0000 (23:22 +0000)
Clear dest window to black before copying.
Use glWindowPos2iARB().

progs/xdemos/wincopy.c

index 3ec67dc..f670983 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.1
+ * Version:  6.5.2
  * 
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -32,6 +32,7 @@
  */
 
 
+#define GL_GLEXT_PROTOTYPES
 #define GLX_GLXEXT_PROTOTYPES
 #include <GL/gl.h>
 #include <GL/glx.h>
@@ -50,7 +51,7 @@ static int ScrNum;
 static GLXContext Context;
 static Window Win[2];  /* Win[0] = source,  Win[1] = dest */
 static GLint Width[2], Height[2];
-
+static GLboolean TestClipping = GL_FALSE;
 static GLfloat Angle = 0.0;
 
 static GLboolean DrawFront = GL_FALSE;
@@ -123,7 +124,7 @@ Redraw(void)
    glMatrixMode(GL_MODELVIEW);
 
    glShadeModel(GL_FLAT);
-   glClearColor(0.5, 0.5, 0.5, 1.0);
+   glClearColor(0.5, 0.5, 0.5, 0.0);
    glClear(GL_COLOR_BUFFER_BIT);
 
    /* draw blue quad */
@@ -150,22 +151,18 @@ Redraw(void)
       return;
    }
 
-   /* raster pos setup */
-   glViewport(0, 0, Width[1], Height[1]);
-   glPushMatrix();
-   glLoadIdentity();
-   glMatrixMode(GL_PROJECTION);
-   glPushMatrix();
-   glLoadIdentity();
-   glOrtho(-1, 1, -1, 1, -1, 1);
-   glRasterPos2f(-1, -1);
-
    /* copy the image between windows */
-   glCopyPixels(0, 0, Width[0], Height[0], GL_COLOR);
+   glClearColor(0.0, 0.0, 0.0, 0.0);
+   glClear(GL_COLOR_BUFFER_BIT);
 
-   glPopMatrix();
-   glMatrixMode(GL_MODELVIEW);
-   glPopMatrix();
+   if (TestClipping) {
+      glWindowPos2iARB(-2, -2);
+      glCopyPixels(-2, -2, Width[0] + 4, Height[0] + 4, GL_COLOR);
+   }
+   else {
+      glWindowPos2iARB(0, 0);
+      glCopyPixels(0, 0, Width[0], Height[0], GL_COLOR);
+   }
 
    if (DrawFront)
       glFinish();
@@ -309,6 +306,8 @@ Init(void)
 int
 main(int argc, char *argv[])
 {
+   if (argc > 1 && strcmp(argv[1], "-clip") == 0)
+      TestClipping = GL_TRUE;
    Init();
    EventLoop();
    return 0;