diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2006-10-16 23:22:44 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2006-10-16 23:22:44 +0000 |
commit | 8dff54e71d3ea22813e416910c3c99f7e3abbb2f (patch) | |
tree | 63f2c5ebec86a72793863e07a47124d3d5dbaafc | |
parent | d40f20aebc6f9995b9fdb70cd5123b0c28d45589 (diff) |
Added -clip option to test glCopyPixels beyond window bounds.
Clear dest window to black before copying.
Use glWindowPos2iARB().
-rw-r--r-- | progs/xdemos/wincopy.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/progs/xdemos/wincopy.c b/progs/xdemos/wincopy.c index 3ec67dc672..f670983a0f 100644 --- a/progs/xdemos/wincopy.c +++ b/progs/xdemos/wincopy.c @@ -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; |