Merge commit 'origin/master' into gallium-sw-api-2
[mesa.git] / progs / xdemos / wincopy.c
index 04fa98a78a6c63d6991482a2a34c358746a1e5aa..f670983a0f700272dbbab25b3968869d68bcf8d6 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,7 +32,8 @@
  */
 
 
-
+#define GL_GLEXT_PROTOTYPES
+#define GLX_GLXEXT_PROTOTYPES
 #include <GL/gl.h>
 #include <GL/glx.h>
 #include <X11/keysym.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;