summaryrefslogtreecommitdiffstats
path: root/progs/tests
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-02-05 10:54:40 -0700
committerMichal Krol <[email protected]>2010-02-09 15:33:03 +0100
commitfd6701029b15260ecf26d4139defc51cd8546ee7 (patch)
tree12a8feecf8d1b7e8755fb5a76865ba61e4da438e /progs/tests
parent22a3a817aa35d2ba8e38728193eaa65e02b97cf0 (diff)
progs/tests: add line drawing option to cylwrap.c
Diffstat (limited to 'progs/tests')
-rw-r--r--progs/tests/cylwrap.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/progs/tests/cylwrap.c b/progs/tests/cylwrap.c
index 95d46449379..2b32f115416 100644
--- a/progs/tests/cylwrap.c
+++ b/progs/tests/cylwrap.c
@@ -12,6 +12,7 @@ static int Win;
static int WinWidth = 600, WinHeight = 400;
static GLfloat Xrot = 0, Yrot = 0;
static GLboolean CylWrap = GL_TRUE;
+static GLboolean Lines = GL_FALSE;
@@ -32,17 +33,35 @@ DrawSample(GLboolean wrap)
glEnable(GL_TEXTURE_2D);
- /* texured quad */
- glBegin(GL_QUAD_STRIP);
- for (p = 0.0; p <= 1.001; p += 0.1) {
- float x = -2.0 + p * 4.0;
- float s = p + 0.5;
- if (wrap && s > 1.0)
- s -= 1.0;
- glTexCoord2f(s, 0); glVertex2f(x, -1);
- glTexCoord2f(s, 1); glVertex2f(x, +1);
+ if (Lines) {
+ /* texured lines */
+ float t;
+ for (t = 0; t <= 1.0; t += 0.125) {
+ float y = -1.0 + 2.0 * t;
+ glBegin(GL_LINE_STRIP);
+ for (p = 0.0; p <= 1.001; p += 0.05) {
+ float x = -2.0 + p * 4.0;
+ float s = p + 0.5;
+ if (wrap && s > 1.0)
+ s -= 1.0;
+ glTexCoord2f(s, t); glVertex2f(x, y);
+ }
+ glEnd();
+ }
+ }
+ else {
+ /* texured quads */
+ glBegin(GL_QUAD_STRIP);
+ for (p = 0.0; p <= 1.001; p += 0.1) {
+ float x = -2.0 + p * 4.0;
+ float s = p + 0.5;
+ if (wrap && s > 1.0)
+ s -= 1.0;
+ glTexCoord2f(s, 0); glVertex2f(x, -1);
+ glTexCoord2f(s, 1); glVertex2f(x, +1);
+ }
+ glEnd();
}
- glEnd();
glDisable(GL_TEXTURE_2D);
@@ -138,6 +157,10 @@ Key(unsigned char key, int x, int y)
else
printf("Cylindrical wrap off.\n");
break;
+ case 'l':
+ case 'L':
+ Lines = !Lines;
+ break;
case 27:
glutDestroyWindow(Win);
exit(0);
@@ -215,6 +238,7 @@ Init(void)
glPointSize(3.0);
printf("Press 'c' to toggle cylindrical wrap mode.\n");
+ printf("Press 'l' to toggle line / quad drawing.\n");
}