I'm trying to draw a line using a GL_TRIANGLE_STRIP that will go deeper or more shallow with the z coordinate, but the the z value I'm passing into glVertex3f() doesn't seem to affect the perceived width. In the code below (a modified example from OpenGL Programming Guide), the line should start closer to the perspective (larger), and get farther (smaller).
Would you point to my mistake, or a topic in which this it is addressed?
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
}
void display(void)
{
GLdouble gran = 5.0;
GLdouble width = 7.0;
GLdouble theta = 1.047197551;
GLdouble halfPi = 3.1459/2;
GLdouble refpx = 50.0;
GLdouble refpy = 50.0;
GLdouble startr = 1.0;
GLdouble startg = 1.0;
GLdouble startb = .5;
glClear(GL_COLOR_BUFFER_BIT);
//glLoadIdentity();
//glScalef(2.0, -.5,1.0);
//glRotatef(45.0, 0.0, 0.0, 1.0);
glBegin(GL_TRIANGLE_STRIP);
for(int i = 0; i < 40; i++)
{
glColor3f(startr / i, startg / (20 - (i%20)), startb);
GLdouble x1 = refpx + width*cos(theta + halfPi);
GLdouble x2 = refpx + width*cos(theta + halfPi*3);
GLdouble y1 = refpy + width*sin(theta + halfPi);
GLdouble y2 = refpy + width*sin(theta + halfPi*3);
glVertex3f(x1,y1, (GLdouble)i/40.0);
glVertex3f(x2,y2, (GLdouble)i/40.0);
refpx += gran*cos(theta);
refpy += gran*sin(theta);
if(i % 9 == 0) {
theta += halfPi/8;
}
if(i == 20) {
theta -= halfPi/2;
}
if(i == 5) {
theta -= halfPi/2;
}
}
glEnd();
glDisable(GL_BLEND);
glFlush();
}
void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, (GLdouble) w, 0.0, (GLdouble) h, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(450, 450);
glutInitWindowPosition(100, 100);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}