2 * Draw lines in XOR mode.
3 * Note that the last pixel in a line segment should not be drawn by GL
4 * so that pixels aren't touched twice at the shared vertex of connected lines.
14 #include "glut_wrap.h"
17 static GLboolean
xor = GL_TRUE
;
21 Reshape(int width
, int height
)
23 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
25 glMatrixMode(GL_PROJECTION
);
27 glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
28 glMatrixMode(GL_MODELVIEW
);
33 Key(unsigned char key
, int x
, int y
)
37 printf("XOR mode: %s\n", xor ? "on" : "off");
48 glClear(GL_COLOR_BUFFER_BIT
);
52 glEnable(GL_COLOR_LOGIC_OP
);
54 glDisable(GL_COLOR_LOGIC_OP
);
59 glBegin(GL_LINE_LOOP
);
60 glVertex2f(-0.9, -0.9);
61 glVertex2f( 0.9, -0.9);
62 glVertex2f( 0.9, 0.9);
63 glVertex2f(-0.9, 0.9);
66 /* middle line rect */
67 glBegin(GL_LINE_STRIP
);
68 glVertex2f(-0.8, -0.8);
69 glVertex2f( 0.8, -0.8);
70 glVertex2f( 0.8, 0.8);
71 glVertex2f(-0.8, 0.8);
72 glVertex2f(-0.8, -0.8);
77 glVertex2f(-0.7, -0.7);
78 glVertex2f( 0.7, -0.7);
80 glVertex2f( 0.7, -0.7);
81 glVertex2f( 0.7, 0.7);
83 glVertex2f( 0.7, 0.7);
84 glVertex2f(-0.7, 0.7);
86 glVertex2f(-0.7, 0.7);
87 glVertex2f(-0.7, -0.7);
92 glVertex2f(-0.6, 0.0);
93 glVertex2f( 0.6, 0.0);
94 glVertex2f( 0.0, 0.6);
95 glVertex2f( 0.0, -0.6);
104 main(int argc
, char **argv
)
106 glutInit(&argc
, argv
);
108 glutInitWindowSize(250, 250);
110 glutInitDisplayMode(GLUT_RGB
| GLUT_DOUBLE
);
111 glutCreateWindow(argv
[0]);
112 glutReshapeFunc(Reshape
);
113 glutKeyboardFunc(Key
);
114 glutDisplayFunc(Draw
);
116 fprintf(stderr
, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
117 fprintf(stderr
, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION
));
118 fprintf(stderr
, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR
));
119 fprintf(stderr
, "NOTE: there should be no pixels missing at the corners"
120 " of the line loops.\n");
121 fprintf(stderr
, "There should be a missing pixel at the center of the '+'.\n");
122 fprintf(stderr
, "Resize the window to check for any pixel drop-outs.\n");
123 fprintf(stderr
, "Press 'x' to toggle XOR mode on/off.\n");