Module: Demos
Branch: master
Commit: f941f6b60dea9bb446b97985a9afb6b1b839e81f
URL:    
http://cgit.freedesktop.org/mesa/demos/commit/?id=f941f6b60dea9bb446b97985a9afb6b1b839e81f

Author: Brian Paul <[email protected]>
Date:   Tue Nov  3 14:31:39 2015 -0700

rubberband: add keyboard option to test non-white drawing color

And use glLogicOp by default instead of blending.

---

 src/tests/rubberband.c |   19 ++++++++++++++++---
 1 file 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;

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to