summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2015-11-03 14:31:39 -0700
committerBrian Paul <brianp@vmware.com>2015-11-03 14:32:38 -0700
commitf941f6b60dea9bb446b97985a9afb6b1b839e81f (patch)
tree43e1835491e6ecf27d7376794c57531c06ffb877
parentae76b2aafc1d3c9746b6a0eb97407d35b8ce1367 (diff)
downloadmesa-demos-f941f6b60dea9bb446b97985a9afb6b1b839e81f.zip
mesa-demos-f941f6b60dea9bb446b97985a9afb6b1b839e81f.tar.xz
rubberband: add keyboard option to test non-white drawing color
And use glLogicOp by default instead of blending.
-rw-r--r--src/tests/rubberband.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/tests/rubberband.c b/src/tests/rubberband.c
index f24255f..d1ddbf9 100644
--- a/src/tests/rubberband.c
+++ b/src/tests/rubberband.c
@@ -26,7 +26,7 @@ struct rect
static struct rect OldRect, NewRect;
static GLboolean ButtonDown = GL_FALSE;
-static GLboolean LogicOp = 0*GL_TRUE;
+static GLboolean LogicOp = GL_TRUE;
static GLboolean RedrawBackground = GL_TRUE;
@@ -34,6 +34,8 @@ static const GLfloat red[4] = {1.0, 0.2, 0.2, 1.0};
static const GLfloat green[4] = {0.2, 1.0, 0.2, 1.0};
static const GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0};
+static int color = 0;
+
/*
* Draw rubberband box in front buffer
@@ -46,15 +48,19 @@ DrawRect(const struct rect *r)
if (LogicOp) {
glLogicOp(GL_XOR);
glEnable(GL_COLOR_LOGIC_OP);
+
+ if (color == 0)
+ glColor3f(1, 1, 1);
+ else
+ glColor3ub(152, 105, 58);
}
else {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_FUNC_SUBTRACT);
+ glColor3f(1, 1, 1);
}
- glColor3f(1, 1, 1);
-
glBegin(GL_LINE_LOOP);
glVertex2i(r->x0, r->y0);
glVertex2i(r->x1, r->y0);
@@ -95,6 +101,7 @@ DrawBackground(void)
glWindowPos2i((Width - ImgWidth) / 2, (Height - ImgHeight) / 2);
glDrawPixels(ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, Image);
+ glColor3f(1, 1, 1);
glWindowPos2i(10, 10);
PrintString(s);
@@ -163,6 +170,12 @@ Key(unsigned char key, int x, int y)
case 'B':
LogicOp = GL_FALSE;
break;
+ case 'c':
+ case 'C':
+ color = !color;
+ printf("using color %d\n", color);
+ fflush(stdout);
+ break;
case 'l':
case 'L':
LogicOp = GL_TRUE;