mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 08:20:12 +01:00
Added -clip option to test glCopyPixels beyond window bounds.
Clear dest window to black before copying. Use glWindowPos2iARB().
This commit is contained in:
parent
d40f20aebc
commit
8dff54e71d
1 changed files with 17 additions and 18 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue